Beginner Accessed none Question

I’m used to getting Accessed nones in UDK, but I’m not sure what to do in this blueprint. I get Accessed None ‘K2Node_DynamcCast_AsThird_Person_Character’ error message when I close a game down.

I’m guessing it happens because for a couple of ticks my character no longer exists?

So what node am I supposed to connect where the cast fails? Or how do I stop this from happening please?

Thanks

You could just add a branch from the get player controller to check it exists? I assume that the ThirdPersonCharacter cast is failing because the player character doesn’t exist first.

if a cast is in question like this, I usually just pull out of cast failed & use a ‘Print String’ node. it will let you know quickly if your cast is good.
(you can do this after the valid as well)

can’t tell much from your Screen Shot, if this is a construction script in your level BP, you might have problems getting a cast to your Character BP. you might have to find another method. one method is a ‘get all actors from class’ & some people like using interfaces as well.
it almost looks like you are trying to let the player create a spline in your game.

there’s a lot of good talent here in forums that love to help when they can, if you have more problems or keep having this one, post more info & SSs.

Hey there,

yes accessed none is just telling you, that you tried to use a NULL pointer. “GetPlayerCharacter” returns a Pointer to your character or a NULL Pointer.
In C++ you would always want to check your pointers before using them.

Like this pseudo code!



ACharacter* MyCharacter = GetPlayerCharacter();

if(MyCharacter) // or if(MyCharacter != NULL)
{
     //DoStuff with the Pointer
}


So since the “if” in BP would be the “Branch” node, you could use “not equal” (pull the return value of the GetPlayerCharacter and search for not equal)
and just leave the second pin of that node empty.

Or, and that is much better: Pull out the return value or any other Pointer and search for “IsValid”. There are 2 versions of IsValid. One returns a bool
and could be used with a branch again. And the other doesn’t return anything, but has 2 exec outputs with “IsValid” and “IsNotValid”.
You would want to use the second one and the “IsValid” output to be sure that the pointer is not null.

You should do this with every pointer to be sure that you don’t access null pointers.

Thanks for the help guys. I’ve played around with a few things but I’m still getting error messages.

What I’m doing is setting the spine of the pawn to face the direction pushed on the right stick. This works, but I’m getting this pesky error message each time I play. This is how it looks currently:

This is the error message i’m getting:

bab752ca4b49ec1b67e574c2a779e67b2603205b.jpeg

The print string the log warning is telling me to look at is the one connected to Cast failed on the Cast to ThirdPersonCharacter node. But the IsValid check is BEFORE CasttothirdpersonCharacter, so why would it fail if it’s already passed the validity check?

If I hook up Is Not Valid to the branch you see below it and it does the check -“is not equal to nothing” then I get the same error about the print screen connected to false.

In UDK i’d write:


if(something==none)
{
return;
}

Sorry for being a noob.
Thanks

hi again, will add some advice but keep in mind I consider myself a Novice at best but will still try to help, so…

  • the isValid is checking your GetPlayerCharacter not the cast, where you have it now
  • never seen that error message before but definitely not good, try unplugging the PrintString, it’s just really weird for this error to show like that
  • and have you tried a GetPlayerController node instead of the GetPlayerCharacter since you are trying to access input from the right stick - guess this wouldn’t be true if you stick is actually working tho’ (unless that is just a normal rotator then it makes sense)

that’s just from what I see from your update, if nothing still works add more detail about what type of BP (class) this SS is from & possibly where you use the stick input
certain types of BP don’t like communicating with each other
try some of these options, if not put everything back then repost if you need to. if I can’t help, there are others that might be of more help with more info

also I always try to pull of a node’s return value output to get a ‘Cast to’ node, especially if I am having problems like this.

Thanks ayretek I really appreciate your help. So I back tracked a little to make things super basic.

In my Event graph in my ThirdPersonAnimBlueprint I’ve made a function called TurnSpine which is tagged onto the end of the basic tutorial stuff:

51baa3dc1755c73bb44aada78655f97cfae00d27.jpeg

Then in the turn Spine function I need to cast to ThirdPersonCharacter because that stores the rotator I need to make the spine point in the right direction:

f53d1621b56ec93da14ac11a3da7eb8ff2dee715.jpeg

I was having problems getting my rotator from c++ to blueprints, as you can read here:

but anyway I call an event which sets My Right Stick Rotator in my Character EventGraph:

fb5bd5ada465c4fca6f7ba8884144a449a971549.jpeg

Even with a basic setup in my TurnSpine function where i’m just trying to cast to my character I still get this error:

I’d love to know why!

Thanks

EDIT: I can’t cast to controller because I don’t have one. I’m doing all my movement stuff in the “Character class”

Hm, if you diconnect that function etc, the error disappears right? So it is 100% these nodes that cause the null pointer exception?

Would you mind trying “Try Get Pawn Owner” instead of GetPlayerPawn? Also why is your second “IsValid” node not pluged into the NewParam?
I would try creating a variable that holds the Pawn and save the “Try Get Pawn Owner” in it. After that, i would check and use the variable.

Although it should work with the node itself, as long as the pawn is spawned. It is weired that he even calls the error, because it shouldn’t try
to call the cast if the pointer is null (that’s what the IsValid is for)…

thank eXi. I finally worked it out. In my Idle/Run state I using a float to control the influence the Transform bone has on the spine. When the player releases the right stick the value decreases over time and the spine goes back to resting in it’s normal position. I think the problem was I wasn’t checking if that value cast from my pawn was valid.

So in my Event graph I set the value to New Anim Amount, and check the cast is valid. This seems to have stopped the error message popping up :slight_smile:

feed4a77cdbd94dfe20cd1a8534ec7af18ccfa02.jpeg

Thanks everyone for the help!