Character control and colliding

A few things about the character control component.
I am making this 3th person game were you fly a helicopter. So the camera is behind the helicopter and the helicpoter has the character control component attached to it.

The first problem is that i can’t seem to find the correct values for radius and so to match my object good. Is their a way of creating a better shape for the controller so it’s matched my model better?

A second question. My terrain has some mountains on it. I want to, when the helicopter touches the mountain, it must explode but when it lands on a flat piece it does not.
How can i achieve this?
I though about checking if the model collides on the bottom, than everything is ok. If he collides with the left, right,top he must explode. But i don’t know if this is possible and how to do this… Anybody has any tips for that?

Are you sure the CharacterController is the best way to go here? A vehicle often looks good with physics and it might be easier to set up your colliders to match the shape of the helicopter.

If there are just a few landing pads in the terrain, then it’s probably easiest just to have a trigger in the middle of each one. Set a boolean “flag” variable to true when the helicopter is inside the trigger and set it to false when outside. Then, you can activate the explosion only when the flag is false. You could do this in reverse (ie, put the trigger on the mountains) if the terrain is mostly flat.

If the terrain has a complicated mixture of flat areas and mountains that are not easily covered by triggers, then things are a bit more difficult. If you do decide to use physics for the helicopter, then you might be able to use this to detect a bad landing. For example, if it tilts more than a certain angle from vertical as it contacts with the ground then it explodes.

Don’t know… I thought the helicopter is the character you are playing so i must use the character controller… Seems like logic to me.
if i use a collider and rigidBody this would also work but than i have to addapt my code. don’t know if it’s much work to change from controller to rigidbody.
Are their any guidelines on the use of charactercontroller vs rigidBody because in my movement of the controller i use the gravity as well. It would feel more realistic with a rigidBody, true but i never thought about using it…

Yes the terrain is complicated and i want the user to be free to land were he want.

just a thought that came up while i was reading your post.
Couldn’t i use raycasting here in this case? I could cast a ray on the x-axis. When the distance to the collision between the ray and the terrain is smaller than a give value, the helicopter explodes. I can do the same for the Y axis.
This ofcourse will need 5 rays every update (+x,-x,+y,-z,+z) -y is not needed because that is landed.
Wouldn’t that be to much for the processor every frame?

Just wrote the raycast idea and it works :slight_smile:

if(Physics.Raycast (transform.position,new Vector3(1,0,0) , hit, 120)) 
	{
		if(hit.collider.gameObject.tag=="terrain" )
		{
			crashed = true;
			if(crashed)
			{
				changeTo3thPerson();
			}
		}
	}

I just have to add 4 more rays to test for it.
Should this cause performance issues or is it ok to use it that way?