i want to make a game for the godot wild jam 77. the game is about a lil dino that loves sugar and want to reach an lolipop at the end of the game (i still didnt code the lolipop rn) but some times the gets stucks because the level is too hard or impossible so they can switch to a devil(davil) that can fly but every second ure in the devil form u loose 2 worms ( in game currency ). I need help to get the player position _queue_free the dino or the davil (depends on wich the player is in rn ) and spawn the other one at the same exact position. So if u would help me it will be soo nice of u (if u need other screenshot or explanation feel free to ask dm me or ask me on this post 🙂
#need help finding the player position to change between my 2 character
3 messages · Page 1 of 1 (latest)
Hello. To get position of a node, you have position property which is position relative to parent node. If you need global position, its global_position.
To add node from code, you can do
var new_node := Label.new()
new_node.text = "Hello!" # set text to see the label
new_node.global_position = player.global_position
player.get_parent().add_child(new_node)
Note that Label is Godot' class. If you wan't to add your own, you need to name your class too, use class_name at the top of your script of your player/dino/devil or anything you want to reference for adding via code.
P.S.: i suggest to do queue_free when you will not need that node anymore, for example, when player pickups an item, it disappears forever from the stage (as its one-shot). But in your case, when player is expected to switch between forms, i would just use hide and show. For example, you can have multiple animated sprites, and show only one, the one which is active at the moment. This way you don't need to create node on the fly and no need to queue free the other.
ok ty i will try it but at the end u suggest to hide the player but if i hide the dino and play with the devil the dino will fall because he has gravity and not the devil( idk if that's clear) but again ty i will try it tomorrow