Guns spin and die and self destruct on impact

This commit is contained in:
2024-10-27 18:30:18 -07:00
parent 73ab694f7c
commit e3a96303bc
3 changed files with 11 additions and 5 deletions

View File

@@ -3,9 +3,15 @@ using UnityEngine;
public class Gun : MonoBehaviour public class Gun : MonoBehaviour
{ {
public float damageStrength; public float damageStrength;
void OnTriggerEnter2D (Collider2D hit) { void OnTriggerEnter2D (Collider2D hit) {
if (hit.tag == "Player") { // Damage player and destroy self on impact
if (hit.tag != "Player") return;
hit.GetComponent<Teo>().health -= damageStrength; hit.GetComponent<Teo>().health -= damageStrength;
} Destroy(gameObject);
}
void Update() {
transform.Rotate(new Vector3 (0, 0, Time.deltaTime * 1000));
} }
} }

View File

@@ -30,7 +30,7 @@ Transform:
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View File

@@ -52,7 +52,7 @@ MonoBehaviour:
damageTimeoutSeconds: 0.5 damageTimeoutSeconds: 0.5
health: 10 health: 10
gun: {fileID: 5213001249979318174, guid: 98b57b15498e96a9c8fe56264ac2ef63, type: 3} gun: {fileID: 5213001249979318174, guid: 98b57b15498e96a9c8fe56264ac2ef63, type: 3}
throwSpeed: 41.61 throwSpeed: 500
--- !u!212 &480941680556316754 --- !u!212 &480941680556316754
SpriteRenderer: SpriteRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0