I want this to be civil, and I am not trying to cause drama so please hear me out...

I have an ongoing issue...(granted it has not been that long ago that I posted this) here if you don't click on it, that's fine...It's regarding swapping out animations inside an AnimationTree...

The problem I have is that no one seems to either a) know what I mean or.. b) know how to do this.

So now I am in kinda a crossroads. Either I go back to my planning stage and also rework the animations which may take 2 weeks or so(I have a regular day job and family ofc) or I change game engines....

I'm really serious about this. I really want to use Godot...but at the same time I want to progress work on my project and if I cannot do this in Godot I will be forced to another engine...so please take a look at the thread linked above and let me know if this is "just not possible in Godot" or give me a solution...I really really want to stay with Godot, please keep that in mind.

I have a rough idea of how it might be possible, though I have never used the AnimationTree node myself. I’ll try to mess around with the AnimationTree and see if I can find a solution later today.

If you haven’t already, I’d suggest posting this question on some of the other Godot community pages (QnA, Facebook, Reddit, etc), since it is possible someone there might know and be able to help.

I would really appreciate any help, thank you. I tried checking FB, but with it being FB there a more than one Godot page...made me very uncertain which I should try. I've also started to think about other options, like I stated, I want to stay with Godot. I have used unity..it's fine but I prefer the slight performance gain of unreal...but such a horrible concept...either nodes are too messy or c++ is just overkill, but, I wont make any solid decisions yet..I'll think on it over the weekend.

I messed around with the code a little bit, and I found the following changes the animation (using Godot 3.1; script attached to the AnimationTreePlayer node on the Platformer demo from the Godot demo repository):

extends AnimationTreePlayer

var _animation_player;
var _animation_to_change_to = null;
var _old_animation = null;
var _change_to_new = true;

func _ready():
	_animation_player = get_parent().get_node("AnimationPlayer");
	
	#_old_animation = animation_node_get_animation("anim 5");
	_old_animation = _animation_player.get_animation("shooting_standing");
	_animation_to_change_to = _animation_player.get_animation("jump-up-cycle");
	

func _process(delta):
	if (Input.is_action_just_pressed("Change_Anim")):
		
		if (_change_to_new == true):
			animation_node_set_animation("anim 5", _animation_to_change_to);
		else:
			animation_node_set_animation("anim 5", _old_animation);
		
		print (animation_node_get_animation("anim 5"));
		
		print ("Animation changed!");

The only issue I have not worked out, and will have to mess around with later, is getting the animation to change back. On the plus side, it seems possible to change the animation through GDScript. :smile:

On a Meta level, I think there are too many different places to ask questions about godot. I look at these forums, the official Q&A, and Reddit. I've seen some questions on StackOverflow and Github, and probably many other places (like Steam).

such a huge fragementation means some questions go unanswered. I can't offer a solution though, cept maybe re-ask every few days and link to other forums where you ask the question.

@TwistedTwigleg :First, I really appreciate you looking ito this...on your time, for my problem....but there are a few things.. I was avoiding using the AnimationTreePlayer, as it is depreciated...or so I thought?? I had already seen the docs and did try animation_node_set_animation(String,String)...I think the only problem I have is getting the proper pointer to the specific animation node in the AnimationTree. If you look in the image In the link in my first thread you will notice I am trying to change the animation going into a "one shot"....it's only the one shot animation I want to change...I don't need to change animations..I can already change them with the play() function inside a switch case or match, excuse me, I don't think I will ever stop calling it a switch statement.

@novaleaf : You are right. That is a problem. I hate to say it, but the good thing about unity documentation is there is always a small piece of example code to show how something works...it's very basic, but it makes sense.

AnimationTree is just a refactored and up to date AnimationTreePlayer, anything the old one could do the new one should be able to do too and better. Plus then some. At least that's the theory here.

Also note that the new Tree supports state machines, I recon for the kind of use you are trying to make, that might be the best way to go. Notice also that the if statement inside of _process() in @TwistedTwigleg's example is essentially trying to implement a simple state changing mechanic too.

I understand that you are used to probably implementing state changes in code from other engines, but really using the AnimationTree's state machine will make life a lot easier and it's not too different from the animation state machine in for an example the UE4, so to an extent the experience can carry over to at least one other significant engine too.

@justinbarrett said: @novaleaf : You are right. That is a problem. I hate to say it, but the good thing about unity documentation is there is always a small piece of example code to show how something works...it's very basic, but it makes sense.

On that note, you can always open an issue on the documentation issue tracker: https://github.com/godotengine/godot-docs/issues

I gotcha, I know what a state machine is and yes, I am changing states by "hand"... I basically am checking what the player is doing, and if he is on the ground etc...and then I set his "anim_state"..the rig just reads if this has changed and "switches(match)" it's "state" the reason I do not use the built in state machine is it would be hell to look at....even with only 4 weapons and 4 spells(and the given move, jump etc) each one has several different variants....it would just look illegible... doing that would be fine for a simple platformer or even a shooter.

Maybe you are right, but I have not seen any example that points to the built in state machine handling the way I want to have my player move. I also feel I have more control in code.

if you DO know of a complex example, I would be more than willing to look at it.... I feel like I may seem to be making a lot of excuses, but the fact is I set out to do a certain thing...design is important. If I cannot follow that design, it's not going to be "up to par"...and I just wont be happy with that....

but like I said, I'm not doing anything drastic until monday. I will also go look more closely at the AnimationTreePlayer methods, setters etc..

ok, there is a lot of stuff in there, but I am getting an error just by using "get_nodes()", I get a non existent function error. All I am doing is loading it into a var.

another question: in the following function what is the type for animation,


 animation_node_set_animation ( String id, Animation animation )

the second param...I mean it's clearly "type of : Animation" :) but does that need to be a preloaded resource, is it simply a string or do I need to get an index from a pre-built list from the animation player...

you have to excuse my very "beginner level" questions, but I am not familiar at all with the api or the engine...the project I made I did in about 3 weeks, and that is only when I was not working or taking care of my family.

From what I remember, the Animation type can be retrieved from an AnimationPlayer node using the get_animation function. You can export an Animation resource to the Godot editor using export (Animation) var test_animation, but I couldn’t find a way to tell it what animation I wanted to use in the Godot editor.

Also, no worries on the “beginner level” questions. That’s how you learn :smile:

Well, Godot is a little rough around the edges, but hopefully you can find a method to make it work. For me, I want to support open-source development (and it helps Godot editor works perfect on Linux), and it's fun to try something new and build a community. If you just want to ship a game, then Unity is way more mature and bigger, but that is not as fun to me. Same way Windows will "just work" and support more hardware/software but Linux is way more fun to tweak.

I haven't tried to use animation in Godot yet, I was trying to finish my character model first, but let me set aside some time today and do some quick tests. I'm pretty confident there is a way to get it to work. If it doesn't that would be a huge red flag and I would agree a blocker.

Also, you may want to post on Reddit ( https://www.reddit.com/r/godot/ ) the community there is a lot more active than the forums. Personally, I like the forum setup better for long conversations or more lengthy posts, but Reddit is for sure more active. There are 31K members on the sub-reddit and just 1K joined in the last month. So maybe you will find luck there.

I think if you save out an animation as a resource it might be able to take that, but I am still getting the invalid call....so I am at a loss.

There is one glaring issue I think with the anim tree in general....each socket only accepts one input, and there can only ever be one output...

something just dawned on me as I was writing this...isn't it possible to use a multi-dimensional blend space to mix into the one-shot node? If yes, How many can one mix in there...I have @16 ATM.

@cybereality said: Well, Godot is a little rough around the edges, but hopefully you can find a method to make it work. For me, I want to support open-source development (and it helps Godot editor works perfect on Linux), and it's fun to try something new and build a community. If you just want to ship a game, then Unity is way more mature and bigger, but that is not as fun to me. Same way Windows will "just work" and support more hardware/software but Linux is way more fun to tweak.

That is exactly why I want to stay...I'm pro Godot...I may not be very competent in it yet, but I would prefer to use it over unity or unreal. I've made games in Blender and unity before...also many other going back to 3DGamestudio and even dark basic...

making a commercial game is not at all my motivation. I always set out to make something free and ask for donations, but I mostly do it for my kids... I don't have a lot of money(none actually :) ) and this is one way I try to both entertain them and show them that you can make your own way and your own fun...I can't buy them games so...I make them, it only costs some time. I'm probably not leaving(Godot)...I just really don't want to.

worst case scenario, I have to redesign the game and start over...it's not that far in but I hate to quit things.

well it looks like the "blend space 2D" accepts just about all of them....I have not put them all in yet...but they are there. I can move the cursor to the appropriate animation and it seems to work...a few of the animations are a bit off, but that's my fault. Now, I just need to figure out how to access the [x,y] corrds of it in code.

AnimationTree.set_blend_point_position ( int point, Vector2 pos )

but I'm missing how to get that specific node(not a node like an object) from inside the AnimationTree...

@justinbarrett said: something just dawned on me as I was writing this...isn't it possible to use a multi-dimensional blend space to mix into the one-shot node?

Yes, it should.

@justinbarrett said: If yes, How many can one mix in there...I have @16 ATM.

Haven't tested the limits.

Using the state machine for the highest level of the animation tree is not mandatory, just what I'd recommend, however within that state machine¹ you would be able to create the same kind of BlendTree/structures as subsytems as you are showing in the other topic. Each of those BlendTrees can be simpler then. Hopefully you see where I'm going with this.

¹:

I've seen that video, I know what a state machine is...I've got that down pat since 2001. We could be misunderstanding one another...

either you are trying to tell me there is additional functionality, something NOT shown in the video. Or maybe that it is more easily accessible in code??? I don't know.

I find it simpler with the switch statement, for every state you can dictate a sound to play a specific cost to stamina for example all kinds of things. You simply do not have that flexibility unless you code it...

please tell me if I misunderstand. I think you are trying to help, but more than helping you are simply pushing me in another direction....at least this is how it feels. Nearly every answer you provided pushes me to use the built in state machine and does not address the question I actually asked. Wow that sounds offensive, please take no offense. I do realize you are taking your time to deal with my issues.

ok, I got it. I need to tinker with it and make it more functional but basically I got it working.

using the blend tree 2D I was able to add all the animations I needed and with the following code I can activate the "one shot", then set the animation....it's backwards now, but I will get it all ironed out.

anim_tree.set("parameters/attack_one_shot/active",true)
anim_tree.set("parameters/attack_tree/blend_position",Vector2(0,1))

I want to thank everyone who gave me a hand...I'm relieved that this is taken care of.

Great end to the story. That is the thing I have found with Linux or open-source in general. Sometimes you are trying to do what seem like basic things, and no one knows the answer. But there is usually a way to get it to work, and it's really satisfying to figure it out. Cheers.

@justinbarrett said: I've seen that video, I know what a state machine is...I've got that down pat since 2001. We could be misunderstanding one another...

either you are trying to tell me there is additional functionality, something NOT shown in the video. Or maybe that it is more easily accessible in code??? I don't know.

It automates certain things and makes certain others easier than doing them manually.

edit:

@justinbarrett said: I find it simpler with the switch statement, for every state you can dictate a sound to play a specific cost to stamina for example all kinds of things. You simply do not have that flexibility unless you code it...

Watch the video again, then press replay. Pay extra attention to what he mentions off-hand towards the end(well, theres a couple of things he mentions).

@justinbarrett said: Wow that sounds offensive, please take no offense. I do realize you are taking your time to deal with my issues.

Absolutely non taken and yes, I'm recommending that you take a closer look at the state machine already in there. Rolling your own is most definitely doable, but sometimes you just don't have to reinvent the wheel.

edit 2: by no means am I saying that you have to use it though, just learning to use/understand it though might give you more and potentially better ideas toward rolling your own if you still are adamant to do so.

@justinbarrett said: ok, I got it. I need to tinker with it and make it more functional but basically I got it working.

using the blend tree 2D I was able to add all the animations I needed and with the following code I can activate the "one shot", then set the animation....it's backwards now, but I will get it all ironed out.

anim_tree.set("parameters/attack_one_shot/active",true)
anim_tree.set("parameters/attack_tree/blend_position",Vector2(0,1))

I want to thank everyone who gave me a hand...I'm relieved that this is taken care of.

Awesome! I’m glad you were able to find a solution to the issue! :D

I was meaning to come back on and trying to help find a solution, but it looks like you and the others figured it out.