Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger.cpp
- // Fill out your copyright notice in the Description page of Project Settings.
- #include "Trigger.h"
- UTrigger::UTrigger()
- {
- // Установите этот компонент на инициализацию при запуске игры и его обновление каждый кадр. Вы можете отключить эти функции
- // для повышения производительности, если они вам не нужны.
- PrimaryComponentTick.bCanEverTick = true;
- }
- void UTrigger::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
- {
- Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
- AActor* Actor = GetAcceptableActor();
- if (Actor != nullptr)
- {
- UE_LOG(LogTemp, Display, TEXT("Unlocking"));
- }
- else
- {
- UE_LOG(LogTemp, Display, TEXT("Relocking"));
- }
- UE_LOG(LogTemp, Display, TEXT("Hello, World"));
- }
- AActor* UTrigger::GetAcceptableActor() const
- {
- TArray<AActor*> Actors;
- GetOverlappingActors(Actors);
- for (AActor* Actor : Actors)
- {
- if (Actor->ActorHasTag(AcceptableActorTag))
- {
- return Actor;
- }
- }
- return nullptr;
- }
- void UTrigger::BeginPlay()
- {
- Super::BeginPlay();
- }
- ***************************************************************************************************************************************
- trigger.h
- // Fill out your copyright notice in the Description page of Project Settings.
- #pragma once
- #include "CoreMinimal.h"
- #include "Components/BoxComponent.h"
- #include "Trigger.generated.h"
- /**
- *
- */
- UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
- class CRYPTRAIDER_API UTrigger : public UBoxComponent
- {
- GENERATED_BODY()
- public:
- UTrigger();
- public:
- virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
- protected:
- // Called when the game starts
- virtual void BeginPlay() override;
- private:
- UPROPERTY(EditAnywhere)
- FName AcceptableActorTag;
- AActor* GetAcceptableActor() const;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement