Guns travel towards player

This commit is contained in:
2024-10-27 18:15:14 -07:00
parent 89953e7cd6
commit 73ab694f7c
3 changed files with 8 additions and 4 deletions

View File

@@ -15,9 +15,13 @@ public class GunThrower : Ratbot
}
void ThrowGun() {
GameObject thrown = Instantiate(gun);
GameObject thrown = Instantiate(
gun,
transform.position,
Quaternion.identity
);
thrown.GetComponent<Rigidbody2D>().AddRelativeForce((
transform.position - player.transform.position
player.transform.position - thrown.transform.position
).normalized * throwSpeed);
thrown.GetComponent<Gun>().damageStrength = damageStrength;
}