Hi there,
So I have an actor class which contains 1 static mesh component and code to handle some gameplay things. When spawned a force is applied to the skeletal mesh body instance like so:
FBodyInstance* BodyInstance = StaticMeshComp->GetBodyInstance();
if (BodyInstance && BodyInstance->IsInstanceSimulatingPhysics())
{
FVector ForceVec = ForceDirection * ForceToUse;
StaticMeshComp->AddImpulse(ForceVec, NAME_None, true);
}
about 90% of the time this will cause the actor to fly out with the desired physics (inc gravity), but the other 10% it will actually fail to move and just fall down with gravity as if stuck. Note that I get this using the exact same Blueprint parent, so each object is the same.
Now these actors are being spawned on a socket of the player so there is overlap between the two, however the skeletal mesh is being spawned with an overlap condition of all pawns (in fact we have gone to the extreme to fix this by making it overlap all object types, but still have the both physics and query collision enabled).
I have put logging in to ensure that the force is actually being set to a reasonable value in all cases, and it is.
If nothing is set to block this mesh, what else could be causing our actor to not actually move at all. The only component it has is the static mesh component (which is therefore the root one). Why would it work 90% of the time? What other things can I debug to try and work out what is going on here?
From my logging here you can see that it does actually initially move for the first few ticks, before it stops all X and Y movement and just falls on Z
[2017.01.10-23.54.28:373][536]Explode_Throw_C_5 - got force X=-1993.614 Y=-153.283 Z=-44.795 applied
[2017.01.10-23.54.28:373][536]Explode_Throw_C_5 - Pos X=-3060.249 Y=-408.965 Z=192.741
[2017.01.10-23.54.28:381][537]Explode_Throw_C_5 - Pos X=-3078.381 Y=-410.359 Z=192.214
[2017.01.10-23.54.28:390][538]Explode_Throw_C_5 - Pos X=-3094.992 Y=-411.636 Z=191.663
[2017.01.10-23.54.28:398][539]Explode_Throw_C_5 - Pos X=-3111.601 Y=-412.913 Z=191.045
[2017.01.10-23.54.28:407][540]Explode_Throw_C_5 - Pos X=-3111.601 Y=-412.913 Z=190.977
[2017.01.10-23.54.28:416][541]Explode_Throw_C_5 - Pos X=-3111.601 Y=-412.913 Z=190.820
Where as the one before it keeps going:
[2017.01.10-23.54.26:307][294]Explode_Throw_C_4 - got force X=-1985.258 Y=-242.294 Z=-6.573 applied
[2017.01.10-23.54.26:308][294]Explode_Throw_C_4 - Pos X=-2971.250 Y=-648.023 Z=193.060
[2017.01.10-23.54.26:316][295]Explode_Throw_C_4 - Pos X=-2987.792 Y=-650.042 Z=192.901
[2017.01.10-23.54.26:324][296]Explode_Throw_C_4 - Pos X=-3004.333 Y=-652.060 Z=192.675
[2017.01.10-23.54.26:333][297]Explode_Throw_C_4 - Pos X=-3023.328 Y=-654.379 Z=192.326
[2017.01.10-23.54.26:342][298]Explode_Throw_C_4 - Pos X=-3039.866 Y=-656.397 Z=191.955
[2017.01.10-23.54.26:352][299]Explode_Throw_C_4 - Pos X=-3060.559 Y=-658.922 Z=191.383
[2017.01.10-23.54.26:361][300]Explode_Throw_C_4 - Pos X=-3079.135 Y=-661.190 Z=190.784