• Register
Post tutorial Report RSS UDK KILLING RIGID BODY

This is a simple Killing Rigid Body and the damage is determined by velocity(sort of ).

Posted by on - Intermediate Other

This is the "GravGun.uc" it has the ability to throw rigid bodies:

class GravGun extends UTWeap_Physicsgun;



defaultproperties
{
	HoldDistanceMin=128.0
	HoldDistanceMax=768.0
	WeaponImpulse=5000.0
	ThrowImpulse=10000.0
	ChangeHoldDistanceIncrement=10.0


	WeaponColor=(R=255,G=255,B=128,A=255)
	FireInterval(0)=+0.5
	FireInterval(1)=+0.5
	PlayerViewOffset=(X=0.0,Y=7.0,Z=-9.0)



	FireOffset=(X=16,Y=10)

	AIRating=+0.75
	CurrentRating=+0.75
	bInstantHit=false
	bSplashJump=false
	bRecommendSplashDamage=false
	bSniping=false
	ShouldFireOnRelease(0)=0
	ShouldFireOnRelease(1)=0
	bCanThrow=true

	InventoryGroup=1
	GroupWeight=0.5

	AmmoCount=1
	LockerAmmoCount=1
	MaxAmmoCount=1

	bExportMenuData=false
}

This is the "KActor_KillingRB.uc" with the by velocity determined damage:

class KActor_KillingRB extends KActor;
var()				float			DamageGive;
var()				float			VelDmgDiminuator;
//Used for collision between actors that block, not touch (which allows movement through, but still detects collision)
event Bump(Actor Other, PrimitiveComponent OtherComp, Object.Vector HitNormal)
{


// if what you've hit's class is the same as your pawn's class, then it is your pawn, so you should do damage.
 if (Other.IsA('UTPawn'))
  {
	DamageGive=(Velocity.X+Velocity.Y+Velocity.Z)/VelDmgDiminuator;
    Other.TakeDamage( DamageGive, None,Location, vect(0,0,0) , class'DmgType_Crushed');
	

   }

}

defaultproperties
{
	VelDmgDiminuator=3
    bCollideActors=true
    bCollideWorld=true
    bBlockActors=true
    bWakeOnLevelStart=true
    bStatic=false
    bBounce=true
    bNoEncroachCheck=false

   Begin Object Name=StaticMeshComponent0
		WireframeColor=(R=0,G=255,B=128,A=255)
		BlockRigidBody=true
		RBChannel=RBCC_GameplayPhysics
		RBCollideWithChannels=(Default=TRUE,BlockingVolume=TRUE,GameplayPhysics=TRUE,EffectPhysics=TRUE)
		bBlockFootPlacement=false
	End Object


Physics=Phys_RigidBody
}

after you have all this set and compiled for your game , you add them to the scene :
STEPS :
THE GUN IN GAME:
The gun you add it trough the kismet or a : Weapon Pickup Factory(ACTOR CLASSES>Pickups>Weapon>UTWeaponPickupFactory)you go properties and you will find the "Weapon Pickup Class"( put it into your map/scene) and set it to : "GravGun"
THE RIGID BODY IN GAME:
Then your RigidBody (ACTOR CLASS>Physics>KActor>KActor_KillingRB)( put it into your map/scene)
then you will have an empty selected , from that point you go Properties and then : In "Collision>Collision Component>Static Mesh Component>Static Mesh" select in your content browser your mesh and put it inside that value and everything is done !!

!!! the "Damage Give" option in properties is unchangable , the only one you can increase so it kills more difficult is : "Vel Dmg Diminuator" ( Velocity to Damage "Diminuator" = Decrease )


Now the only thing is to enjoy killing others with props and be careful that's a 2 sided blade , can kill you too!!.

HERE IN ACTION THE BOTH CODES
+------------------------------+---+
|Like Half-Life 2 Gravity Gun!!|UDK|
+------------------------------+---+
Thank You !! And have fun!!

Thank you for the second rigid body script ( because it was half done by someone on the internet as a tutorial too)

Post comment Comments
rokyed Author
rokyed

I have forgot to mention that : if the rigidbody is not moving and you step on it , it will not damage your life!!

Reply Good karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: