It begins with finding a target..
smurfted
Member, PRO Posts: 586
How can i make an actor look at a series of actors and have it decide to go to the closest one?
Comments
If you have the other actors X and Y positions (stored in a game attribute or table) you could loop through them and see which distance is the smallest (remembering the distance formula is sqrt[(self.x-actor.x)^2+(self.y-actor.y)^2].
There may also be something better with path finding, but I have never used it
Epic, i will see if i can get that up and running..
The magnitude function is a little simpler than the distance formula.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The Magnitude Function works well, here is a tutorial if you want to check it out:
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Here another approach using a 'detector' - file attached.
Drag the little purple dots around, then click on the central player to detect and move to the nearest dot.
It would probably needs lots of refinement, but should give you the basic idea.
Yet again some epic stuff in here lads, i'll have to try a few versions for sure as i want lots of little characters looking for each other.
So i'll have to try and work out which is the fastest way to get this looping..