Question by
goutham12 · Oct 16, 2017 at 12:33 PM ·
rotationtransformrigidbody2dtranslate
rotate object2d the direction it is moving?
am doing 2d game in that i had some enemy characters which will roam arround the screen. their roaming is fine. i want to face the enemy the direction which is going. here is my code. how can i do this.
void Start(){
SetDirection ();
}
void Update(){
transform.Translate(dir*speed*Time.deltaTime);
}
void SetDirection (){
dir = Random.onUnitSphere * 10;
dir.y = Mathf.Abs (dir.y);
dir = dir.normalized;
}
Comment
Your answer
Follow this Question
Related Questions
How to translate an object in an unknown angle ? 1 Answer
Car Controls without physics. 1 Answer
Rotating GameObject Does Not Rotate Child 0 Answers
Can't move instantiated object. 1 Answer