Before any replies, no, I am not using fast-cast or whatsoever open source melee modules out there, unless there’s one that matches with what I am trying to do.
I’m currently trying to create melee raycasts by detecting object hits inside a cone-shaped area. Similar to a melee raycasts on games like CS:GO / Valorant, which melee checks for a small degree of angle offset.
The cone is depicted by the green lines:
Currently, I have tried using workspace:GetPartBoundsInRadius to get the parts inside the red sphere. Then calculate the degree between collided part and the origin to see whether it is positioned within the cone, if it is, it would be counted as a hit object.
By using workspace:GetPartBoundsInRadius, the part can be detected despite it’s origin is outside of the red sphere. However:
As of now, there is no way to get the exact hit position of the object. If I cast a ray between the center of the hit object and the origin, the angle (yellow line) will exceed the cone area.
Is there any method to achieve such raycasts behavior? Or I would have to cast hundreds of ray per frame inside the cone to detect whether what’s in there?
i would get the angular offset instead, you can calculate what the threshold of the angle should be to get a cone shape without having any rays or getpartsinpart methods
realistically the sphere is a good start, getting objects within it, and to test whether or not its within’ your desired angle to attack, you can use the dot product with the vector from the origin of the attack to the attacked position and the attack direction and see if that is within’ a threshold, if so its within your angle (0-180) and you can attack