Boolean Won't Stay Saved As True/Is Engine Bugged?

Hello,

I’ve been working on my game for many hours and I’ve started encountering what seems to be a bug and I can’t work around it.

I have a very simple custom event setup so when my character overlaps with an actor in the world, a wall comes up and sets a Boolean to true through an actor component. After I kill my enemy in the game, it is then supposed to check if the Boolean is set to true and decrement the integer until it reaches 0. It successfully reaches the component and sets the Boolean to true, but the Boolean does not stay set as true when I kill an enemy, and nothing in my script is telling it to go back to false. I’m having the same problem with the integer. The integer sets to 15 but when I call for it, it says its at 0 every time.

Here is a picture of my script:

Here is a video showing what is happening. You can see when the wall comes up, it hits the print string and is setting the Boolean to true, but when I kill an enemy it hits the branch and say false every time. Not sure what I’m doing wrong or if its just a bug. Any help would be awesome.

There’s no problem with bools :slight_smile:

Is this code in the player?

I don’t see the spider dying. What is calling ‘check for event’, can you show that?

The “Check For Event” is being called after the spider dies in the spider BP. I’m trying to program the events inside of an actor component so I can allow communication between the actor that starts the event and the actors that are killed in the event.

Here is the screenshot where the Check For Event custom event is called. I didn’t include the entire death code because it’s long and the rest is working fine in the spider BP. I did setup a print string past this point in the BPC_EnemyEvents actor component and the communication is making it past the “Set Bottom Right Event” node in the actor component.

Here is also the script where the “Set BottomRightEvent” is being called. Again, the script is making it past the event and is working as it should.

What I’m not understanding is, from the print strings, you can see the communication is there but the Boolean is not actually setting to true, or if it is, it immediately sets itself back to false. If i setup an event begin play node and hook up “Set Bottom Right Event”, it works just fine but not with my custom event.

And no, nothing is being scripted inside of the player. There is an actor right after the wall that triggers the event to start.

1 Like

Do you get ‘accessed none’ errors when you stop play?

I’m not sure how an actor component can facilitate communication between blueprints ( probably my being dumb ).

No, I don’t get any errors after I stop play.

Everything in that line of code past the “SetBottomRightEvent” does not stay set. Even the integer doesn’t stay set. If i force the Boolean to be true and it actually makes it past the branch, the integer is always set to 0 and not to the 15 like its supposed to. Really not sure what is happening here.

I would think there would be a communication problem between the BPs, that’s usually where the problem lies, but the print strings show this isn’t the case.

I’m still quite new to this, and this is the only way I could figure out how to get 2 bps to communicate with eachother. The actor component can be added to both my spider and the overlap actor that triggers the event to start. I originally tried using a blueprint interface but I wasn’t successful at this.

When does the player overlap with the spider? ( that’s not obvious ).

The character isn’t supposed to overlap with the spider.

There is an actor placed directly past the wall that the character overlaps with. This triggers the event to start and the spiders to spawn within the wall boundaries.

Here is a screenshot of the actor the character overlaps with to start the event.

I’m trying to make it so when you kill all the spiders the wall drops back down, and it spawns an item. The problem I’m having is these spiders are also in the main world, so they can be found in the world and inside this event, so I need something saying this event started so it can countdown how many spiders are needed to be killed before allowing the player to leave and before the item will spawn. This is also why I need communication between the spider and the actor that starts the event.

Right.

I think you’ve stumbled across the wrong tutorials, or got some weird advice here.

If you’re starting out, ‘direct blueprint communication’ is the way to go.

Even if I was sitting in front of you right now, and explained why blueprint interfaces are a good thing, you would not understand. You have to encounter the kind of problem that caused their invention, before you can really get it.

Using components is worse :slight_smile: You’re trying to solve the problem by making it more complicated.

What you need is an actor in the level that spawns the spiders and keeps count, it can be a blueprint with the collision volume in ( the wall ). The player overlaps, you set the counter and spawn your first spider.

Two easy ways to keep count are

  1. Put a timer in the wall BP, it looks every second to see if there is a spider. If not, it increments the count. If the count is 15, spawn the prize, otherwise spawn another spider.

  2. When the spider dies, it tells the wall BP, then you don’t need a timer.

This is about direct BP comms

This probably isn’t the right way to do it but, I ended up setting up the boolean and integer inside of the character. The wall now sees you overlap with it, then sets the boolean and integer in the character. The spider now accesses those variables from the character and uses them and now it works fine.

I also have tried using blueprint interfaces but I was not able to get them to work. (My own fault I’m sure)

Still not sure why that boolean and integer wouldn’t stay set in the actor component, even if I wasn’t using the correct method, the actor component was working fine for communication but the boolean and integer inside of it would not stay set as as they should. I still think this might be a bug.

Thanks for the help. Issue is resolved.

1 Like

Character is also good for now. It just needs to be ‘not in the spider’ :slight_smile:

If the actor component was inside the spider, that would be a great reason not to work. Each spider starts from scratch.

This is also not a good place to use an interface, so I wouldn’t worry :sunny:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.