Question by
aidangig56 · Dec 26, 2016 at 11:22 PM ·
c#gameobjecttransformvector3movetowards
Vector3.MoveTowards moving transform
My code
public float runSpeed = 1;
public Transform target;
float step = runSpeed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, target.position, step);
I want to use Vector3.MoveTowards to a constantly moving object. For example, a player. The player is always moving but when I assign the public transform target. It doesn't go anywhere else after I play in editor, and it only goes to the start position not where player is constanly moving...
Comment
We need to see the entire script, and any other script(s) which act on it.
Your answer
Follow this Question
Related Questions
Operator '==' is ambiguous on operands of type 'Vector2' and 'Vector3' 1 Answer
Can’t keep the position 0 Answers
Transform search function only sporadically works?! 1 Answer
How to find the transform position of another gameobject then move a gameobject to that position? 1 Answer
Set new default position each time? 1 Answer