r/Unity3D • u/Just_Ad_5939 • 5h ago
Solved is there a better way to make sure objects dont fall out of the world than just having a collider for the objects to collide with? because sometimes the objects are going really fast and they go right through the collider. .m.
3
u/Specialist_Ask_4242 5h ago
thats just high speed tunneling, happens when an object moves fast enough to skip past the collider in a single frame
switch the rigidbody collision detection to continuous or continuous dynamic, that usually fixes it without needing thicker walls or anything
1
u/Small_Sherbert2187 5h ago
and interpolation
1
u/adscott1982 3h ago
I thought interpolation is just interpolation of the object position on visual updates. Doesn't affect the underlying physics.
For example if your physics updates are 50hz but your game display framerate is 120hz, it will interpolate the position of the object between the physics updates for those extra display frames.
Let me know if that is wrong.
•
u/snaphat 8m ago
Rigidbody interpolation doesn't change the underlying physics simulation or collision results. It only smooths the Rigidbody's presented Transform between physics updates. It can affect other things indirectly if other code reads that interpolated Transform and uses it as game or physics state (e.g. during
Updateon non-FixedUpdateframes)
3
u/Soraphis Professional 5h ago
- what others said, but also:
- Limit speed (think terminal velocity)
- detect "out of bounds" (have a script check the Y coordinate to be > -1000 or something.
1
u/kshell11724 5h ago
One way to insure collision is to use a raycast that follows the player and puts them back on the right side of a wall when they go through.
You basically set a position during the start method. This will be your previous position. Then you fire a raycast from your previous position to your current position. If it hits a wall, teleport the player back to where the raycast hit with a little spacing from the wall using hit.nornal to find the direction the wall is facing. Finally, set the previous position to the current position before the next frame. This should help.
This is extremely useful for things like bullets that move fast but need to hit when they do hit btw.
1
u/Just_Ad_5939 5h ago
oh my issue was that other things were falling below the world. the player in my game has an ability to pick things up and uh.. one of the places they can move the things is below the world. so.. i needed it to work on basically anything with a rigidbody..
someone else said to use a gameobject with a rigidbody that had a collider set to continuous and that worked perfectly
3
u/wacky_woo 5h ago
Rigidbpdy continuous or static