Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Distance between 3D Actors  (Read 3866 times)

0 Members and 1 Guest are viewing this topic.

Myxini

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 7
    • View Profile
Distance between 3D Actors
« 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!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Distance between 3D Actors
« Reply #1 on: April 17, 2008, 02:43:22 PM »

You can calculate this by calculating the vector length. From the top of my head (someone correct me if I messed up :))

Code: WME Script
  1. var Distance = Math.Sqrt((X2 - X1) * (X2 - X1) + (Y2 - Y1) * (Y2 - Y1));
  2.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Myxini

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 7
    • View Profile
Re: Distance between 3D Actors
« Reply #2 on: April 17, 2008, 02:53:14 PM »

Thanks so much! This was just what I needed!
Logged
 

Page created in 0.019 seconds with 24 queries.