My objects are falling to slowly when a rigidbody is attached, cab you help?
Asked Answered
J

12

0

When i attach a Rigidbody to an object, it falls at a very slow speed and no matter how much I increase the mass it falls at exactly the same speed every time.

it falls about 75% slow than this Unity tutorial

There is no code attached and the rigidbody has the default settings.

What can the be problem?

Jumbled answered 13/1 at 11:43 Comment(2)

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

Jumbled

1. 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
P
0

Are you sure that no other script are running elsewhere and impacting your falling speed ?

Are you sure you didn’t alterate the time flow (Project settings/Time) ?

Maybe you have modified the weight of your object or the gravity of the app ?

Pimbley answered 6/6, 2023 at 2:18 Comment(3)

until yesterday there were no scripts written and this problem has been around since before then. Now there are literally no scripts attached to the object it is a brand newly created 3D object with a rigidbody attached and it falls at the same rate if the mass is set to 1 or 5,000,000. drag is set to 0 I've not touched the Time flow and the current settings are the default settings.

Jumbled

Mass doesn't affect the acceleration of a falling object so it can't really be the issue if gravity is the only force affecting the object.

Acus

What about the scale of everything in the scene? If a root object is scaled, its child objects migh appear to be falling slower in relation to their size.

Acus
J
0

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

Jumbled answered 27/7, 2017 at 15:19 Comment(0)
P
0
  1. 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 answered 27/7, 2017 at 16:24 Comment(0)
A
0

Did you find an answer to this? I am having the same issue and can’t find anything.

Thanks

Arbuthnot answered 10/5, 2018 at 1:32 Comment(2)

yea the problem was solved, it was to do with the size of the object

Jumbled

check my solution below

Rabblerouser
C
0

Have you checked you have dragged the object into the scene after you’ve changed it? Rather than testing the same game object with the old settings in whilst changing settings in the inspector

Cheerly answered 30/6, 2018 at 17:1 Comment(0)
A
0

There are a lot of misconceptions here. Do not do the following:

  • Change the force of gravity in your scene.
  • Add an extra force in code.
  • Change the mass.

~A very long time ago, Galileo found out mass doesn’t affect freefall time. I am very confident the problem with your scene is the scaling. Look at this gif:
alt text
These objects are all the same except in that they are larger than each other. Keep in mind that, in Unity, 1 unit = 1 meter. Scale everything accordingly. If everything is scaled properly, I promise everything will fall realistically. If you have an object with a very large size, it will fall extremely slowly.

Allogamy answered 6/6, 2023 at 2:39 Comment(5)

Thanks, I shocked that I didn't know about this.

Illconditioned

Smart answer!, thanks.

Wessling

Great! Thanks for your informations.

Doubledecker

I'm glad someone said this its exactly what I was going to answer with when I saw the title of the question.

Intercourse

You are the best. Thanks!

Punctuality
S
0

i think its a coding mistake , you’re setting the rididbody.velocity.y = 0 in the code somewhere, and that makes the jumping fast (since its a force set from code) but the falling slow since its not set from code , the physics update get a few milliseconds between each Update frame to do its physics thingy but it get stopped once the velocity.y = 0 happens , or atleast thats the problem i had …

Sulphonamide answered 6/6, 2023 at 2:19 Comment(2)

ty man . it worked

Quandary

@off99555 What do you mean by "attach the prefab to some game object's field" ? Do you mean if you like have an active game object, and the non-instantiated prefab from your asset folder, is set in a field in a class on that gameobject ? That it's then returned in the FindWithTag-search function ?

Acidulent
C
0

You should go to Mars. I’m not joking. You shoud increase gravity values of your game enviroment.
Click Edit tab
131231-ans1.png

Choose (Project Setting/Physics). And change gravity values of Gravity Manager.

Centerboard answered 6/6, 2023 at 4:17 Comment(1)

Yes. Suppose that you have a Game Controller object and it has Game Controller script attach to it. The script has a field GameObject obj and you attach the prefab into this obj slot via Unity editor. And you have Player object, with Player script, inside the script you call FindWithTag(tag) with the tag of the prefab. Here, the 2 scripts are not related but the problem still persist.

Ticket
D
0

I’m having the same problem. I’ve narrowed it down to the Animator - when I disable the Animator component, the object falls as expected… not sure why

Dynamotor answered 13/6, 2023 at 23:58 Comment(1)

For me the object falls as expected specifically when I disable "apply Root Motion" in the Animator component

Dillman
R
0

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!

Rabblerouser answered 13/1 at 11:43 Comment(0)
R
0

I had the same problem. I just add downward force anytime the rigid body has a less that zero y vector. Playing with the amount of force will help fine tune.

Rolfston answered 26/10, 2020 at 15:30 Comment(1)

ObjectYouHit is just a name I thrown it for an object you deteced yourself. Good thing is that it's easy to detect it. In general you detect collisions with unity method [OnCollisionEnter][1]. Unity gives you CollisionData that has gameObject property. That gameObject is exactly what you are looking for [1]: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html

Purser
L
0

I’m new, and I had the same issue, and I just found out that its simply solved with a simple script that its task is to set the object’s Y value to its current value (I don’t really know how to put it), but here is the code (make sure you put the script in the object that you want to fix);

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class physics : MonoBehaviour
{
    Rigidbody rb; /*create a variable of the Rigidbody filetype, and set it to "rb"*/

    void Start()
    {
        rb = GetComponent<Rigidbody>(); /*gives the variable a value*/
    }

    void Update()
    {
        rb.velocity = new Vector3 (rb.vector.x, rb.vector.y, rb.vector.z); /*sets the position of the object to its position in the world*/
    }
}

This worked for me and I hope it does for you too!

Lager answered 12/1 at 23:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.