Guns travel towards player
This commit is contained in:
@@ -30,7 +30,7 @@ Transform:
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 2.2222223, y: 2.2222223, z: 2.2222223}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
||||
@@ -52,7 +52,7 @@ MonoBehaviour:
|
||||
damageTimeoutSeconds: 0.5
|
||||
health: 10
|
||||
gun: {fileID: 5213001249979318174, guid: 98b57b15498e96a9c8fe56264ac2ef63, type: 3}
|
||||
throwSpeed: 0
|
||||
throwSpeed: 41.61
|
||||
--- !u!212 &480941680556316754
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user