Home Unreal Engine

Physic Asset Collision Detection

Hey guys, i'm trying to make an instant hit weapon do specific area damage on a spawned pawn(CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA) with some physic assets (SK_CH_Corrupt_Male_Physics). If i enter ShowCollisions in the console i can see the physics assets and that he already comes with cylindrical collider that was not created using my code. When i fire my instant hit weapon he enters ProcessInstantHit function, and detects that the collision occurred in the cylindrical collider and not the physics asset (headshot, for example).

Pawn
class FollowerPawn extends UDKPawn;

defaultproperties
{
    Begin Object Class=SkeletalMeshComponent Name=MySkeletalMesh

		CollideActors=true
		BlockActors=true
		BlockNonZeroExtent=true
		BlockZeroExtent=false
		bHasPhysicsAssetInstance=true
		Scale = 1.75f;
		PhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
		SkeletalMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA'
	End Object

	Components.Add(MySkeletalMesh);
	CollisionComponent=MySkeletalMesh;

	bCollideComplex=false
	
	name='FollowerOne';
}

Weapon
class MyGun extends UDKWeapon;

simulated function ProcessInstantHit(byte FiringMode, ImpactInfo Impact, optional int NumHits)
{
 	`Log("Actor = " $ Impact.HitActor);
	`Log("Collider = " $ Impact.HitInfo.HitComponent);
	`Log("Bone = " $ Impact.HitInfo.BoneName);
	`Log("Location = " $ Impact.HitLocation);
	`Log("Location = " $ Impact.HitNormal);
	`Log("----------------------------------------------------");
}

simulated function TimeWeaponEquipping()
{
    AttachWeaponTo( Instigator.Mesh,'WeaponPoint' );
    super.TimeWeaponEquipping();
}

simulated function AttachWeaponTo( SkeletalMeshComponent MeshCpnt, optional Name SocketName )
{
    MeshCpnt.AttachComponentToSocket(Mesh,SocketName);
}

DefaultProperties
{
	FiringStatesArray(0)=WeaponFiring //We don't need to define a new state
    WeaponFireTypes(0)=EWFT_InstantHit
    FireInterval(0)=0.1
    Spread(0)=0

	Begin Object class=SkeletalMeshComponent Name=GunMesh
	SkeletalMesh=SkeletalMesh'WP_LinkGun.Mesh.SK_WP_Linkgun_3P'
	HiddenGame=FALSE 
	HiddenEditor=FALSE
    end object
    Mesh=GunMesh
    Components.Add(GunMesh)
}

See anything wrong? I've tried putting BlockZeroExtent=false to try to instruct the built-in cylindrical collider to ignore the instant hit and let the physics assets detect it, but it still detects it. I've also found the TraceAllPhysicsAssetInteractions (which might be useful for multiple headshots with one bullet) but not sure if it's overkill or if there is a better way to detect my instant hits.

I'm deriving from UDK-level code, not UT-level.

Replies

  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Your physics asset isn't usually used for top level collision detection. The cylinder allows the game to run at a respectable speed in a complex environment.
    For location specific damage you're going to need to pass on the hit location from take damage into some function that compares the hit location in actor space to some known locations on the actor. There may be a function like radius from socket or something that can be of help.

    Headshots in previous unreal games were done this way. There was a coded offset for where the head was and the damage taking routine compared the impact point to the head point. If it was a headshot capable weapon a headshot was registered and the special death was played.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    I'm pretty sure that instant hit weapons do not ever use physics volumes to detect hits. Otherwise you'd get a lot of incorrect misses and hits on character models.
  • xlar8or
    Options
    Offline / Send Message
    First of all, thnks for the replies, been stuck with this a little while now. So, what are physic assets really for? ragdolls and stuff? I'm basically trying to do a melee system and i wanted to know if my sword gave an instant hit i could detect which physic asset he collided and, for example, rip it, or give more/less damage. An approach for detecting good hits that i saw was in Chivalry, they put traces from the socket to the tip of the sword almost every frame and detect hits, but i don't think it's location specific damage. Either way i would like to know how they did that. Anyway, from what i understood of what you said, when my pawn gets hurt i take the HitLocation and compare it through some radius function and check if there's some bone in that area, no? the radius should have a well thought value, because if i set it too small, it never hits the bone, if i set it too high i'll get incorrect hits, right?
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Physics assets are for ragdolls primarily, and also for shadowcasting, and for other physical interactions like cloth and clothing and foliage, stuff thats actually physically simulated. I think they may actually be used for collision detection, its just a second level of it. The initial collision event that is registering is the cylinder, but the next level down uses the collision mesh/physics asset to assign damage and actual hits. At least I think this is the case. I haven't tested this to be sure, but it seemed the case from what I remember of using the sniper rifle.

    You can get a socket's location in either world or local space it looks like. So long as you have a hitlocation on the damaged actor you could create a list of your known socket names, then just loop through them to find the one that is closest to the hit location and assign the hit to that bone in whatever your damage methods are.

    As for weaponry, you could have a very rapidfire near zero extent trace weapon that moves its emitter point, OR you can customize your firing routine to do a radius check around the wielder, then refine the hit actors list with some angular or distance routine to cull those outside the swing area from being hit. I made a quick and dirty melee weapons system a couple years back that used radius checks like this with a custom weapon type to get melee like behaviour.

    It worked, there were likely some mishits, but in really rapid combat it wasn't terribly noticable.
Sign In or Register to comment.