x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Variable with "actor as selected type" always returns null, why?

Ok so the variable Main is referencing an actor in the level. There is only one instance of that actor. Now I CAN read a variable "Counter Running" from it just fine but then I have to Set a variable I always get "Accessed none' as an error message once I return to the editor. So I know that Accessed none means that the variable is Null and contains but how can it be null if I have just read from it? I basically can read a variable in that blueprint but not write...

alt text

Product Version: Not Selected
Tags:
more ▼

asked Aug 14 '15 at 09:17 PM in Blueprint Scripting

avatar image

TobiasRipper
103 44 48 69

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Have you tried doing the same but using a standard "Cast to" class, with your variable selected instead of Self?

I'm assuming you can see the variable because you've marked it as public, but doing cast to, you can set/get anything within a class without any issues that i'm aware of.

more ▼

answered Aug 15 '15 at 06:46 AM

avatar image

MrGrr
986 34 3 41

avatar image TobiasRipper Aug 16 '15 at 04:39 PM

I have actually been trying to figure out the casting system for some time and the only object I was able to cast to was the player blueprint because when you cast to it, you can set target as "get first person character" at index 0 but for custom actor blueprints I have to set a target, which, come to think of it can really only be done with an array and reading the array for an object id.

avatar image eXi Aug 16 '15 at 05:22 PM

ehm, no. The problem is that you didn't understand the whole topic by now no offense.

Casting means, that you convert an Actor or what ever Class you got your fingers on, to another class. An example:

Your Player as well as an Enemy are from the "Actor" class. They are both childs of the same parent. Now you have an Overlap Event for a Trap that should only damage the Player, but not the Enemy.

The Overlap event reacts to every Actor, so as "OtherActor" you get the Overlapping unit as an Actor Class Instance. You have no idea if it is your Player or the Enemy. If you now try to cast that to the PlayerBlueprint Cast, the Cast will only succeed if the Player is really the one jumping into the Overlap. The Cast will fail for the Enemy.

Casting is also important to get specific variables that you've created in your Child Classes. Actor Class for example doesn't know about Character specific variables. But if you cast it and the Actor is really a Character, you can access the Variables.

For your NULL or Accessed None problem:

A Pointer or Reference variable can be empty (NULL). If you create it and don't fill it, it will be empty and you shouldn't be able to use it like you want (and you will get the Accessed None Error). It doesn't matter if you have an Instance of that class in your Game at the time. You will need to fill the Variable with a reference of that Actor. Either by overlap event, raycast or other things.

You COULD use "GetAllActorsOfClass" and get the 0 index of that array, but that is the worst thing to do! If the Actor is already placed in your scene before you start the game, you can get the reference by using the LevelBlueprint. It is the only Blueprint where you can get a direct reference by selecting the actor and rightclicking in the event graph.

avatar image eXi Aug 16 '15 at 05:22 PM

Important classes like the PlayerCharacter can be accessed by "GetPlayerCharacter" at a specific index. The Number is only important if you have multiple players with a split screen or so. As long as you play online/lan or singleplayer, you can just take "0" for that.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You only selected the Type. You said you know what "NULL" means, so you should know that you have to fill the variable before using it. It's weird that you can get any value of it. Fill the variable and only use it when it is not NULL or at least use an "IsValid" to make sure that you don't use it when it's NULL.

Your "There is only one instance of that actor" doesn't do anything. There could also be 2 or 0. You need to get the reference of this one actor and save it (set) to the variable. Otherwise you will get the Error.

more ▼

answered Aug 16 '15 at 04:26 PM

avatar image

eXi
6.8k 332 184 464

avatar image TobiasRipper Aug 16 '15 at 04:35 PM

It's weird, I've pointed that tree variable is not just an actor but the exact blueprint and yeah, I am able to retrieve the variables from it.

I ended up doing an array and just finding the instance at index 0 to retrieve that bp instance id. I still get an null error but now I'm able to get and set variables anyways. This looks like a bug now.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question