Character reference thread-unsafe call. Even with a custom variable

Hi guys. I’ve been looking for a solution to this but I didn’t find anything. I’ve created a Character variable to access to the methods but the warning is still there.

What can I do?


What happens when the cast fails?

Use a boolean instead of an actor reference; any variables from other actors you need to access should be done in the event graph, not the animation graph. This is how it’s done in the default third person character:

Unsafe way:


Safe way (from third person sample):


2 Likes

Idk, the cast never failed

That was my old solution. But, I don’t want to create a variable for each variable my character has. I just want to use get them from my character.

Try and answer the question to yourself so you can actually learn something.
Doesn’t matter if it’s working. What if it did not?
What would the code you set up do in that case?

For what it’s worth the example given and the default templates are WRONG.
Yes, you read that right. The stuff epic gives you is an Example. Just that.

As a rule of thumb, the animation blueprint should have no code at all.

The character blueprint needs to take care of toggling or updating the animation blueprint variables that are then used by the state machines to animate.

No calculations, no casts, nothing at all except basic math and operators should be used in transition states.

This ensures that all the animations can take advantage of fast path.

There’s only one potential pitfall to it, and it is that you have to do things correctly when you plan to swap the animation blueprint on the run.
Not something that’s commonly done anyway. In fact unless you need to make something extra modular to re-use it you won’t need to worry about it.

All the variables for animation within the character will be tied to the animation blueprint cast - so changing the ABP permanently involves replacing the invalid variables (really this has only happened to me once in 3 years so, you won’t need to worry about it).

And, it’s obviously normal to have around 40 variables in an animation BP.

Try and keep it simple though.

Most times there’s no need to have multiple boolean it’s a common mistake.

People add a “crouched” and a “standing” and then need to manage both on and off states.
The better way would be to use one “pose” status to manage that - or better yet an int so you can do several states based on the integer (standing, prone, crouched, flying, etc).

First of all thanks for your advises. Ofc I tried to answer my own question and I actually did it. As you said, creating variables. But I thought it would be a better solution to just use getters from my actual character to get the variables, avoiding “duplicates”.
Besides, I asked this cause I saw at work how they manage the animation blueprint variables. They use the getter form but they didn’t have any errors.
Btw, I would appreciate a little bit more of “chill” on the first sentences!

While they are duplicates, they are safe to access from the animation graph. Accessing the character blueprint directly in the animation graph is not “wrong”, but it’s “unsafe,” hence, why you get a warning and not an error. This all has to do with how multithreading works.

  1. Do they have “Allow Multi Threaded Animation Update” disabled?
  2. What variables are they accessing? Some variables work without warnings.
1 Like

Yes but - the other way around.
So the variables only exist on the Animation BP - which uses them directly, and the character bp check/alters them directly.