How do I resolve the access none error when casting to an animation blueprint?

Very new to unreal, I keep thinking I’ve made some kind of very basic error but can’t figure it out.

I have a BoxTrigger in my level, and an animation blueprint with some animations set up. I wanted the blueprint to play an animation when a specific cube is overlapping the boxtrigger.

This is a screenshot of the BoxTrigger blueprint inside my level, and I’m trying to send the overlap data for the Grabbable_SmallCube to the Male_AnimBP using the Pointing function I made inside the Male_AnimBP blueprint.
The PointRef is the object variable I made for the Male_AnimBP and it seems I have to set the variable at BeginPlay to stop an access none error. Tried using GetGameMode pin for the cast to Male_AnimeBP but it says that it doesn’t inherit. Please help.

The easiest way is using “Is valid” node, it just cuts the line in the case something goes wrong

|s Valid Node works for this.

Many times you get accessed none because of order of loading and spawning actors.
You are never guaranteed that actors will be spawned and loaded in same order, so make code that can accommodate for that.

1 Like

So I don’t need to set PointRef at the start using Event Begin Play at all? I used an Is Valid node before, and printed a string to let me know if it’s not, and it was not valid any and every time I overlapped the cube on the trigger. Is there any more info I can give you to see if I made some other mistake?

Your Begin Play is currently setting PointRef to null, ergo the not valid problem.

To clarify, inside the Cast node in the Begin Play event, there’s a pin on the left that says “Object” and there’s a dropdown that says “Select Asset.” You need to select the asset you want to use.

I’m trying to select an asset, but I’m confused as to which asset to use. In the level, I basically have the boxtrigger, whose blueprint is the screenshot, the male_animBP which is the animation blueprint I made, and the grabbable cube from which I want the collision overlap data. I tried using the boxtrigger but it says ‘male_animbp does not inherit from’ boxtrigger, same for getgamemode/gamestate.

I have been also dealing with the whole None error myself. What I have learned is that your REF is empty. While you SET it on BeginPlay, your CAST doesnt have an attached object, so is casting ‘nothing’ to the REF. Thats my guess at least.

I would try to get the object part filled in, probably a GET of some sort. Here is an example:

Soemtimes there is an option in the dropdown, not sure in casting to an animation blueprint.

For me, getgamemode and any other asset I use gives the ‘does not inherit from’ error. That was the main question, I can’t find a GET which doesn’t give me the inherit error.

I have the same exact problem when im trying to set a REF to a Widget that is already created by some other process. Seems the only way you can SET a REF to Widget is when you create it.

For what its worth, the solution to my problem, was to move the variables off the Widget I was trying to reference, to the Game Mode BP.

My Game Mode BP is data only right now. Are you saying I should move the screenshot content, which is in BoxTrigger BP, to the Game Mode BP?

Not sure. I dont know enough about what your doing.

What is Pointing doing?

All right, so here’s a summary.

In the level, I have a box trigger, an animation blueprint, and 3 grabbable cubes. What I want to do is for the animation blueprint to play a pointing animation, when the grabbable cube collides with the box trigger.

Anim BP: I created an animation state machine with an animation Pointing, and in the event graph I set a boolean PointTrigger which is the condition for the animation to run inside the state machine. Next I created a function Pointing, which would pass the boolean PointTrue to PointTriger (PointTrue is an input inside this Pointing function, which I will set in the BoxTrigger blueprint).

BoxTrigger BP: I made the BP as per my original screenshot. On ActorbeginOverlap for one specific box. I call the function Pointing and set the boolean PointTrigger to true, which should activate the animation by means of PointTrue inside the Anim BP. To do that I needed an actor variable PointRef, which you see in the list of variables, where I set the variable type to Anim BP.

Now comes the problem. The Pointref needs a default value to work, or else it’ll show an access none error, for which I did the nodes you see in Event BeginPlay. But I can’t set the default value using the nodes you see because if I use Get GameMode or any other asset, I get an inherit error.

Hope I could explain it properly.

Update: I found the basic mistake, but I still can’t figure out how to transfer the data.
I directly put the animation blueprint into the level instead of a blueprint of the character actor class.
But how do I then transfer the boolean about the collision occuring from the boxtrigger blueprint into the animation blueprint? I have the function created inside the animation blueprint, I assume I can cast that function into the boxtrigger blueprint, but even then the access none or inherit error remains.

Final Update:
Here’s what worked for me.

  1. Make sure to use the object NPC actor with the animation blueprint set in it’s skeletal mesh, and NOT put the blueprint itself into the map. (Noob mistake but still better to specify)
  2. Create function in animation blueprint, which takes a value from the box trigger blueprint using the ‘cast to’ node. To do that, you need to create a variable with the variable type as the animation blueprint. Access none error will occur since this variable has no default value when the level starts, so the next step is to set a value to the variable.
  3. Set this variable value in the LEVEL BLUEPRINT, and NOT in any of the other blueprints. Since the level blueprint has a reference to all the variables inside every blueprint (as long as it’s set to public), setting there is easier and will not give any default value error.
  4. Here’s a screenshot of the level blueprint for reference. The variable PointRef is set so that it has no access none error when used inside Box Trigger,