Hit detection help

Hello developers, currently I’m working on a game where the player falls extremely fast using velocity. However, Iv ran into an issue involving hit detection.

My current method of detecting if a player hits a part when falling is by using renderstepped and casting a ray from the player HRP a certain amount of studs and seeing if it hits something, however, if the player is falling too fast sometimes it doesn’t detect when a player collides with an object.

Any suggestions on different methods?

1 Like

Keep a variable for the players last position, and cast from their last position to the current position.

Add invisible parts that are taller.

Maybe you can correct the timing of the hit by figuring out how far the player is from the “real” part based on their velocity.

Not sure what you mean by this as I’m already casting a ray from the player’s current position everyframe

How do you determine the amount of studs to cast the ray down from? And what is your origin on every frame ?

Origin is the player HRP pos and I cast it -10 studs on the y-axis

yeah so basically, your origin needs to be the players last position (keep track of this in a variable or something) and the -10 studs down needs to be the magnitude between the players last position and current position

I am not sure if this is what I’m looking for because currently, in every frame I’m getting the players new HRP position and casting a ray to 10 studs below the player to see if they hit something

Maybe this image will help understand. Method 1 is how you’re doing it, and Method 2 is how I’m explaining. The issue is that if you’re going too fast, the player position might just go through the ground from frame 1 to frame 2.

but in method 2, casting on frame 2 where the origin is the players last position and the distance is the magnitude between the last position and the current position it’s guaranteed to check if the player went though the ground for any speed

1 Like

OHHHHHHHHHH I understand now! Thanks a lot, man! I’ll mark your post as a solution after I test it!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.