0 votes

In the official Godot fps tutorial, https://docs.godotengine.org/en/3.1/tutorials/3d/fps_tutorial/part_two.html, a lot of things are done in code, that would be done in the editor if you were using unity. For instance, when setting up animations in the tutorial, a dictionary variable is put in the code that lists every animation and then what animations can be played after the animation is finished. then it has a dictionary for every animation and it's speed! In unity, this is done with a node system, and there's a file for each animation which has a speed variable among other simple settings, and I think that's a much more efficient way of doing it. putting all of it in the code, is confusing, and it's a lot of repetition. Is this the only way of doing it in godot?

asked Oct 17, 2019 in Engine by Millard (103 points)

Thanks, this is what I needed, I'm not quite sure how to call the animations in the tree with code, but I'm sure it can be done. I'm not sure why the fps tutorial did this all in code when using the animation tree would probably have been a lot easier. The one thing I would like to know, is how would I connect a state animation node to another state animation node, but make it so the transition only happens if I call it in the code? (unity can use a boolean, or an int)

Well at least the tutorial makes you understand the value of Animation tree :D

For playing animations I use:

func _ready():
    active = true
    playback = get("parameters/playback")
    playback.start("idle_armed")

And then I use

playback.travel('run_armed')

To travel to another node.

Thanks for the help, I am using gdscript, and I think what you are using is C#, I think I can transfer it, but if you could put it up in gdscript as well, that would be great. :D

P.S, what does "Travel" mean?

I'm using gdscript and that is gdscript code :)

Oh sorry, I forgot to mention, I use state machine, you define states (animations) and you travel from one to another. Very simple concept. The enginealso interpolates between states so it seems very smooth.

https://godotengine.org/article/godot-gets-new-animation-tree-state-machine

oops, just shows how new I am to Godot. :) Just to clarify, does your example code tell the state machine to start playing "idle-armed" and then when it is finished to start the animation process over again, starting at "run-armed"?

Kinda, it tells it to play idle-armed at the start of the scene. You also have animation player node where you can define whether the animation is repeating or is played only once. So it's stuck in that state until we tell it to travel to another state. If two states are not connected directly it will travel through closest path (for example you don't want to connect "idle" and "shoot" directly, you want to have "aim" state in the middle). It's best if you check some demo project or tutorial.

Check this one, it's for 2d, but the concept is the same.

https://www.youtube.com/watch?v=CPDlaKWnQPM&t=182s

Thanks for the help :)

1 Answer

+1 vote
Best answer

The Animation Tree might be what you're looking for: https://docs.godotengine.org/en/3.1/tutorials/animation/animation_tree.html

answered Oct 17, 2019 by varkatope (46 points)
selected Oct 17, 2019 by Millard
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 How to use this Q&A? before posting your first questions.