There is an opponent gameobject.
It’s Rotation in Scene is -0, 270, 0
It can move towards the Character.
C -----------<---- move towards left hand side ------ O
If C is in left hand side of O, O will move to left hand side
I read
and
I added a code
function Update ()
{
transform.rotation.x = -0;
transform.rotation.y = 270;
transform.rotation.z = 0;
transform.Translate(movement.direction * movement.walkSpeed * Time.deltaTime);
}
Then, O rotates to face camera and moves backward.
What do I want to do is when C is on the right hand side of O, O can rotate to face C and move to the right hand side.
O ----> rotate and move to right hand side -------> C
transform.rotation.x = 0;
transform.rotation.y = 90;
transform.rotation.z = 0;
transform.Translate(movement.direction * -movement.walkSpeed * Time.deltaTime);
transform.LookAt(targetTransform); cannot be used because:
if C jump over O, O will falls down.
Or, how to limit transform.LookAt x,y,z?
did not mention it