How to use BlendSpace in C++?

Hi,

Are BlendSpaces only usable through blueprints ?
I can’t find a single example of how to use them purely through C++.

Thanks

It is usually a matter of where to look. Generally Blendspaces are setup in the editor and utilized on an Animation Blueprint. I would suggest keeping it that way. However if you want a property that points to a Blendspace declare a UProperty of UBlendSpace and assign it from the editor. However if you are trying to trigger certain animations I suggest using a montage instead.

Node with “f” icon are binds of C++ functions and you should able to find it, usally they have same name just without spaces, also “Target” input type is usually class that this function belongs too. Search the name in API refrence

I tried that but didn’t find a single code example and was trying to ascertain if there were none before I tried manually. I guess it’s for the best if I stick with Blueprints.Thanks !

I guess you’re right, this doesn’t seem like a good idea unfortunately, didn’t want to have critical code on Blueprints, but this seems to be my only option. Thanks

What is the critical code you don’t want on blueprints? I tend to avoid doing this as well, code such as damage dealing etc but in some cases it is not easy to get around if you are using animation based weapon damage or something like that.

Recent study of the animation system left me pushing data into blueprints which drive the animation system. This is functional and while it adds some extra steps hooking up fairly basic animations does give flexibility further down the line.

In the case you are doing something such as animation based damage what I tend to do is build all the core functions in C++ and have the blueprint call them at the right time using animnotifies.

I also (especially if you are making a reusable library) will build fail safe functionality such as a timer that sets the character back to not attacking mode if it exceeds the time limit (along with a log notify that no attack animation was found).

That is the way I was trying to do this, exposing bools for blueprints to play different anims. Stil have to learn a bit more to do what I intend but it’s functional. I guess that if blueprints only read the data I feed them I can contain them and reuse them. Thanks !

That’s my reasoning now, should work.

TL;DR There is no simple way. Better stick to Blueprints for this.

It’s all about standardizing the way you are trying to do something. If all of your actors that use the animation blueprint have the same function in C++ you will do fine (a plus if you create an interface but UE4 interfaces are a separate massive topic as they are not intuitive to how you are used to using them…). Using the Event Notifies you can also have your Animation blueprint set data, using any standard functionality you have constructed within the C++ class.

For instance you can have an attack animation that when it beings you have an StartAttackNotify that calls a function MyPawn->StartAttack() which sets some attack variable to true. Then at the end of that animation you have a notify called EndAttackNotify that calls a function MyPawn->EndAttack() which sets the attack variable to false (or you can just do MyPawn->SetAttack(true) or MyPawn->SetAttack(false) )

Anyway hope this helps