Turn off the lights in the room by clicking on the switch

Hello. Me need create a swith on the wall in the room for turning on/off light on chandelier by clicking on swith. This is two differents objects. And need appear hint like a “press “e” for use” when cursor on the swith. Maybe can make together lesson for this situation.
P.S. sorry for my english.
Здравствуйте. Задача в следующем. Нужно сделать так, что бы выключатель расположенный на стене в комнате. выключал и включал свет на люстре. Это должны быть два разных объекта. И еще должна появляться надписть на подобие “намтите “Е” что бы использовать”. Возможно объединившись сможем сделать урок.

Hi there,

and
https://youtube.com/watch?v=jHxUisYmuAg
should get you started

this is not exectly what i want

Hi, Denton,

Is this being done in an FPS type of game? If so, do you want it to work that the object will only activate when the center/crosshairs of the player’s screen is over the object?

yeah. FPS, for crosshairs objects

Hi DcDenton,

i had the same problem a few days ago. Here is a short tutorial on how you can make a switch.

  1. Go to Blueprints: Right click on “Blueprint_WallSconce” → Create Copy = name it “MyWallSconceBP”

  2. Open MyWallSconceBP in your Blueprint Editor, go to EventGraph

  3. Right Click → Choose “Custom Event” = name it “LightSwitch”

  4. Drag PointLight2 into the EventGraph, choose “get”. Look for “toogle visibility” and connect everything together. Compile and save.

7483dff97dfe4fd2a0ab7f963872dbfaf2250d81.jpeg

  1. Go to Props → Right click on “Material Sphere” → Create Blueprint using… = name it “LightButtonBP”

  2. Open “LightButtonBP” in the Blueprint Editor → Components → Add Component → Select a “Box” rename it to “Trigger” and place it around your sphere.

  3. Add Component → Text Render, rename it to “HintMessage”. Go to Details → Text > set Text to: “Press E”. Place your Text somewhere around your sphere. where the Text should later appear.

  4. Go to Details → Rendering → uncheck Visible.

  5. Go to EventGraph → select Trigger → and in the EventGraph create all the Nodes like shown in the picture below.

  6. at the “Get All Actors of Class” choose “MyWallSconceBP” and on “Out Actors” choose “get” → CasttoMyWallSconceBP → As My Wall Sconce BP → LightSwitch. Compile and Save.

  7. Now you can place the “MyWallSconeBP” and “LightButtonBP” somewhere in your Editor (Transform → Scale “LightButtonBP” to 0.5 for X Y Z) and that’s it! Hit play and test your new Lightswitch.

I hope this is more or less what you are trying to do. :slight_smile:

Greetings

Ace D.

The one issue, Ace, with that set up is that a person could theoretically back up into the light switch and get the pop up to turn it on, without actually facing the switch.

Denton, what you want is to have the blueprint for MyCharacter draw a trace out from itself. Here is a screenshot of the blueprint that I have set up and working:

What this does is that every tick there is a trace shooting out from the center of your screen to X feet in front of you. It will stop if something is blocking it and it will return a hit result if it hits anything flagged to be WorldDynamic.

Anything that it hits will receive a message that it is being looked at from the blue print interface. At that point, you’ll just need to set up an event on the object regarding what to do when it is being looked at.

Let me know if you need help on that part, but at least this part should get you going. The only downside is that your main character is constantly doing a tick… and I’m not too sure how big of a performance hit that could be.

The upside is that you could use this wherever you want in your game, i.e. turning on lights, opening doors, etc, all based on if the player is looking at something.

Im tried yesterday AceD scheme, this is not exectly what i want, Me need, what hint always will be front for player, like a hud element, and else E button didnt swith light. Today will try McSean scheme

Hi, I need help with this tutorial. It tells me to turn off the light in rendering, but there is no box to turn off the visibility of the light. After that, whenever I type in visible when adding a new node I do not get the same functions options. All I get is “Set Actor Hidden in Game”

Please help??

Im make a multi interact like this lesson - YouTube
and make wallSconce with toggle function https://dl.dropboxusercontent.com/u/76051529/Unreal/WallSconce.png
and
when i add event in lightSwither to communicate them to wallsconce, i compile and see the next error https://dl.dropboxusercontent.com/u/76051529/Unreal/PinTarget.png
what me need to do?

Hi DcDenton,

you have to plug your Blueprint_Wallsconce_Child as the target to your LightSwithasD.
Create a new Variable and search for your Blueprint_Wallsconce_Child under Variable Type. “Get” that variable into the eventGraph and connect it to the target.

I’m only beginner, can u write more details instruction?

Hi DcDenton,

ok first, open your LightSwitch-Blueprint and click on Variable:
Step 1:

than click on bool and search for your Blueprint_Wallsconce_Child.
Step 2:

drag your newVar (you can rename it of course) into the EventGraph and connect it.
Step 3:

If this isn’t still working, try Step 4 and create Nodes like shown in the picture.
Step 4:

Greetings

Ace D.

And else. About hint when mouse look on object. Im add text via myHUD bluprint, but i dont know how make variable with text from object give to myHUD text. and the begin showing when mouse look at object

McSean,

The only part I’m having trouble with in your blueprint is the On Observed light blue piece.

I’m totally a beginner here. I assume its some type of variable that you apply to other objects? I really have no idea.

Appreciate any help.