Tween animation problems

godot 4.3 rc 2

alright so i decided that animation player for this project may not be good and instead have decided to use tweens but theres something very wrong here

extends Control
@onready var absorb = get_parent().get_node("Move_layer/absorb")
@onready var Enemypos = get_parent().get_node("Cast/Enemy/Enemy_sprite")
@onready var Playerpos = get_parent().get_node("Cast/Player/Player_sprite")
func Animation(entity, move):
	match move:
		"Absorb":
			match entity:
				"Player":
					absorb.show()
					var tween = get_tree().create_tween()
					absorb.position = Enemypos.position
					#set tween delay to 10 for debugging
					tween.tween_property(absorb,"position",Playerpos.position,10)
					await get_tree().create_timer(.5).timeout


sorry if im tiring yall with posts lol

bump!!!

I would say most of your game is Control nodes, I am not too sure how well those react to modifying position, especially if they are child of a container.

Could you print the positions of the player and the enemy? Could you explain what type each of these variables (absorb, enemypos, playerpos) are?

Not 100% on this but try changing Enemypos.position and Playerpos.position to Enemypos.global_position and Playerpos.global_position instead.
Position gets the position data of a node relative to its parent node, if you just tell another node to head there it’ll go wildly off course depending on how your scene tree is structured. global_position works based on the co-ordinates in the editor.

2 Likes

absorb being the sprite 2d for the sprite i am moving Playerpos being the players sprite position Enemypos being the enemys sprite position

this worked i just had a return statement that cut off the rest of the function like an idiot lol

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.