Author Topic: Oxygen Level  (Read 3948 times)

saiwong3268

  • Level 6: Milder
  • *
  • Posts: 119
    • View Profile
Re: Oxygen Level
« Reply #15 on: December 08, 2019, 11:02:37 PM »
I have been testing my Sandbox levels and noticed that the swimming alarm code works for 99%
of the situations. However, there was an issue when your characters head is above water whilst
the characters feet are underwater.

I investigated the issue, and concluded that if your character is not swimming,
the value of breath/air is "undefined" (believe it is something like  -1)

The issue is when your character is swimming, but has head above water, value of
swimming is true, but breath is "undefined" so alarm sounds

In order to fix this, use the following:

if swimming = true  & breath > 0
{
if breath < 3000
{
sfx = 5
loop = staggered
}
}


You can interpret the first 'if statement' as:   if character is swimming and breath value is defined

TingThing

  • Admin and Developer
  • Level 20: Nobom
  • *
  • Posts: 1395
  • Creator and Developer of Platform Builder
    • View Profile
    • Platform Builder Home
Re: Oxygen Level
« Reply #16 on: December 30, 2019, 04:42:46 AM »
don't forget that you could use a variable with a delay command or a looping timeline to loop stuff at your own pace.

CGM

  • Christian, 3D artist, former Platform Builder gamdev
  • Master Builder
  • *
  • Posts: 3836
    • View Profile
Re: Oxygen Level
« Reply #17 on: December 30, 2019, 06:47:09 PM »
Could you explain that, TingThing?

TingThing

  • Admin and Developer
  • Level 20: Nobom
  • *
  • Posts: 1395
  • Creator and Developer of Platform Builder
    • View Profile
    • Platform Builder Home
Re: Oxygen Level
« Reply #18 on: December 30, 2019, 10:53:33 PM »

You guys have talked about doing staggered looping so that the sound effect doesn't play as frequently. But it will still loop quite quickly.

if swimming = true  & breath > 0
{
if breath < 3000
{
sfx = 5
loop = staggered
}
}


Thing is, you could just put that into a timeline that loops itself every second. That way the sound effect will only happen every second when the breath amount is low.