Godot_Bouncy_Ball_Prototype/Player/shooter.gd

19 lines
417 B
GDScript3
Raw Normal View History

2023-09-03 14:32:48 +00:00
extends Node3D
@export var ball_scene : PackedScene
2023-09-05 00:28:09 +00:00
var count = 0
2023-09-03 14:32:48 +00:00
func shoot(spawn_position ,direction = Vector3.FORWARD, strength = 7):
2023-09-05 00:28:09 +00:00
count += 1
print(count)
2023-09-03 14:32:48 +00:00
var ball = ball_scene.instantiate()
ball.linear_velocity = direction * strength
ball.position = spawn_position
# Add the ball to the highest node of the scene so it's not parented to the player
get_tree().root.get_child(0).add_child(ball)