How to implement trolley-like physics behaviour in Unity

1.5k Views Asked by At

I am stuck with two things while trying to simulate the physics setup for a trolley-like object (push powered vehicle with free rotating wheels on the front and fixed wheels on the back).

I have the RigidBody with its mesh and four WheelColliders, the object moves fine if I just apply torque to the wheels. However if I use the AddForce method on the RigidBody it won't move; I see the object being pushed (slightly balancing) but the wheels won't rotate so it stays in place. How can I get the wheels to move if the object is being pushed?

My other problem is to simulate the standard 360 degrees rotating wheels on the front of the trolley. What would be the best way to simulate this? I was thinking about a horizontal WheelCollider and a vertical one as a child but that seems really weird and I doubt it will actually work. Any ideas?

1

There are 1 best solutions below

2
On

https://docs.unity3d.com/Manual/WheelColliderTutorial.html

This tutorial shows an example of how to use the wheel colliders and apply steering and torque to them.

It might be what you are looking for in regards to the adding force part.

I suspect it might allow the 360 degree rotation as well, but I am not familiar enough with these colliders to guarantee that.

EDIT:

In the guide there is the line:

public float maxSteeringAngle; // maximum steer angle the wheel can have

Which looks relevant for the 360 degree turning.