// Fill out your copyright notice in the Description page of Project Settings.
// Fill out your copyright notice in the Description page of Project Settings.
#include "Grabber.h"
#include "Engine/World.h"
#include "DrawDebugHelpers.h"
// Sets default values for this component's properties
UGrabber::UGrabber()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UGrabber::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
FVector Start = GetComponentLocation();
FVector End = Start + GetForwardVector() * MaxGrabDistance;
DrawDebugLine(GetWorld(), Start, End, FColor::Red);
//내가 설정한 원으로 콜리션 원 만들기
FCollisionShape Sphere = FCollisionShape::MakeSphere(GrabRadius);
FHitResult HitResult;
bool HasHit = GetWorld()->SweepSingleByChannel(HitResult, Start, End, FQuat::Identity, ECC_GameTraceChannel2,Sphere);
if(HasHit)
{
AActor* HitActor = HitResult.GetActor();
UE_LOG(LogTemp,Display,TEXT("Hit Actor: %s"), *HitActor->GetActorNameOrLabel());
}
else
{
UE_LOG(LogTemp,Display,TEXT("No Actor Hit"));
}
}
When I look elsewhere, I don’t get a message saying I succeeded in Hit, but I get a message. Why is that?
I also have a problem with Debugline currently not connecting to bpplayer but connecting in the x direction. Is it related to this?