Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code with cross gets called multiple times, not once per collision. #59

Open
StarrKiss opened this issue Nov 10, 2021 · 2 comments
Open

Comments

@StarrKiss
Copy link

So I have bullets assigned to the filter 'cross', because they penetrate through multiple enemies. However, I've noticed that the damage for the bullets is called EVERY FRAME they are colliding with the enemy, not once per collision - if the bullet deals 3 damage and collides with an enemy for 2 frames before passing to the next one, the enemy will recieve 6 damage. A similar thing happens with the enemy attacks that have big hitboxes to the player - a attack may deal 2 damage, but if the player is in the hitbox for 5 frames it deals 10 damage. How do I fix this?

@deli73
Copy link

deli73 commented Feb 20, 2022

Games generally have this ting called "i-frames"; essentially when the player gets damaged you give them a brief period of invulnerability in which they cannot be damaged further. Alternatively, you could delete the bullet when it collides with the player, depends on what you're doing with your game... you could perhaps also have a variable that stores whether a collision has happened last frame and ignore it if it has?

@deli73
Copy link

deli73 commented Feb 20, 2022

(alternatively, for some reason checking if collisions[i].ti is non-negative seems to only be true once per collision, so that could work? not sure why that happens though, we're new at this, but hope that helps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants