clean up file structure
This commit is contained in:
parent
1318fdd9fc
commit
324e7d437b
28 changed files with 102 additions and 125 deletions
28
player/projectile/player_projectile.gd
Normal file
28
player/projectile/player_projectile.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
class_name PlayerProjectile
|
||||
extends Area3D
|
||||
|
||||
const SPEED := 20.
|
||||
var _initialized := false
|
||||
var velocity: Vector3
|
||||
var health: int = 1:
|
||||
set(v):
|
||||
health = v
|
||||
if v == 0:
|
||||
queue_free()
|
||||
|
||||
func _ready() -> void:
|
||||
body_entered.connect(func(body: Node3D):
|
||||
if body.has_method("hit"):
|
||||
body.hit(self)
|
||||
health -= 1
|
||||
)
|
||||
|
||||
func init(dir: Vector3) -> void:
|
||||
_initialized = true
|
||||
velocity = dir * SPEED
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
position += velocity * delta
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
assert(_initialized)
|
||||
Loading…
Add table
Add a link
Reference in a new issue