0 votes

Hi, I have some nob questions. I am making a game where you are a car and you have to transport things. I am making a prototype with my car as a Rigid Body and a box as a Rigid Body too. I am facing 2 issues:

First when accelerating my car the box that it is transporting tends to roll back and fall immediately, so you can´t transport anything. How I can make it grab a little so the box only fall when I am at certain speed?

An example:
https://imgur.com/a/ulqmswr
box

Second issue appear when the box is on the corner of my car, the car begins to tilt due to the weight of the box,How can I prevent the car from suffering that weight?

An example
https://imgur.com/gallery/9FadeaX
box weight

For both problems I tried changing gravity, mass, height and friction but I can´t see a difference

Godot version 3.3
in Engine by (138 points)

Have you taking a physics course yet? I think what you're trying to accomplish is going to be very difficult without being able to draw a Free Body Diagram of your car and box interaction and a baseline knowledge of physics. I would suggest following along with the first three modules here: https://www.khanacademy.org/science/high-school-physics to get a baseline understanding of motion in physics.

I think ultimately what you're going to want is the platform of your car (where the boxes rest) to be it's own RigidBody2D that rests on its wheels which are their own RigidBody2D's. Alternatively you can calculate the torque applied to your car at runtime and use the apply_torque_impulse() function to apply that torque to your car accordingly. This is going to allow you to achieve the effect you described in your second issue. (You're going to need to be clever about how you keep the wheels of the car in sync with the platform of the car though.) The first issue is all about how you're applying the forces to the RigidBody2D box, until you're able to draw a Free Body Diagram of your problem it's just going to be a guessing game which numbers to use for what and what calculations to perform.

1 Answer

0 votes

Physics work just the way they work.

You could bypass the behaviour by implementing in _physics_process(state) function some code that will make use of rigidbody.get_colliding_bodies() to change linear velocity of your crate to the one of your truck, to prevent it from falling but it might look clunky in the end. You might just want to have a simpler approach!

Cheers

by (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.