일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Unreal Engine
- nanite
- 보안
- rpc
- 게임 개발
- gas
- local prediction
- animation
- Replication
- os
- UI
- 언리얼 엔진
- MAC
- gameplay tag
- ability task
- 유니티
- gameplay effect
- stride
- 언리얼엔진
- map design
- network object pooling
- gameplay ability system
- unity
- listen server
- Multiplay
- 게임개발
- attribute
- photon fusion2
- CTF
- Aegis
Archives
- Today
- Total
Replicated
[Drag Down] 눈발사대 눈사람(주기적 발사 장애물) 본문
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DDBulletBase.generated.h"
UCLASS()
class DRAGDOWN_API ADDBulletBase : public AActor
{
GENERATED_BODY()
public:
ADDBulletBase();
protected:
UFUNCTION()
void OnComponentBeginOverlapCallback(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepHitResult);
void PushCharacter(ACharacter* Character);
UPROPERTY()
TObjectPtr<class USphereComponent> Trigger;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components")
TObjectPtr<class UStaticMeshComponent> StaticMeshComp;
UPROPERTY()
TObjectPtr<class UProjectileMovementComponent> Movement;
UPROPERTY(EditAnywhere)
float Power;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/DDBulletBase.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Components/SphereComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Physics/DDCollision.h"
#include "GameFramework/Character.h"
#include "GameFramework/CharacterMovementComponent.h"
ADDBulletBase::ADDBulletBase()
{
bReplicates = true;
Trigger = CreateDefaultSubobject<USphereComponent>(TEXT("Trigger"));
Trigger->InitSphereRadius(5.0f);
Trigger->SetCollisionProfileName(CPROFILE_DDTRIGGER);
RootComponent = Trigger;
Trigger->OnComponentBeginOverlap.AddDynamic(this, &ADDBulletBase::OnComponentBeginOverlapCallback);
StaticMeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComp"));
StaticMeshComp->SetupAttachment(RootComponent);
StaticMeshComp->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
Movement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Movement"));
Movement->InitialSpeed = 3000.0f;
Movement->MaxSpeed = 3000.0f;
Movement->bRotationFollowsVelocity = true;
Movement->bShouldBounce = false;
InitialLifeSpan = 3.0f;
Power = 3000.0f;
}
void ADDBulletBase::OnComponentBeginOverlapCallback(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepHitResult)
{
if ( HasAuthority() )
{
ACharacter* Character = Cast<ACharacter>(OtherActor);
if (Character)
{
PushCharacter(Cast<ACharacter>(OtherActor));
}
}
}
void ADDBulletBase::PushCharacter(ACharacter* Character)
{
if ( Character && Character->GetCharacterMovement() )
{
FVector Dir = GetActorForwardVector();
Character->LaunchCharacter(Dir * Power, true, true);
}
}
Bullet Base
이거 상속받아서 눈덩이로 만들 거다
밑에서 메시 설정해주면 되고, 파워도 설정 가능
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DDPeriodicLauncher.generated.h"
UCLASS()
class DRAGDOWN_API ADDPeriodicLauncher : public AActor
{
GENERATED_BODY()
public:
ADDPeriodicLauncher();
void Spawn();
protected:
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Launcher")
TObjectPtr<class UStaticMeshComponent> StaticMeshComp;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Launcher")
TSubclassOf<AActor> ActorClass;
UPROPERTY()
FTimerHandle SpawningHandle;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Launcher")
FRotator Rot;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Launcher")
float Offset;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/DDPeriodicLauncher.h"
// Sets default values
ADDPeriodicLauncher::ADDPeriodicLauncher()
{
bReplicates = true;
Offset = 300.0f;
Rot = FRotator::ZeroRotator;
StaticMeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComp"));
RootComponent = StaticMeshComp;
}
void ADDPeriodicLauncher::Spawn()
{
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
FVector SpawnLocation = GetActorLocation();
SpawnLocation.Z += Offset;
FRotator SpawnRotation = FRotator(0.f, 90.f, 0.f);
GetWorld()->SpawnActor<AActor>(ActorClass, SpawnLocation, SpawnRotation, SpawnParams);
}
void ADDPeriodicLauncher::BeginPlay()
{
Super::BeginPlay();
if ( HasAuthority() )
{
GetWorld()->GetTimerManager().SetTimer(SpawningHandle, this, &ADDPeriodicLauncher::Spawn, 1.0f, true, 0.0f);
}
}
void ADDPeriodicLauncher::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
if ( GetWorld() )
{
GetWorld()->GetTimerManager().ClearTimer(SpawningHandle);
}
Super::EndPlay(EndPlayReason);
}
이건 발사대
블루프린트로 상속해서 눈사람 넣어줄 거다
맵 다음 테마를 눈, 얼음으로 할 거라 눈사람이 눈덩이 발사하도록 했다
이제 다음은 이거에 네트워크 오브젝트 풀링을 적용해야 한다
'언리얼 엔진 > Drag Down' 카테고리의 다른 글
** [Drag Down] Performance Enhancement of Network Object Pooling ** (0) | 2025.04.16 |
---|---|
** [Drag Down] Network Object Pooling (Subsystem + Interface + GameMode + DataAsset) ** (0) | 2025.04.16 |
[Drag Down] Spring Boot 서버와 연동 - register/login (0) | 2025.04.14 |
[Drag Down] 기본 캐릭터 디자인 (0) | 2025.04.13 |
[Drag Down] 맵 테마2: 해상 암초 (0) | 2025.04.11 |