Finding the distance between two actors?
MarpCark
Member Posts: 121
Hey guys. So in my new game, i have 4 game attributes and two actors, (Actor1 and Actor 2). I want the first attribute to trigger when actor a is 400pixels away from Actor 2, the 2nd attribute to trigger when 200 px away, 3rd when 100 px, and 4th when 50px. How do i determine the distance between two actors, and implement it into the rules? Cheers!
Comments
Use the magnitude() function. It's explained in the Cookbook. If you Google magnitude gamesalad you'll also find more information about it.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang ok I've finally figured it out. Thanks for pointing me in the right direction, spent the last couple of hours learning all about magnitude and abs, and have definitely learned more trying to figure it out myself rather than being fed the answer. So i appreciate that, cheers!
You're welcome! Math functions are a vital part of GameSalad so it's best to have an understanding of them rather than just a complex expression to try to sort through. Of course, if you have trouble making the expression, just ask and someone here will help out.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User