Resizing a collider in script?

I’m attempting to implement continuous collision detection, to keep characters from missing the terrain when they fall too fast, so I’ve been using physics raycasts from the corners of the hitbox to do the lookahead, but I’m having a weird problem with characters that are several terrain tiles wide impaling themselves on anything narrower than they are.

So I was thinking I could instead use a second hitbox to handle the terrain collisions, whose position and size are changed based on the velocity of the character, in order to check the area between where they are and where they are going, but there doesn’t seem to be a way to manually check an area for colliders (I was hoping for something similar to physics.ray_cast, but for a specified area rather than a line), and the closest thing I can find for resizing a collider is to delete it and recreate it with the desired new size every update cycle, but that seems like a lot of overhead.

Is there an easier way to go about this?

1 Like

No, I’m afraid not. I hope we will get to this task quite soon, since it’s a recurring problem for developers.

I’m not sure why your raycast solution doesn’t work though…

3 Likes

If your use case allows it you can have a limited set of colliders of different size and enable/disable them depending on speed.

2 Likes

Mostly it’s because I’m firing the rays from the corners of the hitboxes, the largest of which (so far) is 144 pixels wide, while the terrain tiles are only 32 px wide, so it becomes very easy for the rays to land on either side of certain pieces of terrain (such as a free-standing wall) and then the collision check misses them entirely and I end up inside the wall instead of on top of it.

I’ve tried adding more rays to compensate, but in order to eliminate every edge case, I need a ray every 4 pixels along the hitbox, and having over a hundred raycasts per character is… very slow.