How can I trigger a function on the frame (only the frame) the player hits an obstacle? #107
-
To create a NoClip deaths mod, I've been using the How may I overcome this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
I don't know the signature of 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 If your goal is to count every time the player would've died, I can think of two ways to approach that. The first idea that comes to mind is to check which object the player is currently colliding with in However, if the goal is counting "deaths", you should realize that that's not exactly a well-defined thing if the player doesn't actually die. Does counting deaths mean every frame that the player would've died counts as a death? If so, that's the default behaviour of If you want a death count that's easy to digest for the user, I'd say the best way to do it is to count deaths by every frame the player would die, but skip consecutive frames. As in, when To implement that, all you need is some way to check if the player is no longer dying. One way to do this would be to find which function is called every frame to check for death (probably |
Beta Was this translation helpful? Give feedback.
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…