Need help with hit detection on a growing/moving part

Essentially I have a system I’m working on.
In this system there’s a part that rises, think lava/water/etc.
This part is rising slowly through a control module not related to the damage module.

The part is being spawned and has CanCollide off, but CanTouch on, and it is Anchored.

I’ve run into the same problem no matter what with normal hit detections.

Basically, the part is constantly getting taller (Y axis) and having to be moved up half of the growth to keep it growing upward/rising.

During that time, when it’s growing or moving, it disrupts touching, raycast, and even when I try to use position checks, making it very hard to get consistent hit detection. This makes the damage very unstable as I’ve noticed often the hit detection misses that it is there.

I tried to get clever and I spawned a vector3 value inside the part for size and position and I bound synced it with heartbeat or a variable timing (been playing with both) making it constantly update the position in those vector3 values, and I had that script omit updating any time the values come back nil, this way the value is constantly correct.

This seems like a waste resource-wise and I can’t use it with anything but region3 checking for overlap which gets to be a pain accurately detecting when it touches the player at all. Like I have to make a hitbox, update it, then try to check that hitbox for overlap with the parts vector3 values.

So my question is, does anyone know a solid, efficient, and reliable way, to detect a hit/touch/raycast/etc. between anything (I need to detect player hits and other object hits) with a constantly moving/growing part that has Collisions off and is not moving with physics?

Because of the speed at which the part is rising (a small amount often) sometimes it’s failing up to 80% of my hit checks regardless of the method, regardless of whether the check is run from the part’s perspective or the other part’s perspective.

It has to damage objects as well as players and I feel like I’m totally missing something obvious. I’m pretty sleep-deprived right now, so I figured it was time to get some advice here.

You may want to look into shapecasts or GetPartsInPart.

Thanks, I will definitely look into shapecasts. Seemingly, GetPartsInPart and OverlapParams seemed to help solve it.

If using GetPartsInPart worked please mark that as the Solution so if other people use the Search tool looking for help about the same issue they will see that solved it for you.

Sorry, I didn’t even think of that because I had solved it before seeing the answer, and because it didn’t solve the whole problem, It actually took both combined. GetPartsInPart only helps with the outside initial touch (Though this part wasn’t the hardest and there were other ways.).

OverlapParams is what solved the hardest part which was the stable detection of a part the player is inside. This is the part even Region3 was breaking on that left me inside the lava/water that was growing but never taking damage.

So for the water that was rising, GetPartsInPart worked up until the water got overhead but OverlapParams is what allows for stable detection once you are under water.

1 Like

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