Jump to content

Character Controller Landing Sounds


_Assassin_
 Share

Go to solution Solved by Genebris,

Recommended Posts

Hello again,

I finally got footsteps sounds to work properly on the correct material using triggers. But I have been unable to get a sound to be played at the correct time when the player jumps and lands on a material. How would I implement such a feature using a trigger?

EDIT: I manged to work this out in the end. I did this by making global variables of both the players jump status with the GetAirborne command and the players current speed using GetVelocity():Length command. I then made a jump trigger box combined with the necessary commands for collision detection. Upon player collision, my jump trigger sets a global isJumping variable to false (isJumping is set to true when the player leaves the jump trigger). Finally I added an if statement to check if the player is airborne and moving, if this is true then I set the isJumping variable to true. (Making sure to make an if statement in the character controller to play the landing sounds when the isJumping variable = true). Not very efficient at all but it does as it is intended. As this is my first project and experience with LUA I feel I can get away with it until I can think of a better method. ;)

If anyone else is having this problem feel free to shoot me a message and I'll gladly tell you what I did and even share my code with you. :) 

Edited by _Assassin_
Solved my issue myself.
Link to comment
Share on other sites

8 minutes ago, Genebris said:

Better do this:
 


if self.wasAirborne and not self.entity:GetAirborne() then self.landSound:Play() end

self.wasAirborne = self.entity:GetAirborne()

 

Genebris your a genius! You have managed to do what I did in 11 lines of code in just 2. I have been actively trying to solve this issue for 2 days and you do it in a moment. I cannot thank you enough! :)

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...