- Home /
Bullet case lagg & collision problem
I have a gun that shoots bullets and ejects shells from a empty gameObject's position next to the gun.
Now, the problem is that I want the shells to like bounce a little and maby roll over if another one hits it, I tried with setting the Mesh Collider to be Bouncy but it just keeps bouncing very high.
And another problem is that after about 60 shells are ejected on to the ground it starts to lagg, like to 5fps and I dont have a slow pc. Is there any other way of keeping many bullet cases on the floor without them taking too much of the pc's performace?
Check out this link under Physic $$anonymous$$aterial:
http://unity3d.com/support/documentation/$$anonymous$$anual/Physics.html
I hope this works as I didn't do it myself at this point of time.
Answer by Winterblood · Jun 09, 2012 at 03:14 PM
Three things to try:
Make sure the casings have the cheapest possible collision geometry - a capsule is probably the best choice. Mesh colliders are very expensive.
Give each casing a script that turns the collider off after 5 seconds and deletes the GameObject itself after a minute or so. Otherwise you'll fill the level with casings.
Choose a more suitable physics material for the casing and ensure the mass is set very low. You should then get a realistic bounce off the floor. "Bouncy" means rubber :)
Answer by multinfs · Jun 09, 2012 at 04:52 PM
well if I set the mass to be lower I'd have to decrease the force added to it after it has been ejected. But I'll try
Thanks for your answer :), The capsule collider made it alot less laggy.
EDIT: 1)Btw if you turn off the collider doesnt it make the case fall down through the floor??
2)The bullets that are falling from the gun are stopping the character from moving through them, Is there a way to make the bullets just bounce off the player instead of stopping it?
1) Sorry, yes - you'll need to turn off the rigidbody too. You want them active long enough to bounce and settle on the floor, then they just render for long enough for the player to move on. You won't be able to kick them around, and if you wait long enough you'll see them vanish, but it'll keep the framerate up. You could make them wait until they're offscreen before deleting them if it matters.
2) I'd recommend just letting them pass through the player, it's much easier. Create a couple of layers called "PhysicsDebris" and "Player", set the casings to one and the player capsule to the other. Then go into Edit->Project Settings->Physics and uncheck the box that allows collisions between those two layers.
Your answer
Follow this Question
Related Questions
Rigidbody of empty bullet shell collision problem. 2 Answers
Making a bullet destroy itself on contact. 1 Answer
bullet desent seem to apear (javascript) 0 Answers
ParticleSystem collision checking. 2 Answers
bullets wont show up 1 Answer