Quantcast
Channel: Latest Questions by Turkeybag
Viewing all articles
Browse latest Browse all 27

Rotate on X axies towards an objects height in 3D

$
0
0
Pretty much what I need to do is simulate an AI looking up and down in the same way that players do (with a separate object). Something like the AIs head looks up and down at the player but doesn't turn because his whole body turns instead. I'm having trouble with this and all my searches have come up with stuff that isn't quite what I need. I managed to make some code do exactly what I want (including not rotating past 90/-90) but only if the player is standing at a specific side of the AI. RotationVar = Quaternion.LookRotation(transform.position - Target.position, Vector3.right); RotationVar.y = 0; RotationVar.z = 0; RotationVar.eulerAngles = transform.TransformDirection(new Vector3 (-RotationVar.eulerAngles.x, 0, 0)); transform.rotation = Quaternion.Slerp(transform.rotation, RotationVar, VerticalTurnSpeed * Time.deltaTime); The transform.TransformDirection doesn't seem to have any effect on this as it still only works correctly in 1 direction (if the player is standing in a different direction it still faces that same direction as if it was doing it in global. Any help would be appreciated.

Viewing all articles
Browse latest Browse all 27

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>