WIP Obstacles and die
Added a collision trigger in the obstacles that calls the new ZombieCharacter function: Die. Die converts the actor into a ragdoll
This commit is contained in:
parent
50d1adc8d1
commit
335b7ffc92
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cdff9ca7fc6ed13c785f63aadd65073e5878fd07db67af49ff681d356e16e860
|
||||
size 31545
|
||||
oid sha256:6bf83eb106752e2feac03ddd3851505e271402e5b02d19c46c558ebb04e0ef11
|
||||
size 33112
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8f7d9a58b2bdc60851ffcb94fff19a93f9615b17744b789b925cb89c62a23bae
|
||||
size 31564
|
||||
oid sha256:9f621a60ee414a81565d628912e3e46060e14e546d9761b09b202fc8f9610bba
|
||||
size 32389
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8bc7c7ecdf84ccc779ee4590b84fe34d874eb59217a049a22114e2b3f0297fb1
|
||||
size 30795
|
||||
oid sha256:718a5255036bb614aa822bf103cecae17a056eb56fa3fd6c6a802e7245b86dd1
|
||||
size 31423
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:380a90ce6c893ed44219b090b9f6f67f9a40c18bd0aa39d4d4e977319d713a93
|
||||
size 31093
|
||||
oid sha256:9c593cda9e9db79d93831cbaeb0287b629058d804a0de872931e20d876e2d909
|
||||
size 32004
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6c7b9af625d5628413081f447adee9bbb03d4a696125726cbaa2f5c8b2d419a6
|
||||
size 30517
|
||||
oid sha256:f7924503514acaacc4921d9706cf1ef436d2cbb0006978cdb1e12ce4bbb499e7
|
||||
size 31218
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0b56310f3199f79d5cbcea36a0f0e4a3beaddaedd04879ee69251b080ecd4613
|
||||
size 19189
|
||||
oid sha256:d41ca9f1b02e2ca88467df0def718f0f96eab8c32ba0123c398c0c28e49300b8
|
||||
size 19280
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f0566c7e8795c8006806e9c3c77623216ed523192a1345199be6fe1f284835c9
|
||||
size 19053
|
||||
oid sha256:2a531ad20dd37b4bd17e41ad7ccb88974eb7e2823c623989beaab5ddc827d3cb
|
||||
size 19125
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:52d7550ccc3422b64619380e8548a9abbc6730e29c973bcf3980c79bb94f042f
|
||||
size 18465
|
||||
oid sha256:be3664af054fffe8ab7ef3a7cae2b68545d7c82f6af5c80d0279022e742f5958
|
||||
size 18584
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3e01d88e347d348e225286f5dfbdb3ac8665ebc4a83e1d37453307489ca090db
|
||||
size 20030
|
||||
oid sha256:78f3d157bd7ab0c015c79121fe00add2b9f7254ca88a06aad7068aa75029c5e6
|
||||
size 20164
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6006fb670a5971e479cb17579df7d7883497843dfbbee02d9ec96a08c9909583
|
||||
size 19033
|
||||
oid sha256:e5674bf8396d78d2ddce3227ed1eab8daedd52210fc2e1b6a9566eb8336a94c6
|
||||
size 19160
|
||||
|
||||
@ -2,11 +2,12 @@
|
||||
|
||||
|
||||
#include "Obstacle.h"
|
||||
#include "ZombieCharacter.h"
|
||||
|
||||
// Sets default values
|
||||
AObstacle::AObstacle()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComponent"));
|
||||
@ -15,13 +16,19 @@ AObstacle::AObstacle()
|
||||
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
|
||||
StaticMesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
|
||||
StaticMesh->SetRelativeRotation(FRotator(0.f, 90.0f, 0.f));
|
||||
|
||||
ObstacleCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("ObstacleCollision"));
|
||||
ObstacleCollision->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
|
||||
ObstacleCollision->SetCollisionProfileName(TEXT("OverlapOnlyPawn"));
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AObstacle::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
|
||||
ObstacleCollision->OnComponentBeginOverlap.AddDynamic(this, &AObstacle::CollisionBeginOverlap);
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
@ -31,3 +38,15 @@ void AObstacle::Tick(float DeltaTime)
|
||||
|
||||
}
|
||||
|
||||
void AObstacle::CollisionBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
{
|
||||
if (OtherActor->IsA(AZombieCharacter::StaticClass()))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("[AObstacle::CollisionBeginOverlap] Se ha chocao Paco"));
|
||||
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Red, TEXT("Se ha chocao Paco"));
|
||||
|
||||
AZombieCharacter* ZombieCharacter = Cast<AZombieCharacter>(OtherActor);
|
||||
ZombieCharacter->Die();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Obstacle.generated.h"
|
||||
|
||||
UCLASS()
|
||||
@ -15,10 +16,12 @@ public:
|
||||
// Sets default values for this actor's properties
|
||||
AObstacle();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UPROPERTY(EditAnywhere, Category = "Obstacle-Components")
|
||||
USceneComponent* SceneComponent;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UPROPERTY(EditAnywhere, Category = "Obstacle-Components")
|
||||
UStaticMeshComponent* StaticMesh;
|
||||
UPROPERTY(EditAnywhere, Category = "Obstacle-Components")
|
||||
UBoxComponent* ObstacleCollision;
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
@ -28,4 +31,7 @@ public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
UFUNCTION()
|
||||
void CollisionBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||
|
||||
};
|
||||
|
||||
@ -93,12 +93,16 @@ void AZombieCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (!bDied)
|
||||
{
|
||||
|
||||
TurnTimeline.TickTimeline(DeltaTime);
|
||||
|
||||
if (!bTurning)
|
||||
{
|
||||
MoveForwardConstant(DeltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
@ -149,6 +153,28 @@ void AZombieCharacter::Move(const FInputActionValue& Value)
|
||||
//
|
||||
//}
|
||||
|
||||
void AZombieCharacter::Die()
|
||||
{
|
||||
GetMesh()->SetCollisionProfileName(TEXT("Ragdoll"));
|
||||
SetActorEnableCollision(true);
|
||||
|
||||
// Ragdoll
|
||||
GetMesh()->SetAllBodiesSimulatePhysics(true);
|
||||
GetMesh()->SetSimulatePhysics(true);
|
||||
GetMesh()->WakeAllRigidBodies();
|
||||
GetMesh()->bBlendPhysics = true;
|
||||
|
||||
UCharacterMovementComponent* CharacterComp = Cast<UCharacterMovementComponent>(GetMovementComponent());
|
||||
if (CharacterComp)
|
||||
{
|
||||
CharacterComp->StopMovementImmediately();
|
||||
CharacterComp->DisableMovement();
|
||||
CharacterComp->SetComponentTickEnabled(false);
|
||||
}
|
||||
|
||||
bDied = true;
|
||||
}
|
||||
|
||||
void AZombieCharacter::MoveForwardConstant(float DeltaTime)
|
||||
{
|
||||
if (bStraight)
|
||||
|
||||
@ -89,6 +89,8 @@ public:
|
||||
int iCurrentDirection = 0;
|
||||
FVector vCurrentDirection;
|
||||
|
||||
void Die();
|
||||
|
||||
private:
|
||||
|
||||
void MoveForwardConstant(float DeltaTime);
|
||||
@ -98,4 +100,6 @@ private:
|
||||
float fControlTurn = 0.f;
|
||||
float fPrevCurvValue = 0.f;
|
||||
|
||||
bool bDied = false;
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user