How to set child object world space rotation

Hi, I have a bit problem setting child object rotation. It looks like setting Rotation component value affects only local space rotation.

My entity looks like ‘Body → Child’ and I’m trying to rotate Child object towards target. It works fine as long as I don’t rotate my Body object. I tried to look documents and there are LocalToParent and LocalToWorld components, but couldn’t find a way to set child object rotation in world space using those…

Maybe someone could help me or point me in right direction or has some example code?

LTW is what you need, it represents object transformation in world space, here is couple of things that you can do.

  1. Setup rotation (in radians) directly in to LTW matrix.
  2. “mul” your rotation quaternion in world space with inverted LTW and setup in to Rotation component.
    etc.
1 Like

I ended up doing the second way. I multiple child rotation by parent object inverse rotation and seems to work perfectly!

If will be more than one parent you should do it through hierarchy…no good. With mul to inverted LTW you should do it once.

Somehow I couldn’t get it to work properly when I tried using inverted rotation from LTW. Do you know if there’s any example codes somewhere?

Oh sorry for confusing you, It was morning for me :smile: It’s rotation, you can’t easily mul it from world to local like translation, yeah solution with mul quaternions through hierarchy should work.