cancel
Showing results for 
Search instead for 
Did you mean: 

OVRPlayerController Footstep Sounds

shan1392
Explorer
I'm having trouble integrating my footstep sounds from WWise to my Unity Project.
I'm supposed to add the "AkSoundEngine.PostEvent("Footsteps", gameObject)" code somewhere in my OVR Player Controller Script but I can't figure out exactly where or how to do it.

Any help?
4 REPLIES 4

DaveDriggers
Adventurer
Hi shan,

So do you have the basic Wwise Unity integration working already (i.e. are you able to play other Wwise sounds in your project)? 

I'm not exactly sure what you mean by "I'm supposed to add the "AkSoundEngine.PostEvent("Footsteps", gameObject)"code somewhere in my OVR Player Controller Script." 

It sounds like your project currently has no concept of footsteps, and you're trying to add that functionality .. is that correct? If so, there's no right or wrong way to do that, it's completely up to you to define your own gameplay functionality. You should be able to use the data and functions provided in OVRPlayerController to figure out when the player is moving, then you can start firing footstep sounds. The frequency you trigger them is your call, but you might want to adjust the interval between steps based on the player's velocity, for example.  




dave driggers | audio programmer | Oculus VR

shan1392
Explorer
Hi Dave,

Thanks for your reply.

Yes, I've got the WWise Unity Integration working and I'm able to play other Wwise sounds in my project.
Yes, I'm trying to add a footsteps functionality to my project.

If I use the FPSController from standard assets, I can edit the FirstPersonController.cs script and replace
PlayFootStepAudio();
with
AkSoundEngine.PostEvent ("Footsteps", gameObject);
and everything works just fine.

For the OVRPlayerController, I wrote this script
	CharacterController OVR;

void Start () {
OVR = GetComponent<CharacterController> ();
}

void FixedUpdate () {
if (OVR.isGrounded == true && OVR.velocity.magnitude > 2.0f) {
AkSoundEngine.PostEvent ("Footsteps", gameObject);
}
}
}
It is working but when I move my character, it's like my sound effect is being played a 100 times in one second.

So you're right, I just need to adjust the frequency at which the sound effects are triggered but I'm not sure how to do that.

shan1392
Explorer
Update: I updated my script to send out the trigger every 0.3s. It seems to be working fine now. 
Thanks a lot for pointing me in the right direction.

(If there's a better way of doing this, I'd still like to know).

Thanks.

public class FootSteps : MonoBehaviour {

float Timer = 0.0f;
CharacterController OVR;

// Use this for initialization
void Start () {
OVR = GetComponent<CharacterController> ();
}

// Update is called once per frame
void FixedUpdate () {
if (OVR.isGrounded == true && OVR.velocity.magnitude > 2.0f) {
if (Timer > 0.3f) {
AkSoundEngine.PostEvent ("Footsteps", gameObject);
Timer = 0.0f;
}

Timer += Time.deltaTime;
}
}
}



DaveDriggers
Adventurer
Cool, glad you got it working! 
dave driggers | audio programmer | Oculus VR