/
Tool.cpp
36 lines (30 loc) · 1.2 KB
/
Tool.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Fill out your copyright notice in the Description page of Project Settings.
#include "Survival.h"
#include "Tool.h"
#include "SurvivalCharacter.h"
ATool::ATool()
{
//InteractableObjectSkeletalMesh->SetSimulatePhysics(true);
toolSocket = CreateDefaultSubobject<USkeletalMeshSocket>(TEXT("ToolSocket"));
_canBePutToInventory = true;
}
void ATool::SetIsInteracted(bool newIsInteracted)
{
Super::SetIsInteracted(newIsInteracted);
ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
ASurvivalCharacter* SurvivalCharacter = Cast<ASurvivalCharacter>(PlayerCharacter);
if (SurvivalCharacter)
{
FVector ToolSocketLocation;
ToolSocketLocation = SurvivalCharacter->GetMesh()->GetSocketLocation("ToolPoint");
this->InteractableObjectStaticMesh->SetSimulatePhysics(false);
AttachToComponent(SurvivalCharacter->GetPlayerMesh(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), TEXT("ToolPoint"));
this->SetActorRelativeRotation(FRotator(-100.f, 0.0f, -150.f));
this->SetActorRelativeLocation(FVector(1.0f, 3.3f, 8.73f));
this->SetActorScale3D(FVector(1.5f, 1.5f, 1.5f));
}
}
void ATool::BeginPlay()
{
Super::BeginPlay();
}