Question by
SGT_Smith · Feb 05, 2016 at 09:42 PM ·
c#distance check
Using code to keep distance from target, how do I keep it at its current distance when I start the code?
Here is my keep distance code:
transform.position = (transform.position - target.transform.position).normalized * distance + target.transform.position;
I increase and decrease distance with some simple code to add or decrease from distance. The issue is when i start the code it jumps to whatever distance is instantiated as. How can I determine what the current distance is so it doesn't snap?
Comment
Your answer
Follow this Question
Related Questions
About AI detecting a sound 1 Answer
Incorrect comparison? If statement not returning proper results. 1 Answer
Making a GameObject rotate faster as the player gets closer to it 1 Answer
SqrMagnitude intermittently doesn't work for if statement on prefab. (C sharp) 1 Answer
Fast Distance Checking for many objects? (RTS Game) 0 Answers