i have a part that travels very fast and bounces off walls. However since the part is very fast, it sometimes goes through walls. I have a Heartbeat loop that does all of the stuff to make the part go faster (dont ask for the code as it is not needed)
how should i stop the part from going through walls, while mainting the high speed?
Just make the walls thicker. Incase you don’t want them to appear thicker you can add another layer of invisible walls.
There is definitely a better way other than making the walls thicker, and anyway the part could get stuck inside of the part
You asked for a way and I told you, you can also change the part’s PhysicalProperties.
what physcial property specifically?
I don’t know exactly cause I’ve never had this exact issue but play around with them until you get something that feels right.
im pretty sure none of the physical properties would stop it from going through walls anything thanks for helping
This is probably caused by the physics system not being at a high enough framerate to find the part colliding with the wall, which can be pretty common if you have something that goes fast enough. Roblox’s physics step at 240hz, aka a physics framerate of 240 times a second, so I’m guessing the part is going blazingly fast.
How fast is the part going and why do you need it to be going so fast? Have you tried making sure Workspace.PhysicsSteppingMethods
is set to Fixed
?
using AssemblyLinearVelocity.Magnitude, the part is capped at 100. however sometimes when i cap it at 75, it goes through stuff.
making SCP-018; a ball that bounces with 200% efficiency, for example it bounces 1 meter up, then 2, then 4, etc.
and yes it is set to fixed
Try printing the delta time sent with Heartbeat
RunService.Heartbeat:Connect(function(Delta)
print("It has been", Delta, "seconds since last frame")
end)
What does it say?
Can you show how your code is limiting it’s speed?
Did you only have this issue when you increased it’s maximum speed to 100? Try lowering it to figure out where the cutoff is.
What’s the thickness of the wall, if I may ask? Does the game feel slightly laggy?
and (Part.AssemblyLinearVelocity).Magnitude < 100
lol
cutoff is like 75, but 75 also isnt as fast as i want it to be
walls are pretty slim with .1, but replacing every wall to be thicker would be annoying, also no the game doesnt feel laggy
I managed to get a sphere to pass through a .1 stud wall with a velocity of ~950 (from .Magnitude of 673,0,673
). By making the walls 2 studs thick, the ball didn’t phase through the walls with a velocity of more than ~1500 (from .Magnitude of 1100,0,1100
).
Overly thin objects just don’t play well with fast physics objects, something can pass through them too easily.
I tried drawing what’s happening in Paint. If you make the wall thicker, there’s a higher chance the physics engine will find a collision and make the ball bounce back.
Also the formula is techincally Position = (Position + Velocity) * DeltaTime
, so a higher physics framerate will lead to more accurate physics since everything will be moving in smaller increments, leading to this problem happening less. But Roblox’s physics already run at 240hz so it doesn’t really need a higher framerate. But lag can cause physics to slow down, but I’m not sure if the entire thing slows down like slow-mo to prevent physics errors or if it skips frames instead.
so i should just make the walls thicker?
when you use AssemblyLinearVelocity.Magnitude it should just return 1 number, so how did it pass through a wall at 950 when mine can pass through walls at 75?
Yes
Have you tried printing the velocity.Magnitude every Heartbeat? The if statement you sent had another expression with and
, maybe that’s stopping it from being speed limited?
Also, for me it prints ~0.016 seconds, but for you it seems to be jumping up to ~0.019. This could slow down the physics step enough to make something like this more common.
I’m honestly not sure, but it’s still just a bad idea to make thin walls with fast moving objects.
ill just mark this as a solution and I will DM you the full code so you can understand it better