- Home /
Question by
xylofiso · Oct 08, 2015 at 08:51 PM ·
2d-platformerplatformerplayer movementsliding
Getting my character to slide 2D platformer
Hello I am having trouble having my player slide properly. When the key command combination is pressed he almost instantly teleports to the new location (which is no where even close to what I want him sliding to - he is short about what I would say 50 pixels) and the slide animation does not trigger.
void FixedUpdate ()
{
/OTHER CODE COMMENTED OUT TO SAVE SPACE */
if (Input.GetButton ("Down") && Input.GetButtonDown ("Slide"))
{
isSliding = true;
if(transform.localScale.x == 1)
{
rb2d.mass = 0;
rb2d.AddForce (Vector2.right * speed);
}
if(transform.localScale.x == -1)
{
rb2d.mass = 0;
rb2d.AddForce (Vector2.left * speed);
}
timer = 0;
timer += Time.deltaTime;
Debug.Log(timer);
}
/*
if (Input.GetButtonUp ("Slide"))
{
rb2d.mass = 1;
isSliding = false;
}
*/
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612040543im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Player slides off from moving platform when player isn't moving Bolt/visual scripting 0 Answers
Character animation jerks when moving 1 Answer
Restricting movement to one plane, but smoothly switching what plane that is 0 Answers
How to detect if player had switched direction of movement? 0 Answers
Jump 2D error 1 Answer