PDA

View Full Version : Kactorspawnable pushing physics. :o



Spaceman1861
12-02-2011, 05:02 PM
Hey guys,

I have a pawn which has a couple of sockets in its mesh which i have attached a set of kactorspawnalbes too. The Idea is when you shoot the kactor it falls of the pawn, this part works. However what im am having an issues is that after the kactor has detached from the pawn i can't push it with my pawn like i would a normal kactor i place in editor. Ive been trolling the net looking for awnsers but all i can seem to find is "i've solved it thanks guys :D!", never an explanation :(.

I'm using the same static mesh as i do for my kactors in the editor and i can push them around no problem.
I have set a physics scale.
I have set a collision on the mesh in the editor.


Pushing Pawn Code


bPushesRigidBodies=true
RBPushStrength = 200.0;


Pawn with actors attached Code


class StationaryPawn extends UTPawn placeable;

var TurretController MyController;
var float Speed;

var SkeletalMeshComponent MyMesh;
var bool bplayed;
var Name AnimSetName;
var AnimNodeSequence MyAnimPlayControl;

var () float attackrange;
var () float perceptionDistance;
var () float hearingDistance;
var Syn_ModularPawn_Spike Spike1,Spike2,Spike3,Spike4;
var Synergy2_MovableObject Sphere;
var Vector SocketLocation;
var Rotator SocketRotation;


defaultproperties
{

Begin Object Class=SkeletalMeshComponent Name=InitialSkeletalMesh
CastShadow=true
bCastDynamicShadow=true
bOwnerNoSee=false
LightEnvironment=MyLightEnvironment;
BlockRigidBody=true;
CollideActors=true;
BlockZeroExtent=true;
HiddenGame=true;
SkeletalMesh=SkeletalMesh'SynergyTest.SkeletalMesh .Test'
End Object

Mesh=InitialSkeletalMesh;
Components.Add(InitialSkeletalMesh);
}

function TurretController GetController(){
return MyController;
}




simulated function PostBeginPlay()
{
if (Mesh != None)
{
if (Mesh.GetSocketByName('Right Arm') != None)
{
Mesh.GetSocketWorldLocationAndRotation('Right Arm', SocketLocation, SocketRotation);

Spike1 = Spawn(class'Syn_ModularPawn_Spike',,, SocketLocation, SocketRotation);

if (Spike1 != None)
{
Spike1.SetBase(self,, Mesh, 'Right Arm');
Spike1.ForceNetRelevant();
Spike1.bNetDirty = true;
}
}
if (Mesh.GetSocketByName('Left Arm') != None)
{
Mesh.GetSocketWorldLocationAndRotation('Left Arm', SocketLocation, SocketRotation);

Spike2 = Spawn(class'Syn_ModularPawn_Spike',,, SocketLocation, SocketRotation);

if (Spike2 != None)
{
Spike2.SetBase(self,, Mesh, 'Left Arm');
Spike2.ForceNetRelevant();
Spike2.bNetDirty = true;
}
}
if (Mesh.GetSocketByName('FrontArm') != None)
{
Mesh.GetSocketWorldLocationAndRotation('FrontArm', SocketLocation, SocketRotation);

Spike3 = Spawn(class'Syn_ModularPawn_Spike',,, SocketLocation, SocketRotation);

if (Spike3 != None)
{
Spike3.SetBase(self,, Mesh, 'FrontArm');
Spike3.ForceNetRelevant();
Spike3.bNetDirty = true;
}
}
if (Mesh.GetSocketByName('BackArm') != None)
{
Mesh.GetSocketWorldLocationAndRotation('BackArm', SocketLocation, SocketRotation);

Spike4 = Spawn(class'Syn_ModularPawn_Spike',,, SocketLocation, SocketRotation);

if (Spike4 != None)
{
Spike4.SetBase(self,, Mesh, 'BackArm');
Spike4.ForceNetRelevant();
Spike4.bNetDirty = true;
}
}
if (Mesh.GetSocketByName('Middle') != None)
{
Mesh.GetSocketWorldLocationAndRotation('Middle', SocketLocation, SocketRotation);

Sphere = Spawn(class'Synergy2_MovableObject',,, SocketLocation, SocketRotation);

if (Sphere != None)
{
Sphere.SetBase(self,, Mesh, 'Middle');
Sphere.ForceNetRelevant();
Sphere.bNetDirty = true;
}
}
}


super.PostBeginPlay();
SetPhysics(PHYS_Walking);
if (MyController == none)
{
MyController = Spawn(class'TurretController', self);
MyController.SetPawn(self);
}
}



KactorSpawnable Code


class Syn_ModularPawn_Spike extends KActorSpawnable;
var Float Hp;
var int d;

Simulated Event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
Super.TakeDamage(DamageAmount,EventInstigator,HitL ocation,Momentum,DamageType,HitInfo,DamageCauser);
Hp = Hp-DamageAmount;
`log(Hp);
if(Hp < 0 ) {
self.SetBase(none);
self.SetPhysics(PHYS_Falling);
self.SetPhysics(PHYS_RigidBody);

}
}

defaultproperties
{
bMovable = true;
bCanStepUpOn = false
bProjTarget=true
bCollideActors=true
bCollideWorld=true
bHardAttach=true
Hp = 10;

Begin Object Class=StaticMeshComponent Name=RollerSpike
StaticMesh=StaticMesh'SynergyTest.RollerSpike'
bNotifyRigidBodyCollision=true

HiddenGame=FALSE
ScriptRigidBodyCollisionThreshold=0.001
LightingChannels=(Dynamic=TRUE)
BlockRigidBody=true
RBChannel=RBCC_GameplayPhysics
RBCollideWithChannels=(Default=TRUE,BlockingVolume =TRUE,GameplayPhysics=TRUE,EffectPhysics=TRUE)
bCollideActors = true
bCollideWorld = true
bBlockActors = true

End Object
CollisionComponent=RollerSpike
Components.Add(RollerSpike)
bDamageAppliesImpulse = false;
}

Any Ideas Would be Wikid :D

Spaceman1861
12-04-2011, 07:27 AM
Bumping for coding justice!

staticvoidlol
12-04-2011, 05:12 PM
You can use the Bump function.



simulated function Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
{

//Add your code here e.g.
WorldInfo.Game.Broadcast(self, "Bumped", );
if(YourPawn(Other)!=none)
ApplyImpulse(MomentumVect,
DamageType.default.KDamageImpulse,
self.Location - Other.Location,
,//HitInfo,
DamageType);

//etc
super.Bump(Other, OtherComp, HitNormal);
}

Spaceman1861
12-04-2011, 06:25 PM
Thanks for the reply i will give it a try and report back.:D