Question by
ItsOussama · Sep 28, 2021 at 09:39 AM ·
rigidbody2dgravityplatformerplayer movement
My Unity Rigidbody 2D character fall slowly after a jump,Unity RigidBody Character falls slowly
After a Jump my 2D rigidbody character falls slowly, i made a video of this happening (you can also see my rigidbody2d component on the video) : https://www.youtube.com/watch?v=l9PEslKVKL0
i have just one script attached to the player, i dont think the problem come from there but here is my movements script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movements : MonoBehaviour
{
private Rigidbody2D rb;
public float speed;
private float horizontalInput;
public float jumpForce;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxisRaw("Horizontal");
}
void FixedUpdate()
{
rb.velocity = new Vector3(horizontalInput * speed * Time.deltaTime, 0, 0);
if (Input.GetKey(KeyCode.Space))
{
rb.AddForce(new Vector3(0, jumpForce, 0), ForceMode2D.Impulse);
}
}
}
Comment