I’m still getting to grips with UE4 and blueprint as a whole so I keep running into problems tinkering with an idea I’m playing around with. I’ve looked online but barely seen anything on how to use bools which I think is what I need for what I’m trying to do so I’ll explain as best as I can what I’m trying to do and see if anyone can figure this out :3
I’m trying to create something that acts as a power source. So that when a player goes to this source, they can absorb energy from it which will be active. These sources would be dotted about various levels in the project I’m working on, hence making it as a class. I have created a class blueprint called Source, I’ve added a temporary default mesh and trigger volume around it in the components tab. I also added a hovering piece of text which has its visibility toggled when the player is in the trigger which works. So far so good. The part I am struggling with is interacting with it. I have it so that when you walk up to the object, the trigger volume enables input by the player controller, this seems to work.
I have created a bool called power. This is how I think I should be doing this? So that any time the player uses a power source, the state of having ‘power’ will be true. As a separate thing in the class BP, I have “E Pressed” connected to a branch which checks if power is true. If false, it ticks the bool ‘power’. If it is already true, i.e. the source has already been interacted with, a string pops up saying ‘Already enabled’. When I drop the class blueprint ‘source’ into the world and test it out, it all seems to work. But when I add the class blueprint again, so a duplicate is in the world, things don’t quite work. If I go up to the first one and interact, I get ‘Power enabled’. If I go to the second one and interact, where it should say ‘Already enabled’ it instead classes ‘power’ as false and enables the power again.
As I said I’m still pretty beginner so I could be almost there, I could be going about this all wrong I’m not sure. I assume the bool in every subsequent version of the class blueprint is named differently with _2 at the end or something which is why it is not working. Does the bool ‘power’ need to be in the open level BP graph instead? Should I use something instead of bools?
Thanks for any help