Virtual void Tick(float DeltaTime) override ĬeilingLight.cpp //Copyright Epic Games, Inc. Called when the game starts or when spawned Sets default values for this actor's properties PointLightComp->SetSourceRadius(SourceRadius) ĬeilingLight.h // Fill out your copyright notice in the Description page of Project Settings.Ĭlass BPCOMMUNICATION_API ACeilingLight : public AActor PointLightComp->SetIntensity(Brightness) PointLightComp->SetWorldLocation(FVector(0, 0, -130)) StaticMeshComp->AttachToComponent(SceneComp, FAttachmentTransformRules::KeepRelativeTransform) PointLightComp->AttachToComponent(SceneComp,FAttachmentTransformRules::KeepRelativeTransform) StaticMeshComp = CreateDefaultSubobject(TEXT("StaticMeshComp")) PointLightComp = CreateDefaultSubobject(TEXT("PointLightComp")) SceneComp = CreateDefaultSubobject(TEXT("SceneComp")) ![]() You can turn this off to improve performance if you don't need it. Set this actor to call Tick() every frame. #include "Components/PointLightComponent.h"įrom the constructor ACeilingLight::CeilingLight declare the following. Next navigate to CeilingLight.Cpp and declare the following Include library. UPROPERTY(EditInstanceOnly, BlueprintReadWrite)Ĭlass UPointLightComponent* PointLightComp In the class defaults of CeilingLight.h implement the following code. You have created a new Third Person project and are now ready to learn about direct Blueprint communication.įrom the C++ Class Wizzard, create a new Actor class named CeilingLight. Select C++ and With Starter Content options and click Create Project. Now that you know how to use direct Actor communication, take a look at the other types of communication referenced in the Actor Communication documentation page. In this section you added the Ceiling Lamp Actor reference to the ThirdPersonCharacter Blueprint Actor and you turned the light on and off by pressing the F key. Press Play to go into Play Mode and press the F key to turn the lamp on and off. Search for and select the Blueprint_CeilingLight Blueprint. ![]() Select the ThirdPersonCharacter Actor in your Level and from the Details panel click the Lamp Reference dropdown. In this section you modified your ThirdPersonCharacter Blueprint Actor to use a reference to the lamp Actor and turn the lamp on and off by pressing the F key. Enable the New Visibility checkbox as shown below. Connect the A pin from the Flip Flop node to the Set Visibility node as shown below.Ĭopy the Lamp Reference, Point Lamp 1, and Set Visibility nodes and connect them to the B Pin of the Flip Flop Node. Drag from the pin and search for and select Get Point Light 1.ĭrag from the Point Light 1 pin and search for and select Set Visibility. In the Event Graph, right-click and search for and select the F key to create the input node.ĭrag from the Pressed pin of the F Key node and search for and select Flip Flop.ĭrag the Lamp Reference variable into the Event Graph and select Get LampReference. Search for and select the Object Reference for the Blueprint Ceiling Light as shown below.įinally, enable the Instance Editable checkbox and Compile and Save the Blueprint. Go to the Details panel and click the Variable Type dropdown. Go to the Variables section and click the + Variable button to create a new variable. With your ThirdPersonCharacter Actor selected, go to the World Outliner and click Edit ThirdPersonCharacter to open the Blueprint editor. ![]() Select your ThirdPersonCharacter Actor in the Level and position it closer to the lamp. Go to Starter Content > Blueprints inside the Content Browser and drag the Blueprint_CeilingLight actor into the Level. You have created a new Third Person project and are now ready to learn about direct Actor communication. Select the Blueprint and With Starter Content options and click Create Project. Select the Third Person template and click Next. In the New Project Categories section of the menu, select Games and click Next. In this Quick Start guide, you will learn how to use direct Actor communication to access information from a target Actor in order to use its functions. This communication method uses a one-to-one relationship between your working Actor and your target Actor. This method requires a reference to the target Actor so you can access it from your working Actor. Direct Actor communication is a common method of sharing information between Actors in your Level.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |