Unity52D - Player Jump Bug
Hey there,
So basically I am new to everything here, and I am trying to follow a site called Lynda.com. They have a special series of video's about creating an endless runner in Unity 5 2D.
Now as they started with the player I noticed the jump has some critical issue. Since i do not know the syntax or if there is a special feature I have to turn off here on unity I came to ask here.
A video of what the problem is:
Basically, that's not supposed to happen, the player should just jump striaght up and if the player gets pushed back a little bit, there is a fix to his X axis pushing him forwards.
Inspector insight - on the player.
The only scripts that touch the player:
using UnityEngine; using System.Collections; public class Jump : MonoBehaviour {
public float jumpSpeed = 240f;
public float forwardSpeed = 20;
private Rigidbody2D body2d;
private InputState inputstate;
void Awake ()
{
body2d = GetComponent<Rigidbody2D>();
inputstate = GetComponent<InputState>();
}
void Update ()
{
if(inputstate.standing)
{
if(inputstate.actionButton)
{
body2d.velocity = new Vector2(transform.position.x < 0 ? forwardSpeed : 0, jumpSpeed);
}
}
}
}
using UnityEngine;
using System.Collections;
public class InstantVelocity : MonoBehaviour {
public Vector2 velocity = Vector2.zero;
private Rigidbody2D body2d;
void Awake()
{
body2d = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
body2d.velocity = velocity;
}
}
using UnityEngine;
using System.Collections;
public class InputState : MonoBehaviour {
public bool actionButton;
public bool standing;
public float absVelX = 0f;
public float absVelY = 0f;
public float standingThreshold = 1;
private Rigidbody2D body2d;
void Awake ()
{
body2d = GetComponent<Rigidbody2D>();
}
void Update ()
{
actionButton = Input.anyKeyDown;
}
void FixedUpdate()
{
absVelX = System.Math.Abs(body2d.velocity.x);
absVelY = System.Math.Abs(body2d.velocity.y);
standing = absVelY <= standingThreshold;
}
}
I get that I either need to fix something in the inspector or I need to create a script which forces the player not to rotate, but I do not have enough of the syntax for it.
Your answer
Follow this Question
Related Questions
How can I fix this with my ground check? 1 Answer
How to check for colliders when teleporting the player in a 2D game? 0 Answers
Help with enemy AI Please! (on 2D Platformer) 0 Answers
i'm making a 2d game, the player can endlessly jumply please help! 0 Answers
I can't do jump in my 2D game 1 Answer