2023-01-27 12:47:13 -07:00
|
|
|
extends Area3D
|
|
|
|
|
|
|
|
signal exploded
|
|
|
|
|
|
|
|
@export var muzzle_velocity = 100 # How fast the bullets are
|
|
|
|
@export var g = Vector3.DOWN * 20
|
|
|
|
|
|
|
|
var velocity = Vector3.ZERO
|
|
|
|
|
|
|
|
###### CHEATS
|
|
|
|
var godmode = 0
|
|
|
|
|
|
|
|
|
|
|
|
func _physics_process(delta):
|
|
|
|
# velocity += g * delta # Uncomment this for bullet gravity
|
|
|
|
look_at(transform.origin + velocity.normalized(), Vector3.UP)
|
|
|
|
transform.origin += velocity * delta
|
|
|
|
|
|
|
|
for body in get_overlapping_bodies(): ### THIS IS OLD LOGIC, REPLACE. I'D RECOMMEND TO CHECK BY GROUP AND NOT BY NODE
|
2023-02-07 13:22:31 -07:00
|
|
|
if body.is_in_group("human"):
|
|
|
|
print("Bullet hit a human player")
|
|
|
|
Global.playerHealth = Global.playerHealth - 10
|
|
|
|
self.queue_free()
|
|
|
|
if body.is_in_group("AI"):
|
|
|
|
print("Bullet hit an AI player")
|
|
|
|
body.queue_free()
|
2023-01-27 12:47:13 -07:00
|
|
|
self.queue_free()
|
|
|
|
else:
|
2023-02-07 13:22:31 -07:00
|
|
|
print("Bullet hit something else")
|
|
|
|
self.queue_free()
|
2023-01-27 12:47:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Shell_body_entered(body):
|
|
|
|
emit_signal("exploded", transform.origin)
|
|
|
|
queue_free()
|