Skip to content

How can I trigger a function on the frame (only the frame) the player hits an obstacle? #107

Answered by HJfod
TechStudent10 asked this question in Q&A
Discussion options

You must be logged in to vote

I don't know the signature of destroyPlayer and I don't know exactly how to do it, but the way I'd approach figuring it out is probably by first checking to see if there exists a function for that (probably doesn't as in normal gameplay there's no reason to store whether the player has collided or not as the player will die if any collision is detected).

If a function specifically for it doesn't exist, then I'd first figure out what exactly the functionality you need is.

If you only need to check if the player would've died anywhere in the level, I'd just store a global boolean flag for that, set it in destroyPlayer and then reset at level start.

If your goal is to count every time the pl…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@altalk23
Comment options

@TechStudent10
Comment options

@TechStudent10
Comment options

@HJfod
Comment options

@TechStudent10
Comment options

Answer selected by TechStudent10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants