Quantcast
Channel: Questions in topic: "footsteps"
Viewing all articles
Browse latest Browse all 164

Sprinting Problem

$
0
0
I have a problem. Im trying to create a sprinting script that changes the footstep sound when i press LShift. Also sprinting drains my stamina. Im having a problem when stamina is less than 50 it doesnt play walking sound but it stops all sounds. Help please! Here's my code: var walk:AudioClip; var run:AudioClip; var sta = 1000; function Update() { sta +=1; if ( ( Input.GetButtonDown( "Horizontal" ) || Input.GetButtonDown( "Vertical" ) ) && !audio.isPlaying ){ audio.clip = walk; audio.Play(); } else if ( !Input.GetButton( "Horizontal" ) && !Input.GetButton( "Vertical" ) && audio.isPlaying ) audio.Stop(); if (Input.GetKeyDown("left shift") && sta > 30) { Debug.Log("Sprint"); audio.clip = run; audio.Play(); } if (Input.GetKeyUp("left shift")) { audio.clip = walk; audio.Play(); } if (Input.GetKey("left shift") && sta > 30) { sta -=2; } if(sta < 30) { audio.clip = walk; audio.Play(); } if(sta > 1000){ sta = 1000; } }

Viewing all articles
Browse latest Browse all 164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>