Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started by: Myxini on April 16, 2008, 09:47:27 AM
-
I am new to Wintermute (just doing tests at the moment really) but have a question to which the answer is likely to be very simple.
I have a knight and a hero, both 3DActors. As it stands I can get the knight to, when triggered, turn and approach the hero. However, when the knight reaches a certain distance from his target I need him to stop and perform another action.
So my question, simply put, is "How can I calculate the distance between two actors?"
Preferably the distance should be just one value, but if the only way is to return all three axis then fair enough!
Thanks for your time everybody!
-
You can calculate this by calculating the vector length. From the top of my head (someone correct me if I messed up :))
var Distance = Math.
Sqrt((X2 - X1
) *
(X2 - X1
) +
(Y2 - Y1
) *
(Y2 - Y1
));
-
Thanks so much! This was just what I needed!