How to make a simple object that does only 2 things?
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
How to make a simple object that does only 2 things?
Hey im trying for a player to spawn an object which will have a 3D mesh, and that 3D mesh should collide all instant hit bullets and projectiles,
the second thing but not very necessary would be to always stick up at the same location as the instigator which is the player.
Can someone show me how to make this simple object so i can later learn from it to make more advanced ones?
Thanks in advance!
the second thing but not very necessary would be to always stick up at the same location as the instigator which is the player.
Can someone show me how to make this simple object so i can later learn from it to make more advanced ones?
Thanks in advance!
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
Alright im making progresses, ill need some tick updates and i hope i can get it working, right now heres the main problem.
function bool BlocksShotAt(Actor Other)
{
if ( (Other == Owner) || (Other == ONSPowerCore(Owner).ShootTarget) )
return false;
return true;
}
i believe this is where the collision with the projectile works, how can i unblock any projectiles from red team? and how can i block projectiles from no team?
Thanks in advance!
function bool BlocksShotAt(Actor Other)
{
if ( (Other == Owner) || (Other == ONSPowerCore(Owner).ShootTarget) )
return false;
return true;
}
i believe this is where the collision with the projectile works, how can i unblock any projectiles from red team? and how can i block projectiles from no team?
Thanks in advance!
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
NVm that last part, this is the working code:
However im having huge issues with replications.... heres what ive come up with:
it doesnt spawn at all times, sometimes it misses :S
and the protection class:
Here something even weirder happens, for me it shows bullets colliding with the mesh, but i still can hit them, which probably means it gets replicated for me but not for the server?? o.O
Can someone explain to me what im doing wrong?
Thanks in advance!
Code: Select all
simulated function Touch(Actor Other)
{
if (Projectile(Other) != None)
{
TakeDamage(1, Other.Instigator, Other.Location, vect(0,0,0), Projectile(Other).MyDamageType);
Projectile(Other).Explode(Other.Location, Normal(Other.Velocity));
}
}
However im having huge issues with replications.... heres what ive come up with:
Code: Select all
simulated function Tick(float DeltaTime)
{
if (SpawnProt)
{
Instigator.spawn(class'ShieldPowerUpProtection1A', Instigator.Controller,,Instigator.Location);
Instigator.ReceiveLocalizedMessage(Class'PickupMessagePlus',2,,,class);
SpawnProt=false;
}
}
replication
{
reliable if (Role == ROLE_Authority)
SpawnProt;
}
it doesnt spawn at all times, sometimes it misses :S
and the protection class:
Code: Select all
simulated function Tick(float DeltaTime)
{
if (StartupCheck)
{
bHidden=False;
SetCollision(true);
StartupCheck=false;
}
}
replication
{
reliable if (Role == ROLE_Authority)
StartupCheck;
}
Can someone explain to me what im doing wrong?
Thanks in advance!
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
oh i forgot to mention that this class is an extension from actor
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
Ok well ive made the code less confusing now, here is what i have:
This works fine, it spawns fine, it collides fine, however sometimes the tick event inside the if statement doesnt execute properly, is there some sort of failrate for replication or something?
Theres also a problem in which ive been stuck for a few hours:
When the shield power up reaches the lifespan time, it gets destroyed, and bullets pass through, but theres a huge problem with server replication or something, because any projectiles that passes through that area where it was destroyed and hits you, will count as if nothing happened to you, as if the server still is replicating the collision and so the projectiles are destroyed in that area even if you see the projectiles hitting you.
Its like they hit u, but dont do you any damage, nor momentum transfer, nothing...
I dont know what i can do, heres the code for the SPUP:
But I know no solution for this, please can somebody help?
Code: Select all
var ShieldPowerUpProtection1A SPUP;
simulated function Tick(float DeltaTime)
{
if (SpawnProt)
{
SPUP=Instigator.spawn(class'ShieldPowerUpProtection1A', Instigator.Controller,,Instigator.Location);
SPUP.bHidden=False;
SPUP.SetCollision(true);
SPUP.LifeSpan=16.000000;
Instigator.ReceiveLocalizedMessage(Class'PickupMessagePlus',2,,,class);
SpawnProt=false;
}
}
replication
{
reliable if (bNetDirty && Role == ROLE_Authority)
SpawnProt;
}
Theres also a problem in which ive been stuck for a few hours:
When the shield power up reaches the lifespan time, it gets destroyed, and bullets pass through, but theres a huge problem with server replication or something, because any projectiles that passes through that area where it was destroyed and hits you, will count as if nothing happened to you, as if the server still is replicating the collision and so the projectiles are destroyed in that area even if you see the projectiles hitting you.
Its like they hit u, but dont do you any damage, nor momentum transfer, nothing...
I dont know what i can do, heres the code for the SPUP:
Code: Select all
class ShieldPowerUpProtection1A extends Actor;
simulated function Touch(Actor Other)
{
if (Projectile(Other) != None)
{
TakeDamage(1, Other.Instigator, Other.Location, vect(0,0,0), Projectile(Other).MyDamageType);
Projectile(Other).Explode(Other.Location, Normal(Other.Velocity));
}
}
function bool BlocksShotAt(Actor Other)
{
if ( (Other == Owner) || (Other == ONSPowerCore(Owner).ShootTarget) )
return false;
return true;
}
defaultproperties
{
Texture=FinalBlend'AW-ShieldShaders.Shaders.BlueShieldFinal'
DrawType=DT_StaticMesh
StaticMesh=StaticMesh'AW-ShieldShaders.ONS.EnergonShield'
bStasis=True
bAcceptsProjectors=False
bIgnoreEncroachers=True
RemoteRole=ROLE_None
DrawScale3D=(X=2.000000,Y=2.000000)
PrePivot=(Z=-250.000000)
bMovable=False
CollisionRadius=215.000000
CollisionHeight=190.000000
bProjTarget=True
bUseCylinderCollision=True
StartDestroying=False
}
But I know no solution for this, please can somebody help?
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
ive asked for help from another player and he says he also cant see it when that shield is spawned by me, he can only see it if its spawned by him, so something is not getting replicated right isnt it?
What am i missing?
What am i missing?
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
Alright so apparently ive wasted almost if not already 2 days only to discover i forgot the RemoteRole=ROLE_None....
i changed the Role and now its fine -_-
Now, can anyone tell me how can i update this "actor" location to somewhere else?
i want it to be able to follow the player at all times untill its destroyed, i can get the player location fine, what i dont know is how exactly i change the shield location.
Any ideas on that?
i changed the Role and now its fine -_-
Now, can anyone tell me how can i update this "actor" location to somewhere else?
i want it to be able to follow the player at all times untill its destroyed, i can get the player location fine, what i dont know is how exactly i change the shield location.
Any ideas on that?
- Azarael
- UT2004 Administrator
- Posts: 5365
- Joined: Thu 11 Feb , 2010 10:52 pm
Re: How to make a simple object that does only 2 things?
Try attaching the actor to the Pawn at spawntime. I forget the function, but there are examples in the UnrealScript.
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
attaching pawn, hmm that could work very well, would it be less net consuming than my current method?Azarael wrote:Try attaching the actor to the Pawn at spawntime. I forget the function, but there are examples in the UnrealScript.
what im currently doing for that is setting its location based on tick delta time refresh rate, every tick depending on the player position obviously, and im replication the shield position like this:
Code: Select all
reliable if (bNetDirty && Role == ROLE_Authority)
TheOwnerOfThis;
}
EDIT:
On a sight note it would be awsome if someone could help me out with this:
first the code:
Code: Select all
simulated event Touch(Actor Other)
{
local Emitter MyDestroyEffect;
if(Projectile(Other) != None && !Other.bDeleteMe)
{
if (Level.Netmode != NM_DEDICATEDSERVER)
MyDestroyEffect = Spawn(class'Onslaught.ONSPlasmaHitPurple',self,,Other.Location);
Other.Destroy();
}
}
This is so any projectiles colliding with the shield are destroyed, i have a huge problem because instanthit projectiles go through, how can i block instanthit projectiles too?
And finally, how can i block a specific team projectiles, lets say red team projectiles only, i want this so it will not block my own team projectiles, only the enemy team.
Thanks in advance!
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to make a simple object that does only 2 things?
Is this it? SPUP.SetBase(SPUP.TheOwnerOfThis)?
i dont know if i like it much, when u leave a vehicle sometimes the protection aura appears at a really distant place from u and sometimes it auto refreshes to your position after a couple of seconds or stay like that untill it gets destroyed :\
Am i missing some replications for this? currently im replicating nothing in the SPUP class with this current method.
EDIT: oh ive also forgot, what is the correct event to check TheOwnerOfThis death? TheOwnerOfThis is actually a player, i want the shield to destroy itself automatically if for some reason the player dies before the lifespan of the shield, all i could find was targetby events, which obviously dont work into this example, ive also tried this:
No joy.
i dont know if i like it much, when u leave a vehicle sometimes the protection aura appears at a really distant place from u and sometimes it auto refreshes to your position after a couple of seconds or stay like that untill it gets destroyed :\
Am i missing some replications for this? currently im replicating nothing in the SPUP class with this current method.
EDIT: oh ive also forgot, what is the correct event to check TheOwnerOfThis death? TheOwnerOfThis is actually a player, i want the shield to destroy itself automatically if for some reason the player dies before the lifespan of the shield, all i could find was targetby events, which obviously dont work into this example, ive also tried this:
Code: Select all
function Actor(TheOwnerOfThis).Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
}
Who is online
Users browsing this forum: No registered users and 19 guests