Having trouble triggering an actor

Chameleon

  • Posts: 2
Currently I'm trying to make an item dispenser for my RPG Platform game. The intended function is for the player to move in front of it, press the down key, and an item will spawn out of it.

To accomplish this I'm trying to make it so that when the player actor collides with the dispenser actor and presses the down key, it will make a pickup actor spawn in the players location. I can trigger it just fine with the key press alone, but I'm having lots of trouble trying to make it so its only triggerable while colliding with it.

I've tried so many methods but none of them have worked, here's the current version which works flawlessly when you press the down key any where in the scene:
http://i.imgur.com/m4obi.png

Can anyone recommend a way to have it triggerable only when being collided with?

dubealex

  • Posts: 26
It works anywhere in the scene because your dispenser is colliding with tiles (probably.) or another actor. Then, because it is colliding, it run the blocks inside the "When colliding".

You need to run the routine in your "when this collides" ONLY if the group of the colliding actor is equal to what you need, in your case the player. You could do on IF block to check the group of the actor. Then another IF within that one, and check the key press in there. AN AND statement in 1 IF block should also works.

You already have an IF above, but the problem in it is that you check THIS actor colliding shape, and not the COLLIDING's ACTOR group.

Chameleon

  • Posts: 2
I actually found the issue behind it in the end. Under 'When this collides with something else' I added a 'For each actor of type [Actor]' followed by and 'If [Control] was pressed', now I tried this before many times with lots of variations but no success. It turns out the clincher was that the actor the behavior was attached to needed its collision set to 'Tiles' and to be checked as a sensor, it also needed to set under a 'Tiles' group for its properties.

So many hours spent on such a small correction, but oh well at least it works perfectly.

EDIT: Typos