Rotation breaks when I add LookAt

Hello All,

I have an object that I want to look at another object using the Y axis and at the same time I want the object to rotate around the Z axis. Using the code below both the LookAt and the Rotate command work individually as expected but when I run them together the LookAt works but the object doesn’t rotate, it just wobbles a little.

What am I doing wrong?

private void Update()
    var rotate = Vector3.forward * 100f * Time.deltaTime;

    Vector3 targetPostition = new Vector3(target.position.x,

LookAt is setting the Rotation so you are asking it to rotate to somewhere then immediately rotate to somewhere else. Then on the following frames to repeat that same thing.

You can parse into your look at and rotate Methods just the specific parts of the rotation you care about by instantiating a new Vector3 and passing it the relevant values.

Alternatively if you want to look at something once you can wrap it in in if statement or call the method on an event like a keypress for example.

I got it figured out. I had to nest the object in a empty game object, apply lookat to the parent and rotation to the child and it worked.