-
Notifications
You must be signed in to change notification settings - Fork 24
Scripts.FootStepKeyFrame
##Scripts - FootStepKeyFrame
###What does this do?
This will play a sound at a specific key frame of an animation. This is used to produce footstep sounds based on the material that you're walking on. This will work with both terrain and basic objects at the same time.
###Who/What is this for?
Place this on the root of an object that needs to have it's keyframe access this script to play a sound.
###Setup
- Place this script on the root of your gameobject.
- Here are the following options
Inspector Param | Type | Description |
---|---|---|
Use Terrain | bool | Trigger on to only play sounds if on a terrain. Otherwise use both object and terrain. |
No Sounds | bool | Do/Don't play sounds. Allows you to use an animation without breaking at each keyframe. |
Material List | Dict List | Dictionary of material names and sound and volume options. (Number is depricated ignore it.) |
Object Height | Float | Raycast to ground. If hit during keyframe, play the materials sound. |
Position Adjustment | Vector3 | Start the "Object Height" Raycast from this position |
Audio Source | Audio Source | What Audio Source the footstep sounds will be played from. |
Use Override Volume | bool | Force the footstep sound be play at the "Override Volume" level for all sounds. If not enabled it will use the volume specified in the Material List |
Override Volume | float (0 to 1) | Only works if "Use Override Volume" is enabled. Sound level to play footstep sounds. |
Debug Surface | bool | For debugging. Will log what surface the "Object Height" raycast is hitting. |
Debug Height | bool | For Debugging. Will log the height of the raycast. |
Setup this how you would like. However it will error out if the raycast fails or the material was not found in the dictionary list. Below are some pictures of how I set it up:
Once that is setup go into your animation that you want to play footstep sounds and add the keyframes.
- In Unity Click the Window Tab > Animation
- With the "Animation" tab open select your NPC Object that has your animations attached.
- In the "Animation" Tab select your target animation
- Go to the exact point in the animation and add a keyframe
- In the dialog box that appears select "PlayFootStepSoundKeyFrame()"
- If this isn't an option that means that you have added the "FootStepKeyFrame" script incorrectly.
- Add as many keyframes that are needed.
The following is a list of github repositories that made all of this possible:
delta patches: https://github.com/OctopusDeploy/Octodiff
.net 4 implemented in Monodevelop: https://github.com/mono/mono
Tuples In Unity: https://gist.github.com/michaelbartnett/5652076
Octodiff: https://github.com/OctopusDeploy/Octodiff
Input Manager: https://github.com/daemon3000/InputManager