Hello, I made a laser beam that should hit the player, but it goes a little under the player:
This is the code:
private Vector3 GetPlayerPosition()
{
Vector3 pos = GameObject.Find("Player").transform.position;
return pos;
}
private float GetPlayerAngulation()
{
Vector3 player_pos = GetPlayerPosition();
Vector3 direction = player_pos - transform.position;
rotation_z = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
return rotation_z;
}
IEnumerator FireLaser()
{
while(true)
{
if (!is_first_attack)
shark_eye.GetComponent<SharkEye>().Fire(rotation_z);
else
is_first_attack = false;
yield return new WaitForSeconds(laser_reload);
}
}
This part: shark_eye.GetComponent().Fire(rotation_z); only instantiate the laser in the shark’s eye.
Thank you.