Quaternion.RotateTowards= Spin Transform.Rotate = look at

Maryetta Buckner
2 min readDec 17, 2020

Alright! back on track today. Started out a little rusty as I haven’t gotten to much coding done in the last week or so. I started creating yet another enemy which follows and rams the player when close. At first this did not go as planned. I was able to get the enemy to follow the player using the “Vector3.Movetowards”. Visually this was not going to work as the enemy follows the player still facing in a downward position. I had to figure out how to rotate the enemy to point towards the player. I played a little bit with the scripting trying to manually change the rotation and could only came up with setting a rotation. Headed back to my friend Google to find the right implementation. read a little scripting API and went ahead and added the function in using “Quaternion.Slerp”. Oh boy did this not turn out as expected. Now my enemy was spinning like a coin towards the player but it was pointed in the right direction. LOL. I played with the rotation variables but was still getting the same result. Ugh., brain strain.

Decided to take a break from it and move on to adding a laser beam to my other enemy. unfortunately, ran into another problem. this enemy started traveling right but still faced down. Oh my, what have I done? After our PM team check in I didn’t want to keep stacking new problems with out fixing the previous so I went back to my enemy follow. Aha. May have found the issue. By using Quaternion Slerp and rotatetowards it did not mean to look at the player. Back to the search I had found that it was actually simpler than what I had. Adding back in my move towards function and then adding an “transform.rotate” which included using “Mathf. atan” and “Quaternion.Euler” giving it the angle turn. Success!!!

***Update I passed my recertification test! WOHOO!!!!