Hello, I'm new in Godot and this is my first post/question/help :-)
In order to learn GDScript (Godot 3) I'm creating very small tests. Now I created a sphere in the scene 3D (using a rigidbody). It works, falls down and hit on the ground.
I simply wanted to create, via GDScript, several sphere instances when I press a key, so these new created spheres will be created in the sky and start to fall down like a long stack of spheres.
I use the "master" sphere to get the start position, but I cannot create new instances of this master-sphere.
I tried using new() , then instance(), etc.... but I always get errors.
This is one of my several attempts to create this test:
extends RigidBody
var ball
var ballInitialPos
func _ready():
ball = get_node(".")
ballInitialPos = translation
func _physics_process(delta):
if Input.is_action_pressed("game_space"):
var newBall = ball.new()
if(newBall == null):
print("Error - sphere not created")
else:
get_parent().add_child(newBall)
print(ballInitialPos)
Godot tells me "Invalid call. Nonexistent function new() in base RigidBody(Sfera.gd).
Please can you help me?
Thank you!