I’m trying to set up a system that changes the colour of the crosshair based on whether the player is aiming at an enemy or not using tags (“enemy”=red, none=white).
The code works fine when the line trace hits an Actor tagged “Enemy” but throws an error when it hits anything else without a tag. This is the error:
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_BreakHitResult_HitActor”. Blueprint: PlayerCharacter Function: Execute Ubergraph Player Character Graph: EventGraph Node: Branch
It points to the last Branch node which checks if the Actor has the “Enemy” tag. I can’t figure out why it’s causing a problem as the branch should be False if there’s no tag, right?
I’m calling the “CheckIfEnemy” event once on the “BeginPlay” event, and then it calls the start again every x-seconds (sorry misleading comment perhaps).
Also: that delay node would usually have a much smaller delay but the constant messages in the log where driving me crazy
I’ve tried OnTick and still get the same error… just a lot more often. I also tried unhooking the delay at the end and still get the error but only once (obviously).
I’m pulling my hair out a bit because I can’t see anything wrong with that branch, it’s like it’s handling the “false” condition strangely or doesn’t know what to do with an object that has no tags…
So it took me reverting to an older build which worked and building up again to figure this out:
There’s a piece of geometry I’m using for testing which is in front of the player when they spawn in. The error only flags up if the raycast hits a piece of geometry. Converted it to a static mesh and the errors go away!
So I’m not sure exactly why still but geometry doesn’t do well with tags and/or linetraces I guess.