I have a somewhat complex system on the go, all going well until something I generally have no issues with started happening.
Basically in the image below you’ll see a setup that I tend to use in multiple BP’s around my world.
In this instance the box events you see to the left are referring to a very small box collision.
The problem is this: I can press E anywhere ‘outside’ of this collision box and sometimes this is triggering.
There are other events in my level but to summarise:
Got player character checks on all my collision boxes to make sure nothing else can fire things in an incorrect manner
enable / disable inputs are used as shown in the image below
I’d appreciate any feedback or help here. I’ve never had this issue before and it’s clearly going to be something I’ve somehow overlooked but I’m just banging my head against a wall currently so figured I could use another set of eyes.
Cast “Other Actor” to your player controller, if it passes then Enable / Disable input accordingly. OnComponentBegin/EndOverlap can be triggered by pretty much any component, not just your player.
I also advise against using Enable / Disable Input nodes. Use a local boolean to give yourself greater flexibility and thank yourself later.
‘Other Actor’ won’t feed into the input for ‘Player Controller’.
Generally I use the system shown without any issues, I check if the overlap is the character itself and then run to two basic enable / disable inputs.
You know what though I’ve got about 30 booleans in my system so I totally get what you mean. Doing these trigger boxes with enable and disable inputs was one of the first things I learnt a couple of years ago so it’s kinda habit. That said I might have to try a work around as there’s no issues with any of my booleans. Something must be amiss somewhere for this to be firing without even being in the box that enables or disables Input. Driving me crazy.
Now this BP comes from a ‘spawnactor’ once one of my NPCs dies. I used F9 to trace this to the cause and when he dies and the item drops it triggers ‘Enable Input’ around 4 to 5 times sometimes with ‘Disable Input’ firing.
This would explain why I’ve never seen this issue before.
Attempted Fixes / Explanation
So again, I’ve tried 3 /4 work around attempts now to detect my character but when the item spawns it’s completely ignoring the overlap specified character.
I have attempted to turn this box collision off in my NPC AI BP as soon as it spawns but it still insists on acting like my character is stood underneath it even when across the map.
Frustrating but at least I’ve isolated the issue for now.
Below I’ve shown you the relevant section (focusing on the central chain, ignoring the black brushed areas) - this is just what executes after floats and other booleans decide the NPC is dead based on my health system. It ends with a simple spawn actor and print string. The location adjustment is to ensure it doesn’t go through the floor. This works. The issue lies with this explicitly (to my knowledge) being told to check a small box for my character and ignoring it.
And another update. Testing my NPC that the book spawns from the issue is clear. He’s triggering it. Why though, this is the first time I’ve ever had this?
Look at the following image.
1 is my NPC patrolling.
2 is my spawned object (dragged a version of this in to test what happens when he hits it)
Sure enough it fires like crazy when he walks (collides) with it. is my player and he’s called .
The reason he’s triggering it is because, as I said above, any actor/component can trigger the overlap end/start callbacks. You have to isolate the actor calling the overlap by casting “Other Actor” to Player Controller, not Rina Character. Your cast to Rina Character is silently failing because your Player Controller actor doesn’t inherit from the Rina Character class most likely (if it does then best practice is to rename your class to Rina Player Controller since Controller and Character are 2 different things). Casting to Player Controller will always succeed so long as its the player that’s overlapping since your player controller is 100% inheriting from or even is the Player Controller class.
You’re assuming that UE4 can read your mind when you think “only when the player overlaps, nothing else, trigger this” but you really have to tell UE4 what to do, thus you need to distinguish between the player and other actors that are triggering the overlap event.