Which would be best for performance? (Raycasts vs Shapecasts) [specific case for hit detection]

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

  1. I want to know which would be best for performance in the case of hit detection with a spherical object, shapecasts or raycasts?

  2. The problem is the question itself that was made above.

  3. I have thought about a situation that compares two different cases:

The one on the left shows 5 rays, 4 on the sides of the sphere and 1 in the center, all pointed to the desired location(note that the side rays will be parallel to the direction so they dont end up being just another center ray with just a little bit more room for detecting hits).

The other one shows the casual shapecast.

(MOST IMPORTANT: since this is for hit detection, it will be done multiple times a second, on the client side(I know it’s exploitable, but that’s something for later)).

I did look into some topics, but they didn’t really help me much when relating to this specific situation.

If you are making melee hitboxes then raycasting is not really a thing you should be looking for;
If you are talking about perfomance then obviously raycast will win in speed, it only calculates 1 face collision at a time and has lesser arguments in a constructor.

1 Like

The detection is for spherical projectiles, sorry for not stating.

One more question, even though a raycast is faster than a shapecast, would multiple of them(5 in this case) actually compensate performance-wise?

No.
Just do sphere cast in parallel.

1 Like

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