- Home /
Question by
$$anonymous$$ · Apr 21, 2018 at 08:12 PM ·
2dmovementvector2
Turn 2D object toward Vector2 position?
Hello, I'm making an NPC and I need it to turn towards the position it is moving to and then go in that direction, but I'm having some trouble turning it towards it's destination. At the moment, it will reach it's destination by moving only in weird arc things.
public void Move(Vector2 MoveTo){
transform.right = new Vector2(transform.position.x, transform.position.y) - SeekPosition;
transform.Translate (transform.right * Speed);
}
Comment
Best Answer
Answer by $$anonymous$$ · Apr 21, 2018 at 10:55 PM
After a few adjustments, I seem have have gotten it to work smoothly.
public void Move(Vector2 MoveTo){
transform.right = new Vector2(transform.position.x, transform.position.y) - SeekPosition;
transform.position += -transform.right.normalized * Speed;
}