박하의 나날

[06]Battery Collector_기초적인 아이템 물리(자유낙하) 적용

프로그래밍/Unreal

05.Extending the Pickup Class

BatteryPickup.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Fill out your copyright notice in the Description page of Project Settings.
 
#pragma once
 
#include "Pickup.h"
#include "BatteryPickup.generated.h"
 
UCLASS()
class BATTERYCOLLECTOR_API ABatteryPickup : public APickup
{
    GENERATED_BODY()
 
    // Sets default values for this actor's properties
public:
    ABatteryPickup();
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;
};
 
cs


BatteryPickup.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Fill out your copyright notice in the Description page of Project Settings.
 
#include "BatteryCollector.h"
#include "BatteryPickup.h"
 
//Set Default values
ABatteryPickup::ABatteryPickup(){
    //GetMesh()->SetSimulatePhysics(true);
}
void ABatteryPickup::BeginPlay()
{
    Super::BeginPlay();
    GetMesh()->SetSimulatePhysics(true);
}
cs

13) SetSimulatePhysics 물리(자유낙하) 적용

 튜토리얼 대로 기본적인 디폴트값을 설정하는 컨스트럭터에 SetSimulatePhysics를 넣었더니 적용이

되지 않아서 BeginPlay에 넣어주었다.

댓글보니까 안된다는 사람 몇있드라.. 왜안되는지는 모르지만 게임시작시 떨어지기만 하면되서

이대로.