This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have an issue where I have an animationplayer on a node. it has a property track, animatedsprite track, and call method track. I'm trying to insert another node's position to the property track so that wherever the node is, it moves to that specific node. Here's what I'm trying to accomplish.
Theres a player node on the middle left of the screen and three enemy nodes on the right separated by 200 or so pixels in the y axis. The enemy nodes get instanced during runtime, not in editor, and right now, the property track has the transition of going from (0, 0) to (800, 0) then back to (0, 0). I thought the (0, 0) would refer to their separate starting locations, but they all teleport to the same starting location and do the same animation transitions.
So I'm basically trying to make the starting x and y values be the starting position of the enemy node and the ending x and y values be the position of the player node. But the animationtrackkeyedit only has numeral inputs for the x and y value. I combed through the animationplayer methods, but I haven't found a method that lets me access specific tracks' key's values, if there was a way to do that, I feel like it'll solve the issue. Another way I thought of was possibly making an animation node in the main game scene and add that animation node to the enemy node after its instanced in, but the editor doesn't show the animation node?
Any help is appreciated. Been stuck thinking about this for a couple of days

in Engine by (37 points)

1 Answer

0 votes

dug through the docs and found you can access the key values through node
example line code
enemy.animation.getanimation("attack").tracksetkeyvalue(0, 0, Vector2(enemy.rectglobalposition.x, enemy.rectglobalposition.y))

by (37 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.