How would I monitor and display the characters' oxygen while underwater? #232
Replies: 3 comments 38 replies
-
I believe that the variable specifying the time before the player drowns is |
Beta Was this translation helpful? Give feedback.
-
Create a node within the player object. Position that node so that it is always near the player's head. Leave it visible for now. Create a sprite and an animation. You should probably already know how to make a sprite have different frames at this point. Add a script that sets the frame of this animation every frame. Set it based to numFrames * (1 - (player[x].airTimer / player[x].defaultAirTime)) -- that formula should make it so that if it's full (30 / 30), it sets it to frame 0 and if it's empty (0 / 30), it sets it to frame 30. You might need to adjust that psuedocode above to use the parented player object or something. Minor details. When the player exits the water, set a timer that will either fade the timer ui to transparent or else just make it disappear immediately depending on your taste. When the player enters the water, make the ui element visible, clear any timer based removals you might have. Since you have added some complexity to the animation in the last ten seconds of the timer, you'll want to change it to an animation player probably and manually keyframe it to change the frames yourself and just use the following formula to set the time scale of the animation player instead: 1 - (player[x].airTimer / player[x].defaultAirTime) Which gives you a value of 0 when the player's air time is full and 1 when the player's air time is empty. FWIW, it might actually make more sense to make your animation programmatically rather than with a bunch of sprites, but that's another topic. |
Beta Was this translation helpful? Give feedback.
-
An Update to this:I have decided to message the countdown into more of a hard-coded thing. Can anyone help with the process and help make it reset upon collecting a bubble and pause when, well, pausing the game? |
Beta Was this translation helpful? Give feedback.
-
I want to add a mechanic into the game where the player can see how much air the character has. How can I add such a feature?
Each sprite on the sheet is 16x16


And here is a preview of how I am aiming for it to look
Beta Was this translation helpful? Give feedback.
All reactions