playMaker

Author Topic: Footsteps manager  (Read 4665 times)

nihilquest

  • Playmaker Newbie
  • *
  • Posts: 4
Footsteps manager
« on: August 23, 2015, 08:34:17 AM »
Hello, I'm new to Unity and Playmaker. I am a sound designer and musician so my main main focus at this point is trying out Unity sound capabilities. Right now I'm trying to figure out how to do footsteps for a mecanim character. So far I followed a method by mdotstrange described in this post: http://hutonggames.com/playmakerforum/index.php?topic=8562.0

This method works great but doesn't allow to change footsteps when stepping on a different material. Since the whole thing goes through a FSM to play a sound I think it shouldn't be a problem to add some kind of manager, which tracks the tag of a material that is stepped on (dirt, metal, poodle of mud...). After finding out what kind of material it is, the manager should transition to the appropriate state with a playsound action.

Sounds simple enough but right now this is above my head. Anyone? I think it should prove useful for many game designers .

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Footsteps manager
« Reply #1 on: August 23, 2015, 10:21:23 AM »
Hi,
When you find out on what ground your player is (with trigger event for example)
let it set a global int variable (call it GroundMat or something) 1 for dirt, 2 for metal, etc..

then when the footstep is triggered, add an "int switch" to check the int variable
and set a state for each sound (1 for dirt, 2 for metal, etc..)

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Footsteps manager
« Reply #2 on: August 23, 2015, 10:52:19 AM »
. So far I followed a method by mdotstrange described in this post: http://hutonggames.com/playmakerforum/index.php?topic=8562.0

You can use the send event from the animation to trigger a sound to be played and use the technique djaydino explains to play the correct one-

Its more obscure but if you can't add a different tag to each type of ground you can add null physic materials on the different ground surfaces and use get trigger info to grab that and do an int switch based off of it
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

nihilquest

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Footsteps manager
« Reply #3 on: August 25, 2015, 04:18:17 PM »
So this solution would require a trigger for everything the characters steps on? It seems like it a lot of FSMs. I thought it would be possible to check the tag of the object in collision with the character (just one FSM) and send it further. There is a "get tag" action in Playmaker, maybe this would do it? A string variable, convert it to INT, and after that int switch check...

Of course, I might as well work with triggers right now since I don't even have a real game, but I thought tags would be a good way to solve this.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Footsteps manager
« Reply #4 on: August 25, 2015, 05:08:40 PM »
Hi,
you need to set the trigger fsm on the player, and you need colliders on the surface (no fsm needed)
the surface colliders you can setup in different ways depending on your project,
for example :

you can use 2 colliders @ the beginning and end of a surface kind

or you can use 1 big collider to cover the whole surface of a single kind.

for a collider you can create a box and remove the Mesh filter and you can remove or disable the mesh renderer.
(i usually disable it so i can enable it again to see what the collider covers and when i am 100% sure it is good then remove it.)
and set surface tags on it ( and don't forget to set "is Trigger" :P )

nihilquest

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Footsteps manager
« Reply #5 on: August 26, 2015, 04:38:25 PM »
OK, so this kind of works but not as expected. I didn't use any int check, simply a "collide tag" on "Trigger Event" action to send it to states with sounds. I used "trigger enter" and "trigger stay". However, now the steps are out of sync. It seems the delay is caused by the need to check the material every step. Am I doing something wrong? Would a variable int check be more efficient?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Footsteps manager
« Reply #6 on: August 27, 2015, 01:33:40 AM »
Hi,
i think so because you do not need to check the int on every frame, only when you entered the trigger that need to be set

a different way you could try make a global audio variable and change the sound in that variable on entering the trigger.
and set that variable in the audio play action

nihilquest

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Footsteps manager
« Reply #7 on: August 29, 2015, 04:14:11 PM »
Thank you I think it works ok now! I used triggers to enable / disable FSMs with different sound groups.