- Home /
How to slide a character in temple run like game?
hi.. I am new to unity and I am creating a runner 3d game.I am able to jump the character and run the character.But sliding the character is not getting.I am not using character controller .I am giving constant force to run the character.Can anybody please help me to slide my character.....!
Answer by uchodhry · Sep 02, 2013 at 03:09 PM
Slide is just a state in with your character just switches to sliding animation and you set the player state to slide and any thing coiling at that state checks the player state and ignores the collision is player is sliding hope its not too late :p
I have my character a capsule collider and a stone has a box collider.when an animation of sliding is playing the collider remains straight and collides to box.how to stop colliding while animation is playing..!!?
if your character only have an capsule collider then just check OnCollissionEnter if the player is sliding or not but if you are using the rigidBody or character Controller then you need disable all the colliders of the sliding obstacles.
I used this code if i swipe down in update function animation.play("sliding") if(animation.isplaying("sliding")) { rigidbody.collider.enabled=false; rigidbody.usegravity.enabled=false; }
rigidbody.collider.enabled=true; rigidbody.usegravity.enabled=true; ..//but the collider is disabling just for one frame and sliding under the obstacle is not possible for me....
you can try the else to keep the colliders disabled during slide is being played. if(animation.isplaying("sliding")) { rigidbody.collider.enabled=false; rigidbody.usegravity.enabled=false; } else rigidbody.collider.enabled=true; rigidbody.usegravity.enabled=true;
or if this is still not working then try to add a timer so that you can turn on the colliders after some time this will be best as it will be independent of the animation duration
Your answer
![](https://koobas.hobune.stream/wayback/20220613104649im_/https://answers.unity.com/themes/thub/images/avi.jpg)