Raycast по окружности и перед игроком

Hi! Please tell me how to make a raycast check around the player. And in front of you. I don’t understand anything about trigonometry((
In the picture I showed how I would like to do this

A raycast is just a straight line, from one point to another. To make a shape with it, you’d need to fire off a lot of individual raycasts.

To achieve what you’re after much, much faster, you’d be better off creating a sprite with a hitbox shaped like what you’re after, and then checking for collisions with other objects.

1 Like

Then there will be collisions behind the wall

Faster and cheaper than a sprite, for checking a collision or something in a circle area around another object just check the distances.

For the triangle area, I agree a sprite is faster in this case for new people in trigonometry.

1 Like

Once you have a list of candidate objects, perform a raycast to each of them.

1 Like

Yeah to sum up and add to what others have said:

Create a group of all visible enemies called Enemies
Create a group of all objects that block vision called Obstacles
Select all Enemies where Player.DistanaceTo(Enemies) < Variable(VisionDistance)
For each enemy:
[Invterted] RayCast from Player to Position(Enemy.CenterX(), Enemy.CenterY()) looking for Obstacles
So now you have selected all enemies that are visible from the player and is not obstructed.

1 Like

I will try to make your version later.