You should only need it on the character. On interact event in the door call get actor of class, get your character class, then access the map
• create an enumerator defining key colours
• add key|bool map variable in the player BP
• create an interface, open it
• add function to the interface, add map as input
• add interface to the door actor
• implement interface function in the door actor
• have player trace → call
If you get stuck on any of those steps, do tell.
Add interface to the door actor is what I’m confused with, which I mentioned above. I’m not sure how you do this.
Okay, I’ve completed the steps, as far as I’m aware. However, what exactly is going on here…? I could do with it being explained so I have a better understanding what the code is doing.
Also, nothing happens. I pick up the key, I go to the door and press the interact key, but the door doesn’t open. I’ve also set the Line Trace By Channel to draw the debug for the duration, but I don’t see anything.
We line trace along the camera’s point of view, see what we hit. And we then send the keys map to the Hit Actor.
I don’t see anything.
You should see a red dot when the trace connects - draw debug. Ensure the door mesh blocks the channel you’re tracing on (this is usually fine on default settings). If you do not see red dot, post script.
Okay. I was wondering what the purpose of the Camera Manager was all about.
No, I don’t see any red dot. I only have one for the line trace for my guns at the moment when I fire.
This is how it’s looking in the FirstPersonCharacter_BP:
The interact function:
And this could be where the problem lies - within the Door_BP. After the coloured key checks are done, I tried adding the interact function after, promoting the target to a variable, but then that gives me a warning.
This is not connected correctly:
You do not any of those bools anymore:
Everything is handled by the map - each door should have an enumerator (the very pic I sent). And you must populate the key map when you pick up keys.
And this:
Should not be in the door at all. Avoid granting each door in the game access to the player - not a safe thing to do.
What I suggested would replace the entire system, not add to it.
Ahh, I see. Also, the red dot is showing now, but only when I press the interact key. I couldn’t see it at first as the door is red. The door still doesn’t open though.
So are all of those nodes to be deleted at the top of the Door_BP?
Ha, ha, ha!
This is how I’d set up picking keys up (assuming the player overlaps them - but I’d probably use an interface, too):
Assuming the Keys are actors and have the abovementioned enumerator.
So are all of those nodes to be deleted at the top of the Door_BP?
Up to you, they do not serve any purpose in this very solution. Note that this:
Makes no sense. It’s the player that calls…
This is the code I have set up for the keys in the BP_Keycard:
With the TMap you have set up in yours, does that automatically destroy them when they’re picked up, or is that not needed with that system?
Now it does:
The player runs into the key, reads the enumerator and adds it to their key map. Then destroys the key. The above can be done neater with an interface but it’s fine for this.
I’m not able to add an OnComponentBeginOverlap in my FirstPersonCharacter_BP. That was used in my Keycard_BP instead.
Would it not make sense for that to be on the key itself? Seems a bit strange that another collision would be added to the player character when they already have their own.
What do you mean - we’re using the existing one. And it would not be strange, it’s actually pretty common to have multiple colliders serving various purposes.
Would it not make sense for that to be on the key itself?
You can, it’s your game. Would not recommend it for reasons too numerous to mention, though.
I take it I still need to keep the existing collider I have on the key though?
Whew… Well, it’s taken me a while, but the system works! The door opens once I have the key! Thank you, and everyone else, for all your help! I still need to look further into these TMaps as it’s completely new to me. And they’re not touched on in the course I’ve been following. So hopefully it’s something I’ll make further use of.
Yes! Otherwise we cannot detect it.
the system works
I am chuffed. Did not test it. Did not save it either ;p
I am chuffed. Did not test it. Did not save it either ;p
Hahaha.
Yes! Otherwise we cannot detect it.
Makes sense.