Rotate physics object towards camera direction over time

my setup is a bit different… so it wouldn’t really help…

just add 2 more PID controllers… to make a total of 3…

make a sequence for the two other PID controllers, just as you have done with the first… feeding in Roll/Pitch/Yaw to your Roll PID, and then each Roll/Pitch/Yaw Stabilization variable into the localspace rotation… AddTorque to the whole converted worldspace vector

looks fine to me… now play with the multiplier value and the sign value of the multiplier (you might be adding the error instead of subtracting it)

you’ll find it a LOT easier to debug… if you use a sequence node and split it out for each PID… and another wire for AddTorque

Can you send some pics of what exactly i need to do cause I’m a bit lost.

Ok I don’t know if this is correct but this is what i got

Still just spins and doesn’t follow the camera rotation.

Alright now it’s starting to work but still have a few problems, after tweaking some of the multiply values I’ve got the jet to actually face the camera direction but if your camera makes a really sharp turn then the jet will rotate too fast and be stuck in a spin loop, also when you turn it kinda bounces from side to side before adjusting which doesn’t look too good on a jet,

Never mind, I set the derivative coefficient inside the PID controllers all to 1 and now it’s actually working really well, I’ll keep tweaking the values but I think this actually works now :smiley:

Excellent! :slight_smile: yes, you can keep tweaking the speed of your camera movement (smooth it using Rinterp), the multiplier, the derivative coefficient (1 is high, but whatever works), angular damping to give you the speed and smoothness that you are aiming for. Good luck!

Just 2 things, if the jet bumps into a wall for example it’s set off course, which is fine that’s what I want but it takes a very annoyingly long time to rotate back to the camera postion so I want to know if there’s a way to speed that up. Also if the camera is rotated directly upwards or downwards it causes the jet to twitch out so for now I’ve just locked the camera’s max and min pitch but I’d like a proper solution to this.

mmm… I’m not quite sure… a couple of things I’ve learned from my own project are:

try to keep the derivative coefficient somewhere between .001 and .4 (.1 is the default)… maybe it’s superstition, but I suspect this will give a smoother calculation. Ideally, instead, to speed up the interpolation, increase the size of the multiplier.

it’s a very common situation, three common issues arise when your camera tries to go beyond +/- 90 degrees in pitch

  1. The easiest fix is in your PlayerCameraManager… ensure that your pitch/yaw/roll limits are all maxed out
  2. Another possible issue is when your camera rotation goes beyond min/max pitch, the rotator numbers suddenly switch 180 in yaw and (I think) roll… so you are feeding a huge change into the interpolation which causes the hiccup
  3. The last (and can be tricky) is gimbal lock… this is awkward in the wrong situation… but can be resolved using quaternions (don’t worry, it’s another easy to use plugin) or another approach

Alright I’ll look into these in the morning and reply back if i get any results.

Okay I did fix the jet taking for ever to correct it’s rotation when it bumps into something by adjusting the values but still have no idea how to fix the pitch issue. Can you show me the quaternion solution thingy because I don’t want to lock the camera rotation.

sure! but please post a screenshot of your current version… and to make it easy to debug… would you use a sequence node to separate each PID… and then the resultant torque?

looks better! just add another sequence and put one AddTorque node… plug the 3 variables you’ve created into the relevant local to world translation

then let’s see how this works…

Here this is what I got so far:

Should I add the torque for all of them in one node or keep it in 3 separate nodes like I have here?

Yup just did that, still works the same, doesn’t seem like anything was broken but obviously the +/-90 degrees issue still remains.

ok… the first thing to do is to change the AddTorque you are using (you are using the
MMT AddTorque but not the MMT Tick). So I’d suggest the standard AddTorque (just one) and post your BP here again. See if the results are the same…

yes, but Proportional Coefficient is the PID speed… and I’d keep this between .001 and .4 for smoothness and stability… and modify the multiplier instead. I’d be cautious about changing the Derivative Coefficient

see how it goes after those changes… is the speed and stabilty good? I have a suggestion that will involve some radical changes, and some work by yourself… but it might make your interpolation smoother and yet quicker… and it might also solve any gimbal lock issues

ok… I won’t be able to help out fully, because I don’t need Yaw and Pitch for my project… so there are differences…

but basically you’ll need to download the Quaternions plugin and start using quaternions translated to vectors to get the Roll, Pitch, and Yaw error to feed into each PID. By using Quaternions instead of Rotators, you’ll avoid the risk of gimbal lock and the quick flips between Yaw/Roll as you go beyond +/-90 in Pitch. This could occur inside each PID, and in the TransformRotation and InverseTransformRotation (from world to local space). It will involve a fair amount of effort… and learning by trial and error.

I think it’s free on the Epic Marketplace… afaik it’s absolutely excellent