How to make a simple object that does only 2 things?

You need help? It's here!
LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

How to make a simple object that does only 2 things?

Post by LegendaryAgent » Sun 16 Oct , 2011 9:58 am

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!

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Mon 17 Oct , 2011 2:47 am

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!

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Tue 18 Oct , 2011 1:53 am

NVm that last part, this is the working code:

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;
}
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!

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Tue 18 Oct , 2011 1:57 pm

oh i forgot to mention that this class is an extension from actor

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Tue 18 Oct , 2011 4:01 pm

Ok well ive made the code less confusing now, here is what i have:


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;
}
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:

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?

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Tue 18 Oct , 2011 6:03 pm

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?

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Tue 18 Oct , 2011 11:40 pm

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?

User avatar
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?

Post by Azarael » Wed 19 Oct , 2011 12:29 am

Try attaching the actor to the Pawn at spawntime. I forget the function, but there are examples in the UnrealScript.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Wed 19 Oct , 2011 2:08 am

Azarael wrote:Try attaching the actor to the Pawn at spawntime. I forget the function, but there are examples in the UnrealScript.
attaching pawn, hmm that could work very well, would it be less net consuming than my current method?
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;
}
it looks smooth online, do u think its to net consuming having the current method?

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!

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a simple object that does only 2 things?

Post by LegendaryAgent » Wed 19 Oct , 2011 2:44 pm

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:

Code: Select all

function Actor(TheOwnerOfThis).Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{

}
No joy.

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests