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)
|
||||
1
player/projectile/player_projectile.gd.uid
Normal file
1
player/projectile/player_projectile.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c1owlhp4be7wi
|
||||
24
player/projectile/player_projectile.tscn
Normal file
24
player/projectile/player_projectile.tscn
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[gd_scene format=3 uid="uid://beruy087nlwfu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c1owlhp4be7wi" path="res://player/projectile/player_projectile.gd" id="1_0gc0p"]
|
||||
[ext_resource type="PackedScene" uid="uid://yri7p15m8l1u" path="res://utils/lifetime/lifetime.tscn" id="2_73r22"]
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_wqvto"]
|
||||
radius = 0.25
|
||||
height = 0.5
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_0gc0p"]
|
||||
radius = 0.25
|
||||
|
||||
[node name="PlayerProjectile" type="Area3D" unique_id=966789634]
|
||||
collision_layer = 0
|
||||
collision_mask = 12
|
||||
script = ExtResource("1_0gc0p")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=2116862847]
|
||||
mesh = SubResource("SphereMesh_wqvto")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=908451103]
|
||||
shape = SubResource("SphereShape3D_0gc0p")
|
||||
|
||||
[node name="Lifetime" parent="." unique_id=631221358 instance=ExtResource("2_73r22")]
|
||||
Loading…
Add table
Add a link
Reference in a new issue