- Home /
Question by
szwajcowskibruno · Sep 15, 2019 at 05:19 PM ·
aiaimaiming
I have some issues with my enemy aiming script
I have two methods at my enemy script, which are called every frame.
void AimAtEnemy()
{
if (seeEnemy)
{
shootPoint.transform.LookAt(enemy.transform);
}
}
public void SeeEnemy()
{
Vector3 lookBefore = transform.rotation.eulerAngles;
shootPoint.transform.LookAt(enemy.transform);
if (lookingCone.seeEnemy)
{
if (Physics.Raycast(shootPoint.transform.position, shootPoint.transform.forward, out hitInfo, lookRange, lookLayer)) //Check is there any obstacle
{
if (hitInfo.transform.name == enemy.transform.name)
{
seeEnemy = true;
}
else
{
seeEnemy = false;
}
}
}
shootPoint.transform.rotation = Quaternion.Euler(lookBefore);
}
It should make enemy look at me when i enter his "looking cone" and if im not behind a wall. It work in half. Enemy aim ta me when these conditions are true but when one of these conditions turn false, enemy start to look at position where he was looking at start of game.
Comment
Your answer
Follow this Question
Related Questions
I need help on how to make a Aim Assist aka Auto AIm 3 Answers
Procedural character aiming 2 Answers
How do you do this :( 1 Answer
Shell Drop and Aiming 1 Answer
I cant aim Can anyone HELP? 0 Answers