Download

Anim BP for NON PAWNS - How do I get a reference of the main BP that is using an animation BP?

HI,

I want to make an animation BP around a non character/pawn

is it possible ? how do I get a reference of the main BP that is using the animation BP ?

thx for your help

image

Doesn’t GetOwningActor work? I’ve never used it myself…
Edit:
Ho, and you can’t cast from “self”. That would be the anim blueprint. Cast from TryGetPawnOwner (for a Pawn) or GetOwningActor (for an Actor).

could have swore I tried own actor in the search bar

thx it appears to not complain anymore :slight_smile:

now, none of beginplay/initilaize seem to run

my crane variable does not get set

Try “Event Blueprint Begin Play”.

I’ve never used that event “Initialize Animation”.

I’ve used this workaround

But why? The event “Blueprint Begin Play” didn’t work?

You don’t. Ever.
A) that’s bad coding.
B) that’s bad engine use.

C) it’s always the actor that manages the animation BP, because the animation BP is essentially a child of it.

From the actor, pull the skeletal mesh, from the skeletal mesh, pull the animinstance, from the anim instance do the Cast. Store the variable.
Now you can use it directly when applying things and checking for variables.

If you want reusable code, create a component and stick the code in it.
From the component “owner” or “parent” would both work and you can repeat the process in C…

You don’t. Ever.

Hum…I personally don’t like evers in programming.
If you know that the ABP will be only used in a specific actor, keep it simple, go ahead and cast to your BP_PawnXX.

Setting ABP properties from the Actor causes the same dependency problem. You make the actor dependent on the ABP, so you can’t use another ABP on that actor. Besides, doing this will decentralize the act of setting the ABP properties. I like to set this properties all in the same place, and that place is the ABP.

Personally, I would rather create an interface and cast to that interface in the ABP. Who ever wants to use that ABP, must implement that interface.

But hey, I’m new to UE, maybe I’m doing it all wrong.

Except like I said.
You don’t Ever.
It prevents FastPath optimization - among other things like requiring you to pass variables back and forth between blueprints.

The interface can work, but again, on the character.
And the implementation of the interface has to be copy pasted in - so in order to avoid that, you use the component like I mentioned before…
Unless you like to copy paste - or you only need it on 2 blueprints. then there’s no point in making it into a component, I guess.

nop

I found the way I do it in many examples, people do it that way apparently
as long as it works, …
UE can be really complicated to master and to make it work as I want so…

Like I said, if you know that the ABP is specific to an actor, go ahead and cast it in the ABP.
No need to complicate…

Until you need to exit a prototyping stage, sure.
Then you have to start from scratch…
Good luck.

I really don’t understand why. Sorry. Could you explain please?

I think the situation in discussion is:
Actor X exclusively uses ABP Y where X is the main character on a platformer for instance.
This ABP will not be exposted to third parties and it will not be used in other actors.
What’s the problem in casting Actor X in the ABP?

Maybe there’s a reason I’m not aware of as I’m new to UE. Something I should be careful with.

In theory, that would be ok, until you try to optimize for fasth path.

Read it carefully and try it.

Also.
As I probably already said.

The actions that bring about variable changes are in the actor BP. All you are doing in the animation BP is creating a parroting system that wastes resources.

There’s no reason at all to do any of it.
You set the variables of the animation BP directly from the character when required.

The statemachines will all function as expected. And you will also have the blueprint empty so that no resources are wasted.