Hide actor in game on toggle

Hi, the idea of the short game is that you don’t see the enemy actor, but when you pick up thermal goggles and press the camera action mapping, It turns on the thermal post processing volume effects and makes the enemy actor visible. I already did everything except the enemy toggle part.

I set the default value of my EnemyCharacterMesh of rendering to hidden in game,


as I said I did everything when it comes to post processing, but I just added the set actor hidden in game toggle in between, it doesn’t work and I don’t know why so I would appreciate some help on this.

This is the part where my trouble happens, it does start the game with the actor hidden, but it never becomes visible. I am making this current links in my thirdpersoncharacterBP and I made a variable called EnemyCharacterMesh and set it’s variable to my enemyBP in order to get a reference:
image
So If anyone knows how to make it work please speak your mind, because I just get a bunch of errors.

Hey @azman!

Can you show how you’re getting the reference of Enemy Character Mesh?

Also can you show us the Errors you’re getting? That could really help!

Thanks! :slight_smile:

As I said, I reference the EnemyCharacterBP by making a variable called EnemyCharacterMesh and setting it’s type to my enemyBP(Enemy Ghost BP) → Third picture up top. The errors I keep on getting are all on the set actor hidden in game function.

The variable referencing:
image

The errors:

I realize that the referencing might be incorrect, but I don’t know any other way, because I also have the trouble with the fact that I have a mesh in my thirdpersoncharacter and in my enemybp but I want to reference the one with from the enemy bp etc. So please don’t hold back and help a brother out.

So what you can do is use a “GetAllActorsOfClass” node, throw in the class of EnemyGhostBP, and with that array that is output use a “ForEachLoop”. So for EACH entry it’s going to grab the static mesh component (*first one in the list on the Ghost BP that matches), and then ADD any unique entries to the Static Mesh Array-Ghosts.
Just replace your old “EnemyCharacterMesh” one with this static mesh array. Then you’ll use a “ForEach” again on your enable/disable using your array.

All of this can be done from the player BP, on BeginPlay if they aren’t spawned mid-level. But if you DID spawn them mid level, you can run an event for this.

I haven’t actively tested this but it SHOULD work and fix your issue. The issue is not “What am I looking for” it’s "Which SPECIFIC objects am I looking for. :slight_smile:

How do I make the Static Mesh array?

Well either way I fixed it a different way now, I just created a bool variable and made a branch on event tick in my enemy bp and It works now, thanks either way.

This is not how referencing works. This just creates a null variable, you also need a value. Imagine you create a string variable and never type in the text. You have a variable that could hold text but it currently has nothing. That’s what you have now - a reference that points to no ghost.

We need to tell the engine which instance of the Ghost we mean, even if there is only one.

made a branch on event tick in my enemy bp

Sounds to me as if it’s coming back to bite you sooner than later.