How to Switch between two Blueprint classes using widget buttons
I wish to create a widget where once u click a button u can shift between one blueprint class(containing a camera with a spring arm attached) to another blueprint class. I have seen some post but they have assigned a keyboard shortcuts ( 1 and 2) for doing the same.
asked Jan 05 '16 at 11:19 AM in Blueprint Scripting
Thank you for clarifying that. Here's a simple way to do this with your current set up.
This method is assuming that both pawns are of the same blueprint. If they're not, it should be even easier as you can set the references before runtime.
In the pawn's blueprint, make a variable that stores a reference to this type of blueprint, so if you're working in the ThirdPersonCharacter from the template, you'd be setting up a variable that is a ThirdPersonCharacter actor reference. After that, set up the following nodes (OtherReference is my variable).
This allows us to look through all of the instances of this type and get a reference to the other one in the scene.
After that, create the widget blueprint for your button. Add a button and then in the details for the button, click the + beside "OnClicked".
In the event graph that appears, you can add the following nodes.
This gets the currently controlled pawn, makes sure it's of that blueprint class, and then gets its reference variable to tell the player controller what to possess.
Let me know if you run into any issues. Hope this helps!
answered Jan 06 '16 at 03:08 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here