Ok I decided to help you on your way. But we are simply not doing homework for you. UDK documentation seems down for maintainance but I have found this: http://www.moug-portfolio.info/udk-projectiles/ example. You should read it completely since it helps you understand projectiles. Towards the bottom they explain projectiles. Let it be clear that I have no experience other then creating some simple maps a decade ago with UDK.
The code I found on the mentioned website that I will be discussing:
class SandboxPaintballProjectile extends UDKProjectile;
simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal)
{
if ( Other != Instigator )
{
WorldInfo.MyDecalManager.SpawnDecal ( DecalMaterial'SandboxContent.Materials.DM_Paintball_Splash', HitLocation, rotator(-HitNormal), 128, 128, 256, false, FRand() * 360, none );
Other.TakeDamage( Damage, InstigatorController, Location, MomentumTransfer * Normal(Velocity), MyDamageType,, self);
Destroy();
}
}
simulated event HitWall(vector HitNormal, actor Wall, PrimitiveComponent WallComp)
{
Velocity = MirrorVectorByNormal(Velocity,HitNormal); //That's the bounce
SetRotation(Rotator(Velocity));
TriggerEventClass(class'SeqEvent_HitWall', Wall);
}
DefaultProperties
{
Begin Object Name=CollisionCylinder
CollisionRadius=8
CollisionHeight=16
End Object
Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
bEnabled=TRUE
End Object
Components.Add(MyLightEnvironment)
begin object class=StaticMeshComponent Name=BaseMesh
StaticMesh=StaticMesh'SandboxContent.Meshes.SM_PaintBall'
LightEnvironment=MyLightEnvironment
end object
Components.Add(BaseMesh)
Damage=25
MomentumTransfer=10
}
My first assumption is that if you create a weapon with a projectile you have this script attached to it. I simply cannot help you with that.
As Mougli talks about this he explains that if a wall or actor with bWorldGeometry set to true
the HitWall
function/method will be triggered. Since we are not freezing walls or furniture we will leave that alone. Whenever another actor get's hit the ProcessTouch
is being called and like I already mentioned you are supplied by the actor that actually is hit Actor other
.
Now we can call that actor and do stuff with it by doing other.doStuff
. So we want to increment a freeze variable? Then we need to supply this variable first too this actor. So first we need the script actor script.
Let's assign a variable public int freezeCounter = 0f
on top.
Now we can access that variable from the ProcessTouch
method and alter it. other.freezeCounter = 2000
in milliseconds. Whenever an actor is hit he gets his freezeCounter
set to 2000.
Now we need to make sure the actor is not able to move. We could wrap all the actors actions in a if statement stating if (freezeCounter <= 0)
and he will be frozen for it's entire life. The last step is to decrease the freezeCounter
by the amount of miliseconds since the last frame often called something like deltaTime.
The best lesson you should learn from this is to break down your problem into small steps. Try to define these steps and look around on Google for answers, like I did for the Projectile Collision
.
However there might be a view catches. I'm not sure what the definition of actor is in UDK but basically anything that can be hit seems to be an actor. You might have to check in the ProcessTouch
method if an actualy player or character has been hit. Again I do not know the naming conventions but if you open a players script and it says something like class Character extends Actor
then you can add the variable to the Player
script. But then you will not be able to use other.freezeCounter = xxxx
. Now you need to cast it:
if (other instanceof Character) //check if the actor is a character
{
(Player)other.freezeCounter = 2000; //cast other as a player and alter freezeCounter
}
This should get you on your way, otherwise I strongly suggest you tell your teacher to learn you the basics of programming first before telling you to code in a engine you barely know and afaik is pretty much obsolete (could be wrong on my last statement).
<= 0
again. – Menno Gouw Jul 17 at 14:07int freezeTimer
on a player by getting shot. If you made a good attempt but still have undesired behavious then you can post your issue including code and people here are much more willing to do a bit of coding for you and help you on your way. – Menno Gouw Jul 17 at 14:12