x


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?

more ▼

asked Jun 09 '12 at 12:45 PM

multinfs gravatar image

multinfs
21 7 12 13

Check out this link under Physic Material:

http://unity3d.com/support/documentation/Manual/Physics.html

I hope this works as I didn't do it myself at this point of time.

Jun 09 '12 at 02:50 PM ExTheSea
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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 :)
more ▼

answered Jun 09 '12 at 03:14 PM

Winterblood gravatar image

Winterblood
439 3 6

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

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?

more ▼

answered Jun 09 '12 at 04:52 PM

multinfs gravatar image

multinfs
21 7 12 13

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.

Jun 09 '12 at 09:41 PM Winterblood
(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:

x2488
x446
x308
x197
x8

asked: Jun 09 '12 at 12:45 PM

Seen: 490 times

Last Updated: Jun 09 '12 at 09:41 PM