forked from Harrison1/unrealcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventoryItem.cpp
More file actions
61 lines (48 loc) · 1.42 KB
/
InventoryItem.cpp
File metadata and controls
61 lines (48 loc) · 1.42 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Harrison McGuire
// UE4 Version 4.20.3
// https://github.com/Harrison1/unrealcpp
// https://severallevels.io
// https://harrisonmcguire.com
#include "InventoryItem.h"
// Sets default values
AInventoryItem::AInventoryItem()
{
InventoryItemMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("InventoryItem Mesh"));
InventoryItemMesh->SetSimulatePhysics(true);
RootComponent = InventoryItemMesh;
InventoryItemTexture = CreateDefaultSubobject<UTexture2D>(TEXT("InventoryItem Texture"));
isGlowing = false;
}
// Called when the game starts or when spawned
void AInventoryItem::BeginPlay()
{
Super::BeginPlay();
InitialMaterial = InventoryItemMesh->GetMaterial(0);
DynamicMatInstance = InventoryItemMesh->CreateAndSetMaterialInstanceDynamic(0);
if(InventoryItemMesh->GetStaticMesh() && DynamicMatInstance)
{
UE_LOG(LogTemp, Warning, TEXT("I have a mesh and material"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("I am missing either the mesh or material"));
}
}
void AInventoryItem::BeginFocus()
{
if(InventoryItemMesh->GetStaticMesh() && DynamicMatInstance)
{
DynamicMatInstance->SetScalarParameterValue(FName("EmissiveParam"), 50.0f);
}
}
void AInventoryItem::EndFocus()
{
if(InventoryItemMesh->GetStaticMesh() && DynamicMatInstance)
{
DynamicMatInstance->SetScalarParameterValue(FName("EmissiveParam"), 0.0f);
}
}
FString AInventoryItem::MyName()
{
return InventoryItemName;
}