I had an issue like this, I was doing some first person rigidbody-based movement, and this was my code
void Update()
{
float hMove = Input.GetAxisRaw("Horizontal");
float vMove = Input.GetAxisRaw("Vertical");
MoveDir = (hMove * transform.right + vMove * transform.forward).normalized;
}
void FixedUpdate()
{
Move();
}
void Move()
{
rb.velocity = MoveDir * speed * Time.deltaTime;
}
and it was working all well and fine, until I started to the jumping portion of the script, the player fell like a feather. I hadn’t changed any gravity or mass or anything like that, but what was causing the problem is that when I set rb.velocity
to MoveDir
, MoveDir.y = 0
, so every fixed update the object was barely falling. So to fix this issue I did this
void Update()
{
float hMove = Input.GetAxisRaw("Horizontal");
float vMove = Input.GetAxisRaw("Vertical");
MoveDir = (hMove * transform.right + vMove * transform.forward + new Vector3(0, rb.velocity.y, 0)).normalized;
// i gave MoveDir a y value of whatever the y velocity was at the time, so it was essentially unaffected.
}
void FixedUpdate()
{
Move();
}
void Move()
{
rb.velocity = MoveDir * speed * Time.deltaTime;
}
Hope this helps!
I've checked older Unity files and the objects fall at the right speed, i just have no idea why they don't in my current project
– Jumbled1. What is your friction/drag set to? 2. What is your gravity set to? Edit -> Project Settings -> Physics Settings (or Physics2D Settings) 3. Do you have a floor or other object that could be causing friction/drag resistance?
– Petulia