In my script, I have an actor that when colliding with the player, will check if certain requirements are met and if they are, they move into the player to be consumed (deleted). If they aren’t. a basic physics simulation takes place and they are knocked away.
When I attempt to do this with simulate physics enabled, the actor doesn’t move to set location (using the SetActorLocation node). There is also no rotation. When it is disabled, the actor rotates and moves to location but I have no physics simulation.
I have tried enabling and disabling physics as collisions take place but if I have simulate physics enabled by default and simply disable it when criteria is met, the SetActorLocation doesn’t work and the actor remains static. If I have simulate physics disabled by default and only enable it when the criteria for collision is not met, the rotating actor suddenly rotates to the default position and stop rotating but the physics simulation works.
Is there anyway to get around this or fix this? Thanks in advance. I would post my blueprints but they are a bit messy and quite long at the moment.
I found two solutions for you that will both work when simulating physics.
The first solution is to apply the rotation directly to your static mesh component in your actor Blueprint. As you can see below I use the “CombineRotators” node to create a new rotation for my “Cube” static mesh ever frame making it spin.
The second solution is to use the “Add Angular Impulse” node on your static mesh rotate it by physically applying impulses. I prefer this solution more because I think it is a little less hacky than the first solution and leads to more realistic behavior.
How do you get the rotation of the physics body? I can rotate my physics-enabled actor with thrusters, but get rotation is returning zeros. If I collide and get spun around, I’ve no idea which way the actor is pointing