Is Colliding?

EatMoreHippo

  • Posts: 62
Is there a way to check if two actors are colliding and do something as long as they are colliding?

In this example I'm trying to have a shop menu appear if you're standing next to/on top of a vending machine and then disappear if you leave.

Zephilinox

  • Posts: 106
Collision>Basic>group for this actor's colliding shape

use an if-block(flow>conditional>if) with this and a equality block(math>compare>anything=anything), along with a group block (actors>properties>group) then do what it is you want.

EatMoreHippo

  • Posts: 62
I tried this solution but it seems like the only result that "group for this actor's colliding shape" block returns is the actors own group. That is whatever actor had the behavior attached to it was feeding its own group into the block and I couldn't get it to respond to any other actors.

decletro

  • Posts: 235
The 'when this collides...' code happens before the 'always...' code so in the 'when this collides...' you want something like:

if group for this actor's colliding shape = player/vending machine/whatever
    set Collided? to true

('Collided?' is a hidden boolean variable you would make)

Then at any point in the 'always...' code you can do something like:

if Collided?
    [enter the code for the shop menu being open here]
    set Collided? to false

Make sure that the player and vending machine are different collision groups and that they actually can collide.