Answer the question
In order to leave comments, you need to log in
How to let Raycast around the area?
Even MB is not purely a beam, but something like a computer. of view so that the 2d sprite can use it to check whether other objects are in the field of view (I don’t want to use the trigger because it will see through the walls
Answer the question
In order to leave comments, you need to log in
Usually many beams are used for these purposes, or one beam is rotated within the zone, in any case, this is how the field of view in the game is usually described, the option described in the comment (with a trigger) is also quite good, it will reduce the number of Raycast calls to the number of objects in the trigger, however, if too many objects fall into the trigger, there will be an overflow of Raycasts, many of which will be resent. In addition, only the castles climb into the head ...
rayShootPos = playerObject.transform.position - transform.position;
hitShoot = Physics2D.Raycast(transform.position, rayShootPos, shootDistance);
if (hitShoot.collider != null)
{
Debug.Log(hitShoot.collider.gameObject.name);
if (hitShoot.collider.gameObject.name == "Player")
{
Debug.Log("Player Dead!");
needToShoot = true;
}
else
{
needToShoot = false;
}
}
else
{
needToShoot = false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question