What part of a football game should have a rigidbody?

I am not sure what should have a rigidbody besides the ball.

How am I supposed to make my football players run? Should I give them a rigidbody and use velocity?
Or should I use a Character controller for each player?

It all depends on your animation style, whether or not you’re using root motion, etc.

In my experience, I almost always choose the direct transform manipulation. Rigidbodies are unpredictable under most circumstances from my use of them, and they tend to exhibit seemingly random or jumpy behavior unless you spend thousands of lines of code to keep them in check.

Of course, you’ll see people write that anything that moves in a scene should have a rigidbody on it. If you choose that route, I would recommend you use root motion in your animations if all possible. You can check out the default player controllers that come with the Standard Assets for a look at the rigidbody and non-rigidbody player controller.

Keep in mind that rigidbodies have a fundamentally different way of moving (AddForce/Torque) which is notoriously difficult to control. The best analogy I’ve heard is “Picking a spot in a room you’d like to go, and then trying to throw yourself over there.” Whereas transform.translate gives you many options (Lerp/SmoothDamp/etc.) to smoothly and predictably move your character/ball/whatever from one spot to another.

Good luck on your game!

Hi there

Addyarb is partially right - rigid bodies certainly do behave a little differently, but they can be made to perform perfectly well when used correctly. The main thing to understand is that when you switch to a rigid body you are asking the physics engine to try to make them behave… physically! That means that if you start disobeying physics then you’ve got to be careful how you do it, or you end up fighting with the physics engine.

With rigid bodies, you get the advantage of physical behaviour - bouncing, rolling, physically ‘correct’ collisions (that take into account the velocity and mass of objects colliding), constraints like hinges etc etc. However you have to manipulate them carefully by using the force functions, or setting velocities while taking care not to set them to anything invalid. They certainly don’t require ‘thousands of lines of code’ to behave correctly though, so don’t be scared of using them if that’s what you need (as in the case of your ball)!

The answer to your question depends on exactly what behavior you want. In your case, I suspect you don’t really want much in the way of physics for your players. i.e. you want complete control over them, and don’t want them to roll around, bounce off walls or fall under gravity. Similarly, I suspect when the ball hits a player, you aren’t expecting it to bounce off them realistically based on their velocity - you probably just want the player to ‘catch’ the ball.

Given all that, I’d recommend leaving your players as simple game objects, possibly with colliders set as triggers so you can easily detect when the ball overlaps with one, without worrying about it actually bouncing off them. Once a player has the ball, you’ll want to make sure update the ball correctly. Probably do this using the rigid body’s ‘MovePosition’ function, and potentially setting it to be ‘kinematic’ while captured (meaning ‘I’ll control this for a bit thankyou very much!’).

I hope that helps. Basic lesson is - rigid bodies are the correct thing to use if you want objects to behave physically!

A few tips to add on:

  • The rigid body constraints are good to look at - these allow you to limit movement/rotation for a give n body
  • Remember something can have a collider without a rigid body. However moving something around manually that is interacting with rigid bodys can confuse the physics engine, as you’re effectively saying ‘this is static physics engine, but by the way it moved!’
  • The isKinematic flag on a rigid body is useful. This allows you to take full control of a rigid body (velocitys positions etc), but makes sure the physics engine still understands it, so you can control something manually and still have stuff bounce off it correctly
  • I added this answer a while back, which explains some of the force functions - might be handy need tutorials for rigidbody.Addforce - Questions & Answers - Unity Discussions