- Home /
Upper limits of Raycasting; Physics engine "gives up"
Hey guys, I've encountered a strange bug...
I'm making a Battletech-ish game with lots of cannons and rockets and gatling guns and other hoo-haw, and I've found that if I fire too many weapons at once for a long enough time, the physics engine just stops calculating raycasts entirely.
All bullet trajectories and collisions and such are all done using raycasts, the most expensive of which being a gatling gun that fires 70 rounds per second, each of the bullets flying through the air and checking for collisions with raycasts.
But the game does not chug even with multiple gatling guns firing at once; it's just at some threshold all projectiles stop colliding with walls, my robot's feet stop detecting the ground, and everything else raycast-related stops working.
The raycasts all just start returning "false." Even after letting up on all weapons, letting the projectiles all clear, and then firing again, raycasts are still not calculated.
Any idea what the heck is going on? Does Unity just get tired of doing so many raycasts and throw in the towel?
Well thinking of how many ray casts you are doing in each second Unity might not be able to calculate fast enough so they could be passing the object before Unity can calculate.I would try to decrese the number of bullets per second.$$anonymous$$aybe u can still show like u are shooting 70 bullets per second but behind the scenes you can actually shoot 10 of them and multiply each of their damage with 7 so you will get similar results with better performance.
The raycasts all just start returning "false." Even after letting up on all weapons, letting the projectiles all clear, and then firing again, raycasts are still not calculated.
i dndt see that part. $$anonymous$$aybe you can test you Raycast with drawing same gizmos as same as them ? There might some kind of bug as whydoidoit mentioned.
Looks like a Physx bug to me. There's no official limit for raycasts - the only problem should be a loss in performance. I once found myself a Physx bug in raycasts: after teleporting the player to some specific place, the enemy raycasts could not see it anymore - I had to change my code to work around this.
Sgt dude --- I swear, I have been having spooky RayCasting behaviour with unity the last few days.
(I did not update to 412 which just arrived this $$anonymous$$ute.)
For example: just for no totally explicable reason, a raycast stopped working altogether in some button code that I have used 88 zillion times.
It was driving me freaking nuts all afternoon. Eventually: Unity crashed, and when I came back the problem was gone. WTH !
And then there's this !!
http://answers.unity3d.com/questions/433906/terrifying-supernatural-timescale-setting-changed.html
Your answer
Follow this Question
Related Questions
how detect "OnRaycastOut" 1 Answer
How to use raycast on generated objects. 0 Answers
Raycasting not behaving as expected? 2 Answers
Some raycasts don't hit the object 0 Answers
Problem with raycast distance 1 Answer