A real wall to stop the bullets. ( collision )

Hi …

on this next picture below I instantiate a lot of soldiers to patrol behind the 2 wall
and I shoot from the other side bullets ( contain: box collide, rigidbody, etc )

And discovered that bullets pass through the wall, and kill soldiers …

so what I did was create two more ( no trigger ) box collide against the wall
and now the bullets do not go through
so works 100 percent … cool

BUT !!!
i know this is NOT the way to do this.

please somebody have any idea to share what is the best way to do this please.

any help will be greatly appreciated so much.

picture attach …

As I posted in your other thread:

If your bullets have Rigidbodies and are moving using physics (i.e. you’re setting up forces/velocity and then just letting them be moved by the engine) then change the Rigidbody’s collision detection mode to ‘continuous.’

If you’re moving the bullet from code yourself then you should remove the BoxCollider and do what Dustin said - work out what position the bullet is going to be moved to, then raycast from the current position to the new position to see if anything has been hit.

Hello there guys.

Just wanted to add my 2 miserable cents here:

For some reason beyond my understanding, unless you play with physics stepping and stuff, ccd doesn’t work really well, plus using rigidbodies for bullets is far from good approach imho. Raycasting from the old position to the current one works much better, however, i seriously recommend using only rays, and not rbs for bullets, just like something like 99% of the games out there.

You can manually apply speed and gravity, it’s a quite trivial task. Just make sure that when you cast other rays for speed, you start the next one to the ‘end’ of the previous one, not to have gaps between them, in this case the thing will be 100% consistent and much more efficient (rbs aren’t efficient for that purpose and ccd is resources hog).

You asked for the BEST way to do this, and the best way is using only rays. (imho, pretty much guaranteed :slight_smile: ).

Best Regards.

thansk so much …:slight_smile: !!!

question: you mean rycast ? if you …

i found this links and post here to help other people too.


first unity script click here

second … unity answers click here

and 3ths a tutorial video click here

and a unity3d small game based on raycast too click here

You’re welcome!

Yes, I mean raycast. Most AAA games uses raycast for bullets, it’s considered the ‘right way’ to do it… I mean, of course any way that works is okay, but using rays(casts) is more reliable and efficient, you can also apply forces on the rigidbody the ray hits on the exact position it was hit to simulate bullet impacts and stuff (apply decals, etc.). So there’s absolutely no need to use rbs (rigidbodies) for bullets, especially ccd (continuous collision detection), which is very inefficient.

Best Regards.