Swing in correct direction
This commit is contained in:
@@ -58,11 +58,11 @@ public class Teo : MonoBehaviour
|
|||||||
// If ratbot exists and is within swing range, damage it.
|
// If ratbot exists and is within swing range, damage it.
|
||||||
// Calculate absolute difference between angles of ratbot and cursor
|
// Calculate absolute difference between angles of ratbot and cursor
|
||||||
if (ratbot == null || Mathf.Abs(Mathf.Atan2(
|
if (ratbot == null || Mathf.Abs(Mathf.Atan2(
|
||||||
ratbot.transform.position.y - transform.position.y,
|
hit.transform.position.y - transform.position.y,
|
||||||
ratbot.transform.position.x - transform.position.x
|
hit.transform.position.x - transform.position.x
|
||||||
) - Mathf.Atan2(
|
) - Mathf.Atan2(
|
||||||
Screen.height/2 - Input.mousePosition.y,
|
Input.mousePosition.y - Screen.height/2,
|
||||||
Screen.width/2 - Input.mousePosition.x
|
Input.mousePosition.x - Screen.width/2
|
||||||
)) > swingRangeDeg * Mathf.Deg2Rad
|
)) > swingRangeDeg * Mathf.Deg2Rad
|
||||||
) continue;
|
) continue;
|
||||||
ratbot.Damage(damageStrength);
|
ratbot.Damage(damageStrength);
|
||||||
|
|||||||
Reference in New Issue
Block a user