PDA

View Full Version : Skeletalmesh KActor with physics



Barzorx
12-04-2011, 01:36 AM
Yup, I pretty much sumed up my problem on the title. I have a KActor, with no physics. I added in a phAt but no dice. Its a placeable kactor, and I dont really want it to be uber physics or anything, just to have a small gravity and heavy feeling to it. Any idea or suggestions would be appreciated.

Thanks!

ADayInForever
12-04-2011, 01:45 AM
What do you mean you added in a phAt? Do you mean you added a PhysicsAsset to your actor?

I think if you go into your KActor's properties window, you should see an option called "Physics Weight" under your skeletalmeshcomponent tab. Try setting it to a value greater than zero, see if anything happens.

Failing that, I think UDN also lists some video tutorials on the subject from 3DBuzz, which you can pick up here: http://udn.epicgames.com/Three/VideoTutorials.html#3D%20Buzz%20Video%20Tutorials% 20-%20Using%20UDK

Other than that, can't really recommend much to you. Good luck.

Barzorx
12-04-2011, 03:15 AM
Yep, I added a physics asset to the skel mesh, but nothing really happened. It defies gravity and stuff.

/edit

Also, even though through the code I specify a skeletalmeshcomponent, in the editor there are no skeletalmeshcomponent tabs. There is a staticmesh tab, but it says there's no mesh in it.

I know the skeletalmesh is there though, i can see it, and particles popup where the sockets are. Is there any other way?

uberman
12-04-2011, 08:28 PM
there must be an "WakeOnLevelStart" -option (F4) in your placeable KActor I think.
If so, check it.

Barzorx
12-05-2011, 12:36 AM
Yeah, I already know its there. And its already toggled. Its on by default, and it didnt really matter if it was on or off, both ways it has no physics and I cant move it with the physics gun either

Barzorx
12-05-2011, 10:25 AM
Bump, here's some of my code so you guys can see what im doing or.. trying to at least



class MercedesHull extends KActor
placeable;

var int Health;
//var DynamicLightEnvironmentComponent LightEnvironment;
var ParticleSystem FireEmitter1, Explosion;
var bool Fire1;
var bool Fire2;
var bool Fire3;
var bool ExplosionEm;
var SkeletalMeshComponent Mercedes;

var class<DamageType> dmgType;
var float DefaultImpulse;

auto state Active
{

event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
dmgType = DamageType;
`log("Damage done "@Damage);
Health -= Damage;
Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);


if(!Fire1 && Health<=70)
{
SpawnEffect(1);
Fire1=true;
}

if(!Fire2 && Health<=50)
{
SpawnEffect(2);
Fire2=true;
}

if(!Fire3 && Health<=20)
{
SpawnEffect(3);
Fire3=true;
}

if(Health<=0 && !ExplosionEm)
{
ExplosionEm=true;
ExplodingCar();
HurtRadius
(
75,
128,
dmgType,
0,
Location,
None,
EventInstigator,
false
);
}

}

simulated function Tick(float DeltaTime)
{

super.Tick(DeltaTime);

if(Health<=35 && Health>0)
{
Health-=5;
`log("Self Damage for 5 points, HP left "@Health);
}
if(Health<0 && !ExplosionEm)
{
ExplosionEm=true;
ExplodingCar();

}
}


function ExplodingCar()
{
SpawnEffect(4);
ExplosionEm=true;
ApplyImpulse(vect(0,0,10),DefaultImpulse, vect(0,0,0));
HurtRadius
(
1000,
1000,
dmgType,
0,
Location,
,
,
);

GoToState('Dead');
}

}


state Dead
{
ignores TakeDamage,TakeRadiusDamage;

}


function SpawnEffect(int number)
{
if(number==1){ WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment (FireEmitter1,Mercedes, 'FireParticle1',true,,);}

if(number==2){ WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment (FireEmitter1,Mercedes, 'FireParticle2',true,,);}

if(number==3){ WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment (FireEmitter1,Mercedes, 'FireParticle3',true,,);}

if(number==4){ WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment (Explosion,Mercedes, 'FireParticle3',true,,);}

}

defaultproperties
{
Fire1=false
Fire2=false
Fire3=false
ExplosionEm=false
Health=100
bBlockActors=true
bCollideWorld=true
bCollideActors=true
bPathColliding=true


DefaultImpulse=20.0

//particlesystems
FireEmitter1=ParticleSystem'Particles.FlameTorch_C ARS'
Explosion=ParticleSystem'Particles.Explosion_Merce des'

//Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
// bSynthesizeSHLight=true
// bUseBooleanEnvironmentShadowing=false
// End Object
// LightEnvironment=MyLightEnvironment
// Components.Add(MyLightEnvironment)

bWakeOnLevelStart=true

Begin Object class=SkeletalMeshComponent name=MercedesHull
SkeletalMesh=SkeletalMesh'HD_CivilianVehicles.Merc edes_Rigged'
PhysicsAsset=PhysicsAsset'HD_CivilianVehicles.Merc edes_Rigged_Physics'
CollideActors=true
BlockActors=true
BlockNonZeroExtent=true
BlockZeroExtent=true
Scale=10.0
LightingChannels=(Dynamic=TRUE)
AlwaysCheckCollision=TRUE
End Object
Components.Add(MercedesHull);
Mercedes=MercedesHull;
}


The code itself still has a couple of glitches, but I can fix those myself. Im more worried about why it has no physics at all.

uberman
12-05-2011, 10:59 AM
try to set DefaultImpulse higher for testing purpose (like 20000).
and to be sure set "Health <= 0" in Tick.

hope it changes something

Barzorx
12-05-2011, 11:45 AM
done and done, still no gravity and no physics on the car though...

ffejnosliw
12-05-2011, 12:04 PM
Why are you using KActor? KActor is for static mesh rigid bodies. KAsset is for skeletal mesh rigid bodies.

ADayInForever
12-05-2011, 12:10 PM
Of course... it makes sense now!

You said that the skeletalmeshcomponent did not show up in your object's properties, right? It's because in the code you pasted, you have not formally declared the end of the object, and added the component.

In your code here:


Begin Object class=SkeletalMeshComponent name=MercedesHull
SkeletalMesh=SkeletalMesh'HD_CivilianVehicles.Merc edes_Rigged'
PhysicsAsset=PhysicsAsset'HD_CivilianVehicles.Merc edes_Rigged_Physics'
CollideActors=true
BlockActors=true
BlockNonZeroExtent=true
BlockZeroExtent=true
Scale=10.0
LightingChannels=(Dynamic=TRUE)
AlwaysCheckCollision=TRUE
End Object
Components.Add(MercedesHull);
Mercedes=MercedesHull;
}


On the next line after your "Mercedes=MercedesHull;" parameter, you need to add this:



End Object
Components.Add(MercedesHull)


Now the skeletalmeshcomponent tab should end up in your properties now, along with your physicsasset property. But I don't know if this will create the proper physics for your object though.

Start from there, see what happens.

Barzorx
12-05-2011, 03:49 PM
@ADayInForever uhh that line is right there though. Right before the mercedes=mercedeshull, I end the object and add it in to the components list. I moved the code around though and still no Physis Weight in any tab, just in case.


@ffejnosliw I'm using KActor so I can use the ApplyImpulse function, KAsset doesnt have that.

Solid Snake
12-05-2011, 04:01 PM
You can implement ApplyImpulse yourself since the relevant functions are implemented in PrimitiveComponent anyways. StaticMeshComponent and SkeletalMeshComponent are both subclasses of PrimitiveComponent.

You could probably copy and paste KActor.ApplyImpulse() into KAsset no problems. Although make sure you subclass KAsset, instead of modifying the original source code.

Barzorx
12-05-2011, 04:10 PM
Well, extending from KAsset doesnt do the trick by itself though, the car is pretty much still floating, and not movable though.

ffejnosliw
12-05-2011, 04:45 PM
It sounds like you are making a vehicle. Can I ask why you aren't using the vehicle classes?

Barzorx
12-05-2011, 05:09 PM
Because its not a vehicle per se, it's not meant to be used, just stand there and explode whenever I shoot at it. The idea is having multiple vehicles that will explode after X amount of hits, while shooting at it it catches on fire and the moment of the explosion it causes damage to everything surrounding it. If it explodes, it should obviously raise up a bit or something to add in some dramatic effects... but i cant even get it to move at all after exploding. I use a skel mesh to use sockets, where i spawn the particle systems of fire and explosion.

Barzorx
12-06-2011, 06:26 PM
bump for programming goodness! I still havent managed to get it working :(

Barzorx
12-07-2011, 05:04 PM
anyone? please? D:

Barzorx
12-08-2011, 04:42 PM
Seriously though, any idea is good. I really need to add some sort of physics to the car itself.

Maybe im wrong and i dont have to use a KActor. What I need is to use a skeletalmesh for its sockets, some sort of physics so the car will fall off, and to be able to use an impulse and radialdamage post-explosion...

fingolfin
12-09-2011, 05:37 AM
I have been trying to do the same thing, except that I was trying to create a street lamp with physics and sockets on it. Couldn't manage to work mine either.

Barzorx
12-09-2011, 05:04 PM
There has to be a way to do this. Someone out there has to know why a skeletal mesh kactor has no physics. Or maybe its just a matter of using a different class?

ankangronto
12-09-2011, 07:19 PM
As has been stated before, use KAsset for skeletal meshes.

For the ApplyImpulse() function just make a new class that extends KAsset and implement the ApplyImpulse() function yourself, basically copy paste it from KActor should work.

For the problem of not seeing the SkeletalMeshComponent in the properties, you haven't even declared that the SkeletalMeshComponent should be visible in the properties
what you have is:

var SkeletalMeshComponent Mercedes;

where is should be:

var(Whatever) SkeletalMeshComponent merchedes;