So my problem is that when the player jumps it takes too long to fall down, my rigidbody’s “drag” is already at 0 and it doesnt help…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
public float MovementSpeed;
public float JumpHeight;
private Rigidbody rb;
public bool isGrounded;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
PlayerController();
}
void PlayerController()
{
if (Input.GetKey(KeyCode.D))
{
transform.position += Vector3.right * MovementSpeed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.A))
{
transform.position += Vector3.left * MovementSpeed * Time.deltaTime;
}
if(isGrounded == true)
{
if (Input.GetKeyDown(KeyCode.W))
{
rb.velocity = new Vector2(rb.velocity.x, JumpHeight);
}
}
}
private void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Ground")
{
isGrounded = true;
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.tag == "Ground")
{
isGrounded = false;
}
}
}