Godot Version
4.3
Question
Ask your question here! Try to give as many details as possible
I am new to Godot, and am trying to make a simple game where a moving ship fires a cannon. I am able to get the duplicates to go to the player. However,when I try to set the velocity of the duplicates, or try to just make them all the same velocity, they all move relative to each other, and do not start at the player. I have tried a few solutions I found on a few other forums. This is the code in its earlier state. It doesn’t seem to work whether I am attempting to change either the duplicate properties or the original object.
`extends CharacterBody2D
var cpl = preload(“res://assets/scenes/cannonball.tscn”)
@onready var timer: Timer = $Timer
@export var cannondirection = 0
var cannonspeed = 50
@onready var player: CharacterBody2D = $“…/player”
func fireCan():
var instancecb = cpl.instantiate()
instancecb.set_process(true)
instancecb.position= player.position
add_child(instancecb)
func _process(delta: float) → void:
if Input.is_action_just_pressed(“cannon”):
fireCan()
velocity.x = cannonspeed
move_and_slide() `
Any help is appreciated
-clarification: the behavior I experience is I fire the cannon, the ball shoots out, I fire again, after having moved forward, and the cannonball appears in front of the other cannonball, moving at the same speed, at the same distance the other ball was previously to the player.