Collision Issue

ahmadoweda

  • Posts: 307
I want to make the score increases by one, when my player passes through a specific empty space. but when it passes this "empty space" it make continuous score increasing until the player passes all the empty space -it adds like 30 points to score and the empty space width is 50". I've tried to make this empty space collision width to 1 only, it still counts a a lot, even when I made the collision width to my player "1" it counts 2+ score. I cant make the player width 1 anyways but I was just trying to get it.

I'm using "actor-member of a group" event in the scene, as per the attached photo

any idea how to fix this?

Photon

  • Posts: 2697
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!

ahmadoweda

  • Posts: 307
I read it but there is something still missing, where to add if "Actor was hit"=true, set score to score+1 ?? inside always? inside when? both are not working

ahmadoweda

  • Posts: 307
This doesn't change anything, when actor1 hits actor2,  "actor hit?" set to true, so was "actor was hit?" will be true, then "actor hit?" is false, the actor one has not completely passed from actor 2 collision area, so this will be continuous until it pass.. same idea

kynbo

  • Posts: 139
Add a delay after collision should fix the problem


kynbo

  • Posts: 139
- Make a boolean attribute called "Can gain points?" and set it to true as default
- Make a number attribute called "Collision delay" and set it to 50 as default. You can change this number if you want. 50 means points can be earned every 0.5 second.
- Make a number attribute called "Delay counter" and set it to 0 as default
- Now add an "If [Can gain points?]" block under your collision event and put your "Set score to..." under this if block
- Set the boolean attribute "Can gain points?" to false after you have set your score
- In the always event, increase "Delay counter" by one if ["Delay counter" < "Collision delay"]
- Otherwise set "Can gain points?" to true

Photon

  • Posts: 2697
This doesn't change anything, when actor1 hits actor2,  "actor hit?" set to true, so was "actor was hit?" will be true, then "actor hit?" is false, the actor one has not completely passed from actor 2 collision area, so this will be continuous until it pass.. same idea
"Actor was Hit?" will be set to true eventually, but not on the initial collision. Basically, on the first collision, "Actor Hit?" gets set to true but "Actor was Hit?" will still be false until the "when updated" runs. Inside that conditional is where you will want your "score +1." Then as long as the actor remains in that space, it'll cancel subsequent "score +1" actions until he moves out and back in.
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!

Basseman

  • Posts: 208
Can you not make a region in that empty space and use when enters region add to score ?

ahmadoweda

  • Posts: 307
Basseman I liked your idea but the empty space is an actor which is created every X seconds, so I tried to replace that actor with region creation every X seconds also, and when my player enters "the last created region"  add to score, but I got continuous error in log viewer as below:

[LOG] [Flash] com.stencyl.Engine#isInRegion(3699): Region does not exist.

is there anything to use rather than "last created region" ? how can I specify that region

kynbo

  • Posts: 139
The simplest way is to just add a small delay after your score increases to prevent it from adding up when colliding with your "empty space". Creating regions is just overkill