diff --git a/Source/M4_CPP/private/M4_Projectile.cpp b/Source/M4_CPP/private/M4_Projectile.cpp new file mode 100644 index 0000000..0f21fda --- /dev/null +++ b/Source/M4_CPP/private/M4_Projectile.cpp @@ -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(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); +}*/ + diff --git a/Source/M4_CPP/public/M4_Projectile.h b/Source/M4_CPP/public/M4_Projectile.h new file mode 100644 index 0000000..912c97b --- /dev/null +++ b/Source/M4_CPP/public/M4_Projectile.h @@ -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; } +};