Don't know what object to cast to
I've set up a door that closes on a timer but I'm struggling to display the timer in a widget I know how to cast to the player character & how to cast to the game mode, but I have no idea how to cast to an actor blueprint properly
What should I set the object to?
asked Apr 08 '17 at 01:55 PM in Blueprint Scripting
When you cast to anything, you need to get a valid reference first. For your bp_shutter, you need to get a reference to that actor you're trying to get DSeconds from. You can do this in many ways, check out my recent answer here to show a few ways to get references for casting. It all depends on how your game is setup.
answered Apr 08 '17 at 06:24 PM
This is something that I struggled with for a long time as well. For me it was because I thought casting was the only way to communicate with other actors which isn't the case. In your situation, rather than casting to the player, it would better serve you to implement all of the functionality you want inside a door blueprint. There's no need to set up the timer elsewhere. Then you can create an "Interact" key inside of your character and cast from the door to the character - which you pointed out is easy to do. Just as a quick mention, you can also use "Get all actors of class" to grab your door and not need to cast to anything or even use a Blueprint Interface to communicate between your blueprints.
I've created a video tutorial that goes over how to set up interactable objects that could help you a lot. If you want the door to be timer based and triggered in the level, this should still help you.
Follow this question
Once you sign in you will be able to subscribe for any updates here