I’m building a fighter simulator, automatically bumping into the air.
I wrote a script that shoots Ray in four directions when the parts hit.
But when the parts are diagonally struck, there is not enough Ray.
Would it be better to make more Ray?
Or is there a better way?
You may need to make 8 rays, 4 in the directions you made, and 4 others in the corners
Other than that, can’t you simply use something else? Like a .Touched
event, it might not be accurate sometimes but I think it would serve well here
Why not use OnTouch?
Are these just Parts in-game or are they player’s body Parts that are contacting?
In a case like this you would probably need 26 rays.
A Part in 3 dimensions has 6 faces, 8 points, and 12 edges.
Because it shouldn’t be a hit if it hits top and bottom.
I’ll get four directions, but I can’t get a corner. Do you happen to know how to get it?
I am aware of that, but just 9 rays are needed in this case, because we are not covering the bottom and top, and all of the points
Create a ray, with the same direction as the upper ray for example, but add to Z
component of the upper ray, Z/2
of the upper ray (half of the z component), and do that for the other X
component. Make sure the calculations are relative to the correct direction.