Having one object rotate towards another

Hey! The only post I found close to answering my question was from about 12 years ago, and is very outdated so I’m asking this myself :stuck_out_tongue:

Anyways, I’m making an enemy script, and I need the Enemy (Object script is on) to rotate towards the player (GameObjecct defined as player) Thanks!

Here’s an example of what I want…

transform.rotation = Rotation.rotateTo(player.transform, (Position to rotate from));

Btw: transform.LookAt(player.transform); Didn’t seem to work, I think it’s because it has a rigid body (Enemy & Player)

Try this:
transform.rotation = Quaternion.LookRotation(to.position - player.transform.position);
However, if a Rigidbody is stopping Transform.LookAt from working, this may not work either.

Maybe you can use the Rigidbody.MoveRotation() method.

I’m realllly not sure, I’m just 9 years old and started Unity a few months ago

I’m also not really good at using Quaternions so maybe Stevens R. Miller’s reply would be better.