x


Collisions between two CharacterController objects?

(I am using the 2D Lerpz tutorial)

I have one prefab that implements a custom version of the PlatformController script, which utilizes CharacterController for collisions. My custom version implements functions for enemy AI, essentially, and I want enemies to be able to collide with each other and perform certain actions on the collision.

I am using a simple script to detect collisions and print them out on the screen:

function OnControllerColliderHit(hit : ControllerColliderHit) { var gameObj : GameObject; gameObj = hit.gameObject;

 Debug.Log(gameObj.name);

}

It's important to note that this PlatformController script implements its own form of gravity as well as some light filtering for physics, it's for a simple 2D platformer.

When the enemies are running around the level, this works fine - it displays the debug message for all the platforms and objects they run into, crates, barrels, posts, etc. However when they hit another enemy, they physically collide and can't move any further, but no collision debug message is actually output.

http://answers.unity3d.com/questions/7091/charactercontrollers-dont-register-collisions-with-each-other This question indicates that CharacterControllers can't actually easily collide with each other, which gives me two questions: 1) Is there any kind of easy way, or could I add a second collider to the object? 2) How would I specifically go about switching from the PlatformController+CharacterController implementation for these enemies into something using rigidbodies and normal colliders? For this tutorial script, would it be very difficult?

more ▼

asked Oct 20, 2010 at 03:11 PM

Polatrite gravatar image

Polatrite
39 13 13 23

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

2- You could add more colliders on objects parented to your character object and they will collide with each other.

1-Not sure about this one, but try setting your character colliders to Convex and it should work fine.

more ▼

answered Oct 20, 2010 at 06:55 PM

Bravini gravatar image

Bravini
1.1k 17 20 47

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4265
x2993
x1175

asked: Oct 20, 2010 at 03:11 PM

Seen: 3919 times

Last Updated: Oct 20, 2010 at 03:11 PM