playMaker

Author Topic: Get Speed and Float Compare Help  (Read 842 times)

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Get Speed and Float Compare Help
« on: September 24, 2020, 12:34:53 PM »
Hi,

I'm using Get Speed and Float Compare to play a sound when my character moves and having issues getting it to work. I followed the tut on YT on BadSeedGames but it doesnt include using Get speed. Here's what I have attached,

So if the player movement is over 0 in Speed it plays a sound, if equal to or less than, no sound. My player has a Rigidbody and Audio Source. The sound will play if i test it with a Get key down...

Any help would be so much appreciated!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Get Speed and Float Compare Help
« Reply #1 on: September 24, 2020, 04:02:31 PM »
Hi.
With your set up, at start it will check the speed and go to play sound  or no sound.
But after that its not checking anymore.

What you can do is make the 'no sound' as your start state and ad the 2 actions 'get speed' and 'float compare' in the 'no sound'

But only do a transition if greater than and target the play sound state.

Then on the play sound also add 'get speed' and 'float compare' but only compare if equal to 0 and transition to no sound state

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: Get Speed and Float Compare Help
« Reply #2 on: September 24, 2020, 06:22:51 PM »
Hey thanks so much for the reply.

I set it up as you suggested but Im still doing something wrong here.

When it goes to the PlaySound state as you can see in the screenshot it doesnt play a sound. (It will though if i just use a key down state)

Also it's not switching back and forth if the player is moving/not moving. It just goes right to playSound.

Questions:

What should I set the Float 1 and Float 2 value as? Currently they're 0 and 1. Is this so that if the speed is over 0?

What float should I use for the Store Result on the Get Speed? I have it as another Float called playerSpeed...

Thanks so much.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Get Speed and Float Compare Help
« Reply #3 on: September 25, 2020, 05:42:34 AM »
Hi.
On both states, on the float compare action.
On Float 1 : set The playerSpeed Variable.
On Float 2 : set a float value 0 (no need for a variable)

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: Get Speed and Float Compare Help
« Reply #4 on: September 25, 2020, 07:37:58 AM »
Hey that worked! Thank you.  ;D

The sound doesnt seem to want to loop though...I have it set to loop on the audio source and even tried a PM Set Loop action....weird....

Also, is there an action that you know of that would identify a tag so I can play certain sounds on different grounds? Like pavement, grass etc.

Thanks so much for your help.