Can A Continuous Collision Trigger An Event Only Once?[SOLVED]

Alan1

  • Posts: 88
Is it possible? I can only get either a continuous triggering of the event or none at all.

The main function will be to set X/Y speeds to 0 momentarily on initial collision but to allow movement afterwards even if the collision is still occurring. For example, the player hits the ground with both X & Y movement, freezes for a second on impact then continues to move, or preferably moves only on subsequent control input.

« Last Edit: January 28, 2014, 05:39:45 pm by Alan1 »
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

Alexin

  • *
  • Posts: 3130
Use a Boolean attribute to decide whether an event should be ignored or not. Acknowledge the event whenever the attribute is false and then set it to TRUE. Later, with the help of a timed event or some other mechanism, reset it to accept a new event.
"Find the fun"
alexin@stencyl.com

Alan1

  • Posts: 88
Thank you Alexin. Attached is how I interpreted your solution(it's probably wrong). I'm getting results similar to before. It appears to conflict with behaviours that have a 'set X/Y speed' by continuously alternating between True & False. The collision event keeps looping as long as the collision exists. Is there any way around this? Thanks again.
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

gamegirlxl

  • Posts: 713
I think the images are messed up...

Alan1

  • Posts: 88
Messed up how? Are you referring to the blank blocks? That's how Stencyl took the screenshots. I've also noticed that the images only appear when I'm signed in. If it's something else, I'm not seeing it. Either way, thanks for bringing it up :)
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

Alexin

  • *
  • Posts: 3130
You are getting similar results because you set keepMovin to false every time the event is triggered, defeating the purpose of the attribute.
"Find the fun"
alexin@stencyl.com

Alan1

  • Posts: 88
Thank you Alexin. I guess I'm having trouble making sense of this part:

Use a Boolean attribute to decide whether an event should be ignored or not.

How else would I go about doing this?
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

Alexin

  • *
  • Posts: 3130
Pseudocode:
Code: [Select]
when created
set ignore to false


when this actor hits something else
if not ignore
set ignore to true
set actor's speed
do after 1 second
set ignore to false
"Find the fun"
alexin@stencyl.com

Alan1

  • Posts: 88
Thank you once again, Alexin. Sorry to be such a pain with this but it still appears to be subject to the continuous collision as suggested by the print block results. It would appear the collision event block will not allow what I'm trying to do. Unless maybe I've missed something.
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

Alexin

  • *
  • Posts: 3130
The usage of the print block  seems fishy. Try the following to make sure the blocks inside the IF are executed when expected:
Code: [Select]
when created
set ignore to false


when this actor hits something else
if not ignore
print this should be printed only once for the next 10 seconds
set ignore to true
set actor's speed
do after 10 second
set ignore to false
"Find the fun"
alexin@stencyl.com

Photon

  • Posts: 2693
Using a "Do After" will give you sketchy results at best. What happens if the actor separates and collides a half-second later? Won't it still be ignored? Also, what happens if a collision lasts for a few seconds? Ignore then gets set back to false and the event can happen again.

You should use some sort of mechanism to verify a collision is still happening instead of guessing a random amount of time. Try looking at this:

http://photongamedev.wordpress.com/2013/08/06/faq-how-do-i-detect-when-a-collision-has-ended/

Once you have that, then modify the event like so:

Code: [Select]
when this actor hits something else:
     set "Actor Hit?" to true
     if not "Actor Was Hit?":
          trigger event

As you may have noticed from the link, don't mix the two Booleans up in the above code.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Alan1

  • Posts: 88
Very cool. It's like a spring-loaded switch. Thank you Photon. It seems to work. If I understand correctly, it runs the trigger event for the one frame it is FALSE before the collision wrapper sets it to TRUE. Is there any way to control the length of time the trigger event is active or preferably with a subsequent control input?

Thanks again to both Alexin and Photon(and gamegirlxl).
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

Photon

  • Posts: 2693
Very cool. It's like a spring-loaded switch. Thank you Photon. It seems to work. If I understand correctly, it runs the trigger event for the one frame it is FALSE before the collision wrapper sets it to TRUE. Is there any way to control the length of time the trigger event is active or preferably with a subsequent control input?
Could you explain a bit more specifically how you want to control the duration of the event?

And yes, basically it checks for false because its asking "was I already colliding with this?".
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Alan1

  • Posts: 88
Thanks Photon. I'm working on a player that will have a number of interrelated behaviours: Walk, Jump(Fall), and a Jetpack. I have the Jetpack set up so that it is only active after a Jump and the Jump set up so that it is only active after the jump/up thruster control is released. Works OK this far. The one problem however is that if the L/R thruster controls are down as the player touches down, it will immediately shoot L/R along the ground as a Walk, and if I deactivate the Walk, then as a Jetpack movement. The Jetpack animation doesn't play, but I believe the movement isn't disabled until I release the L/R control. I basically have very slippery landings. Same thing happens when the actor is hit from above, it'll shoot along the top of the tiles if I touch. Unfortunately, if I can get this to work, I'm pretty sure I'll have to give up continuous, fluid jumps and a continuing walk from an X-moving fall, but I'd like to make precision landings part of the game play. Hope that made sense.

I guess I never actually answered your question: I'd like the player to freeze upon collision until a subsequent control input. Or at the least, freeze for 1-2 seconds before moving again.

« Last Edit: January 28, 2014, 09:07:56 pm by Alan1 »
"Oh man, this isn't happening, it only thinks it's happening." ~Flynn

gamegirlxl

  • Posts: 713
Thanks again to both Alexin and Photon(and gamegirlxl).

Seriously, the images are still messed up...  I'm not sure why, but I can't be the only one seeing that right?  Is it because that bit was deactivated or something???