Restrict flip rotation when using Lookat
Hi there, I'm creating a pull-able lever. I'm using lookat on the lever so that it follows my "hand" object when the pull is registered.
I found this code on another question:
Vector3 targetPostition = new Vector3(target.position.x, target.position.y, this.transform.position.z); this.transform.LookAt(targetPostition);
It's actually working quite nicely to create the "pulling lever" effect. However, when I cross the yz plane, my lever object "flips." I think this is a result of it wanting to continue to "look at" the hand object. This is undesirable. Any ideas how to restrict this flip from happening?
It usually has to do with the "up" direction in the LookAt (the Docs and other Qs explain this.)
Your answer
![](https://koobas.hobune.stream/wayback/20220612071136im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to align fps Player to surface normal and use look At on a target 0 Answers
Unity lookat at finger position 3D C# 0 Answers
Rotation issues - Please help 0 Answers
gun targeting problem 0 Answers