Question by
falconsky06_unity · Jan 03, 2021 at 07:12 PM ·
2d-platformer
Rigidbody2D not working
I am making a 2D platform style game. I want my character to jump. I am farily new to unity, so sorry in advance if I don't provide enough details.
Rigidbody2D rb;
public float speed;
Vector2 move;
Animator ani;
void Start()
{
ani = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
move = new Vector2(Input.GetAxisRaw("Horizontal"),0f);
ani.SetFloat("Speed_Hor", Mathf.Abs(Input.GetAxisRaw("Horizontal")));
if (Input.GetKeyDown(KeyCode.Space))
{
Jump();
}
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + move * speed * Time.fixedDeltaTime);
}
void Jump()
{
print("Jumping");
rb.AddForce(Vector3.up * 12345677890f, ForceMode2D.Impulse);
}
I get jumping in the console, but the object doesn't move. My Rigidbody type is set to dynamic, and my animator Root Motion is set to false. I can send screenshots if needed. Thanks in advance!
Comment
Your answer
Follow this Question
Related Questions
My Timeline doesn't works how should do it 0 Answers
2d Platformer with timed score, how to prevent player from staying in 1 place the whole time 1 Answer
Camera doesn't move when two are present in scene 1 Answer
Problem with Jumping code in Unity 2D,problem with Jumping code in Unity 2D 0 Answers
Broken Jump Physics 0 Answers