Quantcast
Channel: Latest Questions by Wrymnn
Viewing all articles
Browse latest Browse all 131

Rotate rigidbody2D towards target

$
0
0
I have A lot of gameobjects on scene I need to rotate. They are AI spaceships. However this: Vector3 targetVector = targetPosition - myTransform.position; float angle = Mathf.Atan2(targetVector.y, targetVector.x) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); myTransform.rotation = Quaternion.Lerp(myTransform.rotation, q, 5.0f); Is soo performance HEAVY that there is no way I can use it. Is there some better way to rotate sprite towards target? (Mathf.Atan2 and Mathf.Rad2Deg are taking like 30fps with 1000+ objects)

Viewing all articles
Browse latest Browse all 131

Trending Articles



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