Proper Barrel Collision and Collision Sound

I’m looking for suggestions to get better physics and sound reactions from my physics barrel. I have the barrel setup with 3 game objects for the collider sections, BarrelBottom, BarrelTop and Capsule. I also took a look at the barrels in the FPS tut and those barrels don’t roll, because they only have one cube collider and they don’t move when you bump in to them.

Right now, my FPS Controller climbs up them which is not what I want, and my sound doesn’t react on time.

Here is the setup and code for what I have:

var hitSound : AudioClip;

function OnCollisionExit (other : Collision) {
	if (other.collider.name != "Player") {
		audio.Stop();
		audio.PlayOneShot(hitSound);	
	}
}

Thanks for any help or suggestions.

-Raiden

It’s probably easiest to make a convex mesh collider in the shape of a cylinder. It also works pretty well if you combine a number of box colliders…the attached screenshot was for a disk, but a cylinder would be done using the same technique, but with thicker colliders. You can also make them go lengthwise in a ring shape instead of overlapping like that, but then the cylinder will be hollow.

–Eric

214342--7861--$picture_1_834.png

Thanks for the tip Eric. I re-assembled my barrel like yours and it seems to work better.

I also found a setting “Step Offset” for the FPSController, and lowered it to 0.1. This fixed the gliding up on top of the barrels.

The sounds still aren’t exact, but it is playing when it bumps the ground.

I’m pretty satisfied with what I have, so I’ll build a couple of styles prefabs for these and continue on.

-Raiden

I think the best way to make a “rollable” cylindrical collidr is simply use a capsule collider and add a box collider with the same height, but a x/z dimension that fits exactly inside the capsule. This way, the cylinder is stackable, if you kick it arround it would still fall on it’s side and roll perfectly, cause on the side only the capsule is colliding…