Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kinoko4Tsuki |
Just started using Godot engine yesterday and I’m liking the way it works. I’m trying to make a 2D Megaman-esque game with all the platforming & shooting. After using some tutorials, I found a way to spawn a scene (in this case, an image of an animated water bolt with collision) at the origin using this code:
const WATER_BOLT = preload("WaterBolt.tscn")
if Input.is_action_just_pressed("ui_focus_next"):
var waterbolt = WATER_BOLT.instance()
get_parent().add_child(waterbolt)
After using this code and finding it works, I added the next line, to spawn it at the Position2D node I had set up in the player scene:
waterbolt.position = $Position2D.global_position
This is where things broke. The game would freeze up, and the output would give me the error:
Invalid set index ‘position’ (on base: ‘Node’) with value of type
‘Vector2’
I’ve searched up a couple of tutorials on projectile spawned, and did some error searching, to no avail.
This is the original tutorial, linked to where the guy adds the lines of code similar to what I did: https://youtu.be/wRcGbQBq28c?t=663
I don’t know what to do here, the tutorial seems recent enough, and I don’t see any specific typos that would cause the error. Please try to help me with my issue.
Thanks!