Cannot use Toggle Visibility for Actor Blueprint
I am trying to create a blueprint in which an object becomes visible once the character enters a box trigger. In this case, the object is a key. Here is the tutorial I'm following as a reference:
This tutorial works fine, but only as long as I use a Static Mesh as my reference (like in the tutorial). It does, however, not work when the reference is a Blueprint that is placed in the level, which is what I want. Since the key in my level is also a collectible and rotates around its own axis, it requires to be scripted with a blueprint, but for some reason once I place the key-blueprint in the level instead of the key-staticmesh, the blueprint for Toggle Visiblity does not work; the key is visible all the time.
Here are some screenshots:
Level Blueprint (the invisible node to Toggle Visibility is Event BeginPlay). Note that here the StaticMesh is now used as the reference; when I replace it with the Blueprint Reference, the script stops working.
Actor Blueprint for the key. This is the Blueprint reference that fails to work.
The level. The orange disk is supposed to act as the trigger. When the character is on the trigger, the Static Mesh key appears. This is the effect I want. If I were to replace the reference with the Blueprint Key (the one on the right), it wouldn't make a difference as it remains visible the whole time.
I am a complete noob at programming and Unreal in general, so if you can help, please explain as if I were a 5 year old ;)
Hope this makes sense!
The key-staticmesh works because 'Toggle Visibility' uses a scene component. The key-staticmesh that you're talking about is by default a scene component. Thus, like in the tutorial, it will work as intended.
The key-blueprint, however, is a GROUP of scene components (ie, the DefaultRootComponent, any static meshes, so on). That's why you can't just stick a reference of it into a 'Toggle Visibility' node and expect it to work.
So if you'd like the 'key' to disappear using your key-blueprint, you need to get the reference to that instance of your key-blueprint, get the reference to its static mesh, and then toggle the visibility on that mesh.
Oh that makes sense! It worked, thanks a bunch :)
answered Jul 05 '16 at 10:32 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here