Adding slide ability

Yoas

New member
Hello, I'm trying to add a slide ability to my character, like when you're running and then slide to go under an obstacle. I had done this with the previous version of the TPC and wasn't difficult at all, but with this new version I just cannot make the character to move while playing the animation. The character moves and then, when I press the button, it stops, plays the slide animation (without moving) and finally it moves again.
The slide animation is the same I used with the previous version of the TPC so the problem is not there. I tried using the functions ApplyPosition and Update position but they move the character until the animation has ended not while the animation is playing. I also tried to move the character by adding an AnimatorMotion but it doesn't look very good and besides I lose the liberty of moving the character while is sliding, I mean changing it's moving direction.
I also tried changin the Use Root Motion Position and Use Root Motion Rotation to True, False en No Override but still nothing, the only thing I can do while the animation is playing is rotating the character. The animation is in the FullBody Layer. I'm basically using the same code that HeightChange.cs has. Could you please lend me a hand with this? What am I doing wrong?
 
Does your slide animation have root motion data? It sounds like it should so you'll want to ensure that root motion data is not baked in and the controller is using root motion when slide is activated.
 
Thanks, the root motion data wasn't baked and the controller is using root motion. I now know where the problem is, but I just don't know why is happening.
Initially I had my character like 2 meters above the floor(a simple plane, nothing fancy, no physic material) (floor height y=-2.0f), so I tried putting the floor very close to the character (floor height=0.0f) and suddenly the sliding ability started to work fine, with movement and all. Then I put the floor back to it's original height (y=-2.0f) and again the sliding ability didn't work as it should, the character still had motion but very little compared to it's previous movement, then I increased this difference and (floor height=-10.0f) and the sliding ability didn't move the character at all. So for the best effect right now I have my floor at y=0.0f and the ability works perfectly.
I tried disabling the Fall ability but the problem persists so... I'm very confused about that.
I also tried this character at y=10f and floor at y=9.8f the ability worked fine, but character with y=-9.8f and floor y=-10f it stops moving. And finally character with y=30f and floor y=1f works fine.
In conclussion: my character's y transform position must be equal to or greater than 0.0f for the ability to work. But why is that?
 
That's really odd, I'm not sure on that. I would start by first adding only the slide ability and seeing what happens. You'll also want to ensure the y positional data is baked in to the animation.
 
Do you mean more than the sliding ability? Such as an actual slide animation? I do not currently have it on my todo list but can add it.
 
Top