Can magnitude be used for...

determining the distance between two instances of the SAME actor? Or must they be different actors completely? If they must be different, I was thinking of this workaround:
I would have each instance of actor A (say there are 3 on screen) spawn under it actors B, C, or D (constrain to actor A's X & Y, and make them invisible) and use magnitude to determine the distance between them. Could that work? I'd try it myself, but I'm not at home at the moment.

any thoughts?

Comments

  • ChakkuChakku Member Posts: 1,513
    edited February 2013
    @Kangavark

    Yeah, that should work.

    Insightful thinking! :)

    Sincerely,
    King Chakku
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Assuming you are spawning them, I would add their positions to a table (see attached demo).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here's a similar idea but using just one actor.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ChakkuChakku Member Posts: 1,513
    determining the distance between two instances of the SAME actor? Or must they be different actors completely? If they must be different, I was thinking of this workaround:
    I would have each instance of actor A (say there are 3 on screen) spawn under it actors B, C, or D (constrain to actor A's X & Y, and make them invisible) and use magnitude to determine the distance between them. Could that work? I'd try it myself, but I'm not at home at the moment.

    any thoughts?
    @Kangavark

    This is what I would do, but if you are having difficulties with magnitude, then I have an alternative!

    (This is what I'm considering for the AI in one of my upcoming games; it may be irrelevant depending on what you're using the magnitude for, but is relevant many cases)

    Constrain a circular actor to the actor you intended on using magnitude on, and work with the collisions of the constrained-circle actors!

    Hope this helps.

    @tatiang
    I'm not on my computer right now, but will try out your demos as soon as possible and update this thread if one of your demos was a better/easier solution.





    Sincerely,
    King Chakku
Sign In or Register to comment.