Question by
Refulgent · Mar 01, 2018 at 11:21 AM ·
rotationprogrammingrotatearoundlookrotationrotatetowards
Why does RotateTowards rotate in an "orbit" rather than on the spot? Help me understand!
Hi,
First off, this is just a lack of me understanding this method, I think, I've tried googling but I'm not coming up with anything, sorry.
I have a simple bit of code,
Vector3 enemyVectorRotate = Vector3.RotateTowards(transform.position, transform.position-target.position, 5f, 5f);
Quaternion finalRotation = Quaternion.LookRotation(EnemyVectorRotate);
transform.rotation = Quaternion.RotateTowards(transform.rotation, FinalRotation, 5f);
This does what I expect it to, except for one bit, it does A(in the image below), rotates like an orbit around its local 0,0,0 rather than what I expect it to do (B) rotate on the spot and look at FinalRotation in the code above. In figure A it is actually doing what I want, except it's also doing this orbit around its local x,y,z which is confusing me endlessly.
Cheers for any help anyone can offer, again I just don't think I understand this method.
rotation.jpg
(21.7 kB)
Comment