Hi guys, I'm using RotateAround to make an enemy orbit a player, however I'm having trouble with changing the orbit direction. This is my setup: Enemies spawn randomly up and down the y axis and head towards the orbit location. Depending where they spawned, they will be rotated in an "upwards" (Enemy 1) or a "downwards" direction. In this situation, Enemy 1 begins orbiting correctly (anti-clockwise), and rotates itself so it's always looking in a 'forward' direction, using the following code: Code (CSharp): transform.RotateAround(target.transform.position, new Vector3(0,0,1), (orbitSpeed * Time.deltaTime)); Quaternion rotation = Quaternion.LookRotation(target.transform.position - transform.position, transform.TransformDirection(Vector3.up)); transform.rotation = new Quaternion(0, 0,rotation.z, rotation.w); What I would like is to be able to alter the code for Enemy 2 to rotate in the opposite direction (clockwise) and also reverse the direction the sprite faces. Changing this the first line to use a negative z axis appears to change the orbit direction, but I can't get the sprite to change what direction its facing. Code (CSharp): transform.RotateAround(target.transform.position, new Vector3(0,0,-1), (orbitSpeed * Time.deltaTime) Any help would be appreciated thanks Note: this is 2D.
The reason it doesn't work, is because the rotation is set by RotateAround. The easiest way to accomplish this is to use a child object, that you control the local rotation of. I made an example for this that you can see in the attachment. Another option, if you don't want to do it like this, is to calculate the position and rotation yourself instead of using RotateAround, you can do this with a Polar coordinate system.
Thanks for your help on this steego! I was aware of this solution, but was trying to avoid doing it due to the complexity of AI I wanted to put in, but in the end I went with this