Bullet Damage Not Working
OscarsCoding
Member Posts: 92
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
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 ?
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...
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.
@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:
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
+1 for above but i would add a move behaviour and set it to speed 0 to stop it before the timer destroys it.
Yea, I made it so the the bullet does not get deleted and still nothing happened, I think my game is glitched or something.
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.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
+1
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
I hope this helps
@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.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
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.
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.