[SOLVED] Little help with lookAt

Heyyo guys, im trying to make simple entity rotation towards other entity like lookAt function, but for some reason it is not faced towards the destination entity but in opposite direction, rotation comes along with d. entity position but its is somehow rotated in wrong direction.

Here is a code, i added a little smooth rotation effect but even simple lookAt line is having a wrong results, the same as with smooth rotation.


Here you can see what opposite direction was ment, they should watch me instead of blank space. Thanks for any help.

I also tried to make a little makeup in editor and set y rotation to 180, either tried to add 180 in code but neither of them works, as not only Y rotation is changing but also other x,z

could be related to this

LookAt takes a position (point in space) as parameter to rotate the entity towards and look at but here you use a rotation Quaternion Y component for the Y position.

Is this a typo?

You also completely cancel out the lookAt function by setting the rotation here

It’s seems you try to get a smooth rotation to the position of the target with the same method that I used in the post below. I suppose that your model is already a child entity that is rotated 180 degrees? Otherwise you get the problem that @mvaligursky mentioned. Also the typo that @yaustar mentoined should be the position of the entity itself.

1 Like

Yes its typo i forgot to make it back as i tried different methods , however before rotation there was a entity position, i was trying more ways and was kindy confused what is happening there.

It has only parents, script is attached directly on “girlModel” model, and there is never parent with rotation set to 180 or so, everything is set to zero.

Also smooth rotation works fine, its just that they are not watching the right direction. Ill check links u mentioned.

This helped, thank you.

1 Like