Godot_Bouncy_Ball_Prototype/Player/shooter.gd

16 lines
377 B
GDScript

extends Node3D
@export var ball_scene : PackedScene
func shoot(spawn_position ,direction = Vector3.FORWARD, strength = 7):
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)