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"

Problem with cast

I'm currently trying to create a small system where I set up multiple switches for controlling lighting, and having a main breaker in each level that controls if each switch should be able to turn on a light. I tried to do this by having the switch casting to the breaker to check the boolean "IsPowerOn". If it's true, it then allows itself to turn on the lights. It always checks if this is true, and the moment it's false, it permanently toggles the lights off until the power is on again.

But I think I got the whole concept of casting wrong. I simply want the SwitchBP to be able to check if the power is on, which is decided by a boolean in the BreakerBP.

Here's the blueprints. alt text

alt text

So far I think I've got it right. I started with some keyboard inputs in the SwitchBP to control the power bool, and the light turned off and on when it was suppsoed to. But it's about finding what I'm supposed to connect to the "object" in the Cast node.

Product Version: UE 4.18
lightswitchbp.png (155.3 kB)
breakerbp.png (160.9 kB)
more ▼

asked Feb 24 '18 at 01:26 AM in Blueprint Scripting

avatar image

30 5 6 9

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

1 answer: sort voted first

the main issue you have here is that you have nothing connected to the object pin. a cast is basically a comparison (is object A similar to object B). the way you have it now is like saying is nothing (or rather a lack of a item) like object B.

more ▼

answered Feb 24 '18 at 01:31 AM

avatar image

10.1k 33 10 25

avatar image ThompsonN13 Feb 24 '18 at 01:38 AM

try making a variable and in the details panel change its type to oldbreakerbp or actor. then make the variable editable. now select the switch bp in your scene and set the variable to the oldbreaker in your scene. also have the variable plugged into your cast where the object pin is. this should fix your issue.

avatar image CorbisHETB Feb 24 '18 at 11:04 AM

Wow, that actually worked! I didn't know what to put into the object pin, but this makes kinda sense I guess. I think I need to learn more about object variables, had no idea I could select actors in the scene to a variable like that. Thank you very much!

(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