I have an asteroid following a path on a spline. Now I want it to gyrate, but taking advantage of unreal physics rather then re-inventing the wheel.
First I had to learn that my movement along the spline (during tick) causes a problem. I used “SetActorLocation” and once I started to simulate physics, my asteroids stopped moving. Apparently, the static mesh component of the asteroid, which was not the scene root, doesn’t move along with the actor anymore once “simulate physics” its active.
When I hit the simulate button, I could even see how the static mesh component detaches from the scene root.
I then tried to add a PhysicsConstraintComponent to simply tie the static mesh component to the scene root. To no avail.
Going for the alternative now: I removed the scene root and promoted the static mesh component to scene root. This way, I don’t need a physics constraint component. And indeed: my static mesh component moves along the spline again, even with physics enabled.
However, now “add angular impulse” doesn’t work anymore: the asteroid doesn’t gyrate.
So I can either have the asteroid moving OR gyrating (with unreal physics), not both.
I tried the varies options bSweep = true and ETeleportType::TeleportPhysics, but they don’t make a difference.
No, spline is the root in my case.
I’ve just tried it with the cube as the root and a spline in a separate actor. Works the same.
Your issue must be elsewhere.
I am still working on this. The thing is that I use C++ for the movement along the spline. It shouldn’t really matter, the blueprint version seems identical. As soon as I activate one of the following lines, the object stops moving and starts spinning:
SetActorLocation calls MoveComponent which requires a rotation. It shouldn’t to anything as it sets the rotation to the object’s current rotation. But maybe I have to move my actor to a different Tick Group.
turns out, calling SetPhysicsLinearVelocity (as well as AddImpulse) works fine. Rotation and movement. Only, for movement along a spline, SetLocation is really what I want. Otherwise the movement will drift away from the path.
I am assuming, this doesn’t work anymore in UE 5.0
Also, I won’t use “simulate physics” for now. As my asteroids move on a defined path along the spline, simulate physics interferes all the time. I will have to figure out how to manually deal with collisions, basically rewriting unreal chaos physics to my space physics. Ideally this is a minor adaption to unreal physics, but I’ll have to see …