Collide with center of 2 actors

monkeedmonkeed Member Posts: 22
edited March 2012 in Working with GS (Mac)
How do I detect a collision with the center of 2 actors instead of the outer edges?

Best Answer

  • heathccheathcc Posts: 113
    Accepted Answer
    When I have this scenario, I create a smaller actor that I constrain to the X,Y of the larger actor and make it transparent. Then assign collision rules to the smaller actor.

Answers

  • CloudsClouds Member Posts: 1,599
    If actor A's X position = actor B's X position

    . . . .and . . .

    actor A's Y position = actor B's Y position . .

    . . . then their centres have 'collided'.




    It's very unlikely to happen though.
  • heathccheathcc Member Posts: 113
    You could extend on Tynan's answer and make ranges since as states, that one pixel hit is pretty unlikely.

    I wonder which has more overhead? Using two actors with a Collision behavior or rules (4?) to check for the intersect of two ranges.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Use magnitude.
  • monkeedmonkeed Member Posts: 22
    Wow, interesting options on this.

    John, how would I use magnitude for this?
  • calvin9403calvin9403 Member Posts: 3,186
    edited March 2012
    magnitude(actora'sx-actorb'sx,actora'sx-actorb'sy)

    use that for collide(ex if smaller then 10 then...)
  • monkeedmonkeed Member Posts: 22
    Thanks for your help. I ended up going with heathcc's idea. I created the smaller transparent actor.
Sign In or Register to comment.