Lawn Mower Physics - Can you assist?

Alright, after having a bit of frustration, I thought I’d ask for help. I’m working with a lawn mower. Not the little push mowers that mow your house yard. These big mowers:
1679871--105266--lawnmowerexample.jpg
(Image taken from TurboSquid. Please don’t sue me.)

In my case, my family has a business that has lawn mowers in stock which is pretty nice, as I have access to specifications of the lawn mowers, the tires and whatnot.

Anyway, in my case I’m trying to make the lawn mower move like a lawnmower. What I’ve experimented with is the following:

  • Car Controller: This approach was successful after a few trial and errors. Although, from what I heard, Wheel Colliders aren’t really ideal for mobile devices due to the collision detection. One attempt caused my friend to burst out laughing.

  • Tank Controller: This was more like the system I wanted to achieve, however I would disable the stationary traverse since unless I decide to roll with a on a ZTR (Zero Turn Radius) mower. The SimpleTankController script in Unify Wiki uses Character Controller, which is a capsule… and that doesn’t suit me since mowers aren’t capsules.

  • Roll your own Controller: This is what I’m currently trying to do. It will allow me to mow the lawn my way and also manage Rigidbody physics. However, as I can point out below, it’s acting funky.

  • You suggest a snippet of code or a controller: If you think you know what I’m trying to achieve, feel free to say “hey, here’s a script that will do what you want it to do” or “here, this will get you on your way”.

Game Situation (At the moment):

  • The game will have up to 4 lawn mowers controlled by a Bluetooth Server-Client Implementation.

  • Must be optimized for Mobile (Android). Excess CPU cycles need to be kept to a minimum if possible.

  • I can get a basic rigidbody moving using a cube (that is Scaled X 1 / Y 0.5 / Z 2 ) with a box collider (with all scalings set to 1) using the following code:

rigidbody.AddRelativeForce(Vector3.forward * 10);

…but the issue is that it veers off to the right (positive X axis). I don’t know why this happens, I try to set all RB Drag options to 0, but it still happens. Maybe I need to modify something in the Rigidbody or it’s off center?

  • I know I could get this setup working with a Character Controller, but the thing is that it puts a capsule collider on the mower. Unless I can rotate the collider so it goes hortizonal (not vertical), it’s kinda useless.

  • The lawnmower will need to be able to interact with objects. For example, if it hits into a gas tank, of couse I want it to explode and cause damage to the mower. I know Rigidbodies do the job well. And I do intend to have head-on collisions with other players.

Thank you very much for your assistance. I appreciate little hints, or a few lines of code - it’s all welcome and hopefully can shine light into areas where I’ve missed. I’ll keep you posted how I go. :slight_smile:

Alright, after a little bit of picking brains out on the IRC, it seems that the veering was somewhat caused by the scaling of the gameobject. In my case, my cube was turned into a rectangle by setting the Scale to X 1, Y 0.5 and Z 2. However, for some reason, when you apply forces to it, it got stuck in place and spazzed out.

However, I am still unsure how to rotate the ridgidbody. I know Torque isn’t going to do the trick, because that causes the Rigidbody to spin on itself, I think I will need to rotate the parent transform to achieve this.