Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?alt text

Product Version: UE 4.14
more ▼

asked Apr 08 '17 at 01:55 PM in Blueprint Scripting

avatar image

3 1 2 3

avatar image Wurmloch83 Apr 08 '17 at 05:02 PM

Is this function inside the bp_shutter blueprint? You then don't need a cast you can simply access the Seconds, using right click, typing GetSeconds.

If you are not inside the bp_shutter blueprint, you need to supply an input to the cast node (the object pin).

avatar image axemunger Apr 08 '17 at 06:00 PM

No that screenshot is in the widgets blueprint, more specifically it's the function for the textbox that will be displaying the variable on the screen

also the bp_shutter is just a regular actor blueprint

avatar image Wurmloch83 Apr 08 '17 at 06:27 PM

You need to get a reference to the bp_shutter into your widget (i.e. the widget needs to know the door.). Adding a new variable of type bp_shutter named ShutterRef would be the first step. It now depends on where your widget is embedded. Is it part of your HUD or owned by a widget component? I assume the HUD:

on your HUD you need to create a variable named TimerWidget of type of your widget blueprint type. This variable must be set when the widget is created and added to screen. You could then add to your begin play in your bp_shutter something like: 1. GetHUD 2. Cast to your HUD type 3. GetTimerWidget 4. SetShutterRef

I hope this helps getting an idea what has to be done, it is difficult to suggest the correct solution without seeing all of your project.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.


more ▼

answered Apr 08 '17 at 06:24 PM

avatar image

1.5k 65 132 103

avatar image axemunger Apr 08 '17 at 06:51 PM

Thank you that helped a lot

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.


more ▼

answered Apr 08 '17 at 08:51 PM

avatar image

1.2k 90 118 149

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question