Bullet Damage Not Working

Hi! I have recently made an enemy that shoots bullets at my player and the bullet gets destroyed, my problem is that when my player collides with the bullet and the player is supposed to be damaged by the bullet, but the player is not getting damaged. And the bullet has the same rules and stuff as the enemy (which works fine) any ideas why?

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @OscarsCoding said:
    Hi! I have recently made an enemy that shoots bullets at my player and the bullet gets destroyed, my problem is that when my player collides with the bullet and the player is supposed to be damaged by the bullet, but the player is not getting damaged. And the bullet has the same rules and stuff as the enemy (which works fine) any ideas why?

    The way your game behaves is determined by the code you are using, the rules and behaviours, attributes, conditions, values (and so on) - the likelihood is that somewhere amongst all these computations you have accidentally introduced an error.

    Q: When the game didn't produce the results you were expecting what did you initially do to resolve the issue ?

  • OscarsCodingOscarsCoding Member Posts: 92

    I didn't resolve the issue but I tried different things such as restarting GS and my computer, I also read through the code and I didn't find anything wrong. But I'm still not sure why its not working...

  • CaptFinnCaptFinn Member Posts: 1,828

    put your enemy behaviors in a group. place group in your behaviors. drag those to the bullet. See if that works. If so just change the amount of hurt you want to do to your hero.

    that would me my first test. If it works then you had something wrong in the coding you had in the bullet. if that doesnt work. you will just have to look at each line of code in the bullet and the hero.

    its a pain. but sometimes that all you can do.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited May 2015

    @OscarsCoding, note that the actors gets checked (rules run) sequentially.

    So what is happening is that the bullet gets checked, and if it collides with the player it gets deleted.

    Next the player gets checked, and because the bullet has already been deleted the collide rule with the now non existent bullet does not trigger.

    Solution, either pay attention to the order of the actors, so the player gets checked first, before the bullet,

    or, as a more robust solution, only destroy the bullet a split second later, giving the game a chance to cycle through to the player actor before the bullet is destroyed, e.g. in the bullet:

    If bullet overlaps or collides with player
         Change attribute self.color.alpha = 0  (to hide it straight away)
         Timer AFTER 0.04 seconds
                 Destroy bullet
    
  • UtopianGamesUtopianGames Member Posts: 5,692
    edited May 2015

    +1 for above but i would add a move behaviour and set it to speed 0 to stop it before the timer destroys it.

  • OscarsCodingOscarsCoding Member Posts: 92

    @Hopscotch said:
    OscarsCoding, note that the actors gets checked (rules run) sequentially.

    So what is happening is that the bullet gets checked, and if it collides with the player it gets deleted.

    Next the player gets checked, and because the bullet has already been deleted the collide rule with the now non existent bullet does not trigger.

    Solution, either pay attention to the order of the actors, so the player gets checked first, before the bullet,

    or, as a more robust solution, only destroy the bullet a split second later, giving the game a chance to cycle through to the player actor before the bullet is destroyed, e.g. in the bullet:

    If bullet overlaps or collides with player
         Change attribute self.color.alpha = 0  (to hide it straight away)
         Timer AFTER 0.04 seconds
                 Destroy bullet
    

    Yea, I made it so the the bullet does not get deleted and still nothing happened, I think my game is glitched or something. :disappointed:

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @OscarsCoding said:
    Yea, I made it so the the bullet does not get deleted and still nothing happened, I think my game is glitched or something. :disappointed:

    I would apply Ockham's razor here and point to something else being glitched :)

    Do you move your bullet by interpolate?

    Enough guessing, please post a screenshot of your rules.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @Hopscotch said:
    Enough guessing . . .

    +1

  • OscarsCodingOscarsCoding Member Posts: 92

    Here are 2 pictures of all the rules I have for the bullet collison: http://imgur.com/McGxkNg&1x5ZHob#0

    Here are the rules for the bullet: http://imgur.com/l2peFTh

  • OscarsCodingOscarsCoding Member Posts: 92

    I hope this helps :)

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited May 2015

    @OscarsCoding , what is up with the constrain in the bullet actor?

    It does not show an attribute? Is it a display bug?

    Generally, constrains and interpolates should be avoided when using collide rules as they take precedence over the physics engine, making it likely that collide and overlap rules don't get registered.

  • OscarsCodingOscarsCoding Member Posts: 92

    The constrain rule is just so that it faces the way it goes, I found it in this video:

    Let me try and get rid of it.

  • OscarsCodingOscarsCoding Member Posts: 92

    Yeah, when I put the bullet in another scene, it does what it is supposed to do, which is to subtract the players life by 1 and the destroy itself, I still don't know why it wont work in another scene.

Sign In or Register to comment.