Speed of behaviors

tutysestutyses Member Posts: 134
edited April 2013 in Working with GS (Mac)
Hello everyone!
I m having a problem with the speed of execution of behaviors ( At least i think so :P)
Basically i have enemies coming from the left side of the screen, when 2 enemies are close to each other and i shoot them, the bullet hit the first enemy AND ALSO the other one (Both of them get their HP reduced because of this)
The bullet has the behavior to destroy itself when it contacts an enemy.
I have seen that the problem is the delay time that the bullet has. It contacts the enemy and after 0.1 it destroys. I dont know why it take so much time
The only behaviors in the bullet it's the destroy when overlaps with the enemy and the behavior that make the bullet move


image

In the image you can see the bullet inside the enemy, it shouldnt be inside them, never. I hope someone have solved this because it s pretty common to have an enemy and a bullet :P

Thanks for helping me

Comments

  • WingmanappsWingmanapps Member Posts: 458
    edited April 2013
    havent really had trouble with that before. try to add a rule on the bullet
    "If overlaps or collide with enemy" - change attribute.self.color.alpha to 0 - It might visually help you out :)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Agree that that shouldn't be happening. Care to share a screenshot of your rules or maybe a link to download your project? It sounds like you have some other rules you haven't mentioned that are affecting the bullet.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tutysestutyses Member Posts: 134
    Thank you for your help, it s not a visual problem, the problem is the bullet hiting more than one enemy
    Here i uploaded a Example project
    image

    Play around about 5 minutes and you will see that sometimes you hit more than one enemy!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You have enemies stacked on top of each other. The bullet is going to collide with multiple enemies because it physically overlaps those enemies simultaneously. Not really sure how you can avoid that...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Try this. I added a boolean to (hopefully) prevent multiple hits. Watch the Log Debugger and you can see when there are multiple hits.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tutysestutyses Member Posts: 134
    It works way better. Enough for me at least :P
    I understand why it works but it s kind of weird
    Gamesalad doesnt detect the collision with the precision i need, but this workaround works well.
    I dont normally post a problem on the forum but when i do, you always help me
    I would invite you a cup of coffe if i werent 14000 kilometers away
  • tutysestutyses Member Posts: 134
    man i feel so stupid now, at least thinking that is a gamesalad thing make me feel better
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @tutyses It's not that it doesn't detect the collision. It's that you're expecting it to only detect the collision on the top layer or the first enemy to that position, or something along those lines. If you place two non-moving actors (enemies) in the same location and then shoot a collidable actor (bullet) at them, they will both register the collision.

    And I accept the offer for coffee. Let me just book my flight. :)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tutysestutyses Member Posts: 134
    What i meant with Precision is this:
    Position X and Y are Real variables so, actor positions ARE not the same, at least in this case.
    One of the positions would be something like x =103,4 and the other one 103,8 of course to the eye they would look in the same place
    If colissions were detected by checking if the actor is between X1 and X2 and between Y1 and Y2, the detection would be almost perfect

    Ok remember i live in fireland i will wait you with your coffe and some muffins :P
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Okay, I understand what you're saying. You're talking about a difference of 0.4 pixels. I tested collisions with a bullet moving at speed 100 (slow) and the game.Time of the collisions for two actors placed at x=103.4 and x=103.8 are exactly the same. If I reduce the speed to 20 (very slow), the actors detect collisions separately.

    At x=103 & 104, the time is different by 0.017 seconds at speed 100. At speed 150, the one pixel difference is not enough and both actors detect the collision.

    Here's the file I was playing with.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tutysestutyses Member Posts: 134
    Exactly, imagine the detection with a bullet with 1500 speed ( My bullet for example :P)
    It s interesting how much the colission detection can be affected
    thanks for the tests :) you earned an extra piece of cake :P
Sign In or Register to comment.