rocket launcher shoots and explodes
This commit is contained in:
25
scripts/rocket.gd
Normal file
25
scripts/rocket.gd
Normal 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()
|
||||
Reference in New Issue
Block a user