Colliders and Different Methods of Moving Objects in Unity

One problem with students starting to work with Unity is to understand when colliders work and when they do not work. This very simple demonstration shows how Physics::AddForce(), CharacterController:: SimpleMove() and Translate.Transform() behaves with colliders. Moving a GameObject using Physics and CharacterController based methods interacts with collisions whereas Transform::Translate() does not as seen in the video. Moreover, Translate does not work with MonoBehavior::OnTriggerEnter().


Physics::AddForce():

public class PhysicMove : MonoBehaviour {

	void Start () {
		rigidbody.AddForce (new Vector3 (100, 0, 0));
	}
}

CharacterController::SimpleMove()

public class Move : MonoBehaviour {

	public float speed;

	private CharacterController controller;

	void Start () {
		controller = GetComponent ();
	}
	
	void Update () {
		controller.SimpleMove (new Vector3 (1, 0, 0) * Time.deltaTime * speed);
	}
}

Transform::Translate()

public class MoveTranslate : MonoBehaviour {

	public float speed;

	void Start () {
		enabled = false;
	}

	void Update () {
		transform.Translate (new Vector3 (1, 0, 0) * Time.deltaTime * speed);
	}
}

Published by lankoski

Petri Lankoski, D.Arts, is a Associate Professor in Game Studies at the school of Communication, Media and IT at the Södertörn University, Sweden. His research focuses on game design, game characters, role-playing, and playing experience. Petri has been concentrating on single-player video games but researched also (multi-player) pnp and live-action role-playing games. This blog focuses on his research on games and related things.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: