No ratings yet.

Character Controllers in unity3d:

 

The character in a first- or third-person game will often need some collision-based physics so that he doesn’t fall through the floor or walk through walls. Usually, though, the character’s acceleration and movement will not be physically realistic, so he may be able to accelerate, brake and change direction almost instantly without being affected by momentum.

In 3D physics, this type of behaviour can be created using a Character Controller. This component gives the character a simple, capsule-shaped collider that is always upright. The controller has its own special functions to set the object’s speed and direction but unlike true colliders, a rigidbody is not needed and the momentum effects are not realistic.

A character controller cannot walk through static colliders in a scene, and so will follow floors and be obstructed by walls. It can push rigidbody objects aside while moving but will not be accelerated by incoming collisions. This means that you can use the standard 3D colliders to create a scene around which the controller will walk but you are not limited by realistic physical behaviour on the character itself.

Previous

Colliders
Next

Character Controllers

Joints in unity3d:

 

You can attach one rigidbody object to another or to a fixed point in space using a Joint component. Generally, you want a joint to allow at least some freedom of motion and so Unity provides different Joint components that enforce different restrictions. For example, a Hinge Joint allows rotation around a specific point and axis while a Spring Joint keeps the objects apart but lets the distance between them stretch slightly. As usual, the 2D components have 2D at the end of the name, eg, Hinge Joint 2D.

Joints also have other options that can enabled for specific effects. For example, you can set a joint to break when the force applied to it exceeds a certain threshold. Some joints also allow a drive force to occur between the connected objects to set them in motion automatically.

Box Collider

Switch to Scripting

 

The Box Collider is a basic cube-shaped collision primitive.

Properties

Property:Function:
Is TriggerIf enabled, this Collider is used for triggering events, and is ignored by the physics engine.
MaterialReference to the Physics Material that determines how this Collider interacts with others.
CenterThe position of the Collider in the object’s local space.
SizeThe size of the Collider in the X, Y, Z directions.

Details

Box colliders are obviously useful for anything roughy box-shaped, such as a crate or a chest. However, a thin box can be used as a floor, wall or ramp and the box shape is also a useful element in a compound collider.

 

How to use character controllers in unity3d

Unity3d tutorials

Please rate this