- Home /
Rigidbody fall speed slow
I have a sphere as my player and I made a script for movement on Z and X axis with rigidbody using velocity. But my sphere is falling very slow, I tried putting gravity to -1000 but its still really slow. I added a cube with just rigidbody no script and it fell fast.
Movement Script!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
private Rigidbody rb;
public float moveSpeed;
public float gravity;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 movement = new Vector3(horizontal, 0.0f, vertical);
rb.velocity = movement.normalized * moveSpeed * Time.deltaTime;
}
}
Answer by Exigo95 · Jun 06, 2019 at 09:55 PM
You are setting your y-velocity to 0 in every FixedUpdate, thus your character can never really get up to speed in the y direction. You have to maintain the current speed in that direction. To do this your are setting the y-velovity to the value it already is.
rb.velocity = movement.normalized * moveSpeed + new Vector3(0.0f, rb.velocity.y, 0.0f);
Moreover, you do not want to use deltatime with velocities of rigidbodies, as the rigidbody already is frame rate independent and takes over the calculation for you, see also http://answers.unity.com/answers/282011/view.html
Your answer