rocket launcher shoots and explodes

This commit is contained in:
Derek
2024-07-31 23:27:22 -05:00
parent 30f8c138db
commit 6354dc2774
23 changed files with 2456 additions and 14 deletions

25
scripts/rocket.gd Normal file
View File

@@ -0,0 +1,25 @@
extends RigidBody3D
@export var explosion : Resource
var bullet_speed
var player_velocity
var bullet_damage
var player_position
# Called when the node enters the scene tree for the first time.
func _ready():
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
var explosionspawn = explosion.instantiate()
explosionspawn.position = self.global_position
explosionspawn.transform.basis = self.global_transform.basis
get_tree().get_root().add_child(explosionspawn)
queue_free()