- Home /
Help with FPS slide mechanic
Hi
I'm currently trying to replicate different mechanics from different games and right now I'm really looking at the apex legends/titanfall 2 slide mechanic. I'm stuck on trying to get it to change the speed and time left until you stop sliding based on the slope you are on and how long you have been sprinting for(2 seconds inbetween), along with getting it to stay sliding in one direction. (It currently just goes wherever you look).
public void Sliding()
{
playerCollider.height = reducedHeight;
rb.AddForce(orientation.transform.forward * slideSpeed, ForceMode.VelocityChange);
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, slidingfov, slideFovTime * Time.deltaTime);
}
void StopSlide()
{
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, normfov, slideFovTime * Time.deltaTime);
playerCollider.height = originalHeight;
normfov = 90;
}
I've only got the base of the code here because I'm really stuck on how to code it, I've tried everything I could possibly think of to do those 2 things. I really appreciate any help I can get
I was originally trying to find the angle of the slope the player is on using a raycast, and then from there I can deter$$anonymous$$e the speed of the slide and how long the player will be able to stay sliding. That part I'm really stuck on
Your answer
![](https://koobas.hobune.stream/wayback/20220613043857im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Third Character Movement , Slide On Terrain and other object. 0 Answers
How to move player after animation 2 Answers
Character getting stuck on curbs.. 0 Answers
Need help on making player move towards gameobject, if clicked 1 Answer
Vertical mouse input inverted when player is turned around 0 Answers