Accessed none trying to read property from function: Noob physics and cameras?

Hello Unreal friends,

My noob project has this error on Play:

Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_BreakHitResult_HitComponent from function: ‘ExecuteUbergraph_SideScrollerCharacter’ from node: Set Collision Response to Channel in graph: EventGraph in object: SideScrollerCharacter with description: Accessed None trying to read property CallFunc_BreakHitResult_HitComponent

I am following tutorials that I slightly modified and I have no idea what I’m doing. I am trying to use a camera as an “Object camera” to be able to find and pick-up physics objects to my third person character (template blueprint). Would you consider using multiple cameras like this even for testing purposes? I suspect its highly demanding (CPU) way to get things done but I just want to build things.

Using multiple cameras seems to cause a bug where sometimes my project plays from one camera or the other

I have a first person view camera, physics objects pickup blueprint in my other projects. I would like to adapt one of these to a third person character - even if it appears the character has “magic powers” or “the force” to pick things up at first, for now. (and lacks animations)

I am an artist, I suck at BP. I appreciate all coders who have the time to help!

Your “Add Impulse” and “Set Collision Response to Channel” nodes try to read from hit events hit result but not when the actual hit happens. It will be null and that’s why you get an error.

Due to how blueprints work, you cant hop back and forth in time and expect values to be there, they are only there when the original execution wire on that path is live.

To fix that, you need to store the reference of the hit component into variable when the hit happens and then use that variable for your later actions.

Thx for responding,

I am a very visual person, can you tell me more specifically what to do?

I am a total noob and don’t know how to store the hits when they happen, or what to do, etc.

Thanks.

Drag a wire from break hit results “Hit Component”, right click and select “Promote to Variable”, you can then give the variable some nice name. Then connect “Add Impuse” and “Set Collision Response to Channel” to that variable instead.

Additionally you should check that said variable is valid before trying to use Add Impulse and that other node on it though, just in case it’s not set by hit event yet.

what should I do here? When you say “Then connect “Add Impuse” and “Set Collision Response to Channel” to that variable instead.” do you mean the blue pin or the execute pin?

which Is Valid should I be using?

I am reading “thinking in C++” to try to understand fundamentally what I am doing but its slow going with trying to build all of the art to a massive 3D game while trying to learn the engine…

Thx so much!

You need to connect that execution wire to be able to set that variable, otherwise it will do nothing. You could connect the white wire you have on the middle of those two branches, remember to wire the set variable nodes output back to the other branch.

it did compile, still null references. " remember to wire the set variable nodes output back to the other branch. " - do you mean the execution, is the output?

Execution wire is ok now. but the variable will of course be null if you access it before there has been a hit event (in which case it hasn’t been set yet, like mentioned before the need of checking if that variable is valid).

You can do validity check by Is Valid-node for example. Looking at your code, there’s a lot odd logic there so I can’t really suggest a good position for this. It seems that you do a lot assumptions on the code which is never a good thing. You should always be sure that things are already happening the way you expect when you set boolean variables etc. But one this is certain, you do need to be sure that you have that variable set before you use that Add Impulse and node after it or it’ll get null on Target.

1 Like