Merge branch 'Bullet'
This commit is contained in:
35
Source/M4_CPP/private/M4_Projectile.cpp
Normal file
35
Source/M4_CPP/private/M4_Projectile.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "M4_Projectile.h"
|
||||||
|
#include "GameFramework/ProjectileMovementComponent.h"
|
||||||
|
#include "Components/MeshComponent.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
AM4_Projectile::AM4_Projectile()
|
||||||
|
{
|
||||||
|
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
|
||||||
|
MeshComp-> SetRelativeScale3D(FVector(1.f, .1f,.1f));
|
||||||
|
MeshComp->BodyInstance.SetCollisionProfileName(TEXT("Projectile"));
|
||||||
|
MeshComp->OnComponentHit.AddDynamic(this, &AM4_Projectile::OnHit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AM4_Projectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector Impulse, const FHitResult& Hit)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Called when the game starts or when spawned
|
||||||
|
void AM4_Projectile::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Called every frame
|
||||||
|
void AM4_Projectile::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
}*/
|
||||||
|
|
||||||
36
Source/M4_CPP/public/M4_Projectile.h
Normal file
36
Source/M4_CPP/public/M4_Projectile.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "M4_Projectile.generated.h"
|
||||||
|
|
||||||
|
class UProjectileMovementComponent;
|
||||||
|
class UMeshComponent;
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class M4_CPP_API AM4_Projectile : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
|
||||||
|
UMeshComponent* MeshComp;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere,BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = "true"))
|
||||||
|
UProjectileMovementComponent* ProjectileMovem;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
AM4_Projectile();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float bullSpeed = 50.f;
|
||||||
|
float lifeTime = 3.f;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,FVector Impulse, const FHitResult& Hit);
|
||||||
|
UMeshComponent* GetCollisionComp() const { return MeshComp; }
|
||||||
|
UProjectileMovementComponent* GetMovementComp() const { return ProjectileMovem; }
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user