It looks like you're new here. If you want to get involved, click one of these buttons!
I've been following a tutorial on a 2D platformer controller however when trying to jump it doesn't work. But if I disable the movement it jumps perfectly fine. Here is the movement code
public class PlayerMovement : MonoBehaviour
{
private Rigidbody2D rb;
private Vector2 movementInput;
bool facingRight = true;
[SerializeField]
private float speed;
[SerializeField]
private float rotationSpeed;
[SerializeField]
private float isMoving;
[SerializeField]
private float speed2;
public Vector2 jumpForce;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
SetPlayerVelocity();
}
private void SetPlayerVelocity()
{
rb.velocity = movementInput * speed;
isMoving = rb.velocity.magnitude;
}
private void OnMove(InputValue inputValue)
{
movementInput = inputValue.Get<Vector2>();
}
}
Jump code in replies
Any help is appreciated and thanks in advance
Answers
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JumpCode : MonoBehaviour
{
bool isGrounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
public Vector2 jumpForce;
public Rigidbody2D rb;
private void OnJump()
{
rb.AddForce(transform.up * jumpForce, ForceMode2D.Impulse);
Debug.Log("TEST");
}
}