void AZombieCharacter::Die()
{
	//Disables the logic of the zombie and gradually destroys this Actor

	AZombieController* ZCon = Cast<AZombieController>(GetController());
	if (ZCon)
	{
		//Increasing the kills and wave count if necessary
		OurCharacter->Kills++;
		URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance());
		GameInstance->IncreaseWaveCountIfNeeded();
		OurCharacter->PlayerController->UpdateUI();

		//Stopping the AI logic
		ZCon->UnPossess();

		AlphaChannelReduction();
		//AlphaReductionTimeline.PlayFromStart();

		//Handling the last animations
		ZAnimInstance->bIsDead = true;
		ZAnimInstance->Speed = 0;

		AudioComponent->Stop();

		//Disabling the collision to avoid false kill count!
		UCapsuleComponent* RootComp = Cast<UCapsuleComponent>(GetRootComponent());
		RootComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);

	}
}
	// Create a collision shape actor from a given shape name
	AActor* CreateCollisionShape( UWorld* World, const FString ShapeTypeName, FVector Location )
	{
		AActor* TestRayCollisionActor = nullptr;
		FTransform CollisionTransform;
		CollisionTransform.AddToTranslation(Location);
		
		if (ShapeTypeName == TEXT("TriggerCapsule"))
		{
			TestRayCollisionActor = Cast<ATriggerCapsule>(GEditor->AddActor(World->GetCurrentLevel(), ATriggerCapsule::StaticClass(), CollisionTransform));
			if (TestRayCollisionActor != nullptr)
			{
				UCapsuleComponent* Capsule = Cast<UCapsuleComponent>(TestRayCollisionActor->GetRootComponent());
				if (Capsule != nullptr)
				{
					Capsule->SetCapsuleHalfHeight(100.0f);
					Capsule->SetCapsuleRadius(50.0f);
				}
			}
		}
		else if (ShapeTypeName == TEXT("TriggerBox"))
		{
			TestRayCollisionActor = Cast<ATriggerBox>(GEditor->AddActor(World->GetCurrentLevel(), ATriggerBox::StaticClass(), CollisionTransform));
		}
		else if (ShapeTypeName == TEXT("TriggerSphere"))
		{
			TestRayCollisionActor = Cast<ATriggerSphere>(GEditor->AddActor(World->GetCurrentLevel(), ATriggerSphere::StaticClass(), CollisionTransform));
		}
		TestBase->TestNotNull<AActor>(FString::Printf(TEXT("Failed to create Collision trigger%s."), *ShapeTypeName), TestRayCollisionActor); 
		return TestRayCollisionActor;
	}
void ABaseCharacter::OnDeath(float KillingDamage, FDamageEvent const& DamageEvent, APawn* PawnInstigator, AActor* DamageCauser)
{
	bReplicateMovement = false;
	bTearOff = true;

	PlayHit(true, KillingDamage, DamageEvent, PawnInstigator, DamageCauser);

	DetachFromControllerPendingDestroy();

	/* Disable all collision on capsule */
	UCapsuleComponent* CapsuleComp = GetCapsuleComponent();
	CapsuleComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
	CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);

	if(bRagdolledAfterDeath)
	{
		SetRagdollPhysics();

		ApplyPhysicsToTheRagdolledBody(DamageEvent);
	}
	else
	{
		SetLifeSpan(TimeAfterDeathBeforeDestroy);
	}

}
// Called every frame
void ATheSwarmActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	UCapsuleComponent* move = NULL;
	TArray<UCapsuleComponent*>comps;
	actor->GetComponents(comps);
	if (comps.Num() > 0)
	{
		move = comps[0];
	}

	//adjust Z axis for allowing gravity
	FVector gravityFudge = FVector(GetActorLocation().X, GetActorLocation().Y, actor->GetActorLocation().Z);
	SetActorLocation(gravityFudge + velocity *  DeltaTime);

	//moves swarm actor and child actor
	actor->SetActorLocation(GetActorLocation());
	velocity = velocity.GetClampedToSize(0, 360);
	SetActorRotation(velocity.Rotation());
	actor->SetActorRotation(GetActorRotation());
	
	//allows animation assets to be used
	if (move != NULL)
	{
		move->SetAllPhysicsLinearVelocity(velocity);
	}

}
// Sets default values
APacmanGhostCharacter::APacmanGhostCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	UCapsuleComponent* Capsule = GetCapsuleComponent();
	Capsule->OnComponentHit.AddDynamic(this, &APacmanGhostCharacter::OnHit);
	Capsule->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f));
	Capsule->CanCharacterStepUpOn = ECB_No;
}
Esempio n. 6
0
float ACharacter::GetDefaultHalfHeight() const
{
    UCapsuleComponent* DefaultCapsule = GetClass()->GetDefaultObject<ACharacter>()->CapsuleComponent;
    if (DefaultCapsule)
    {
        return DefaultCapsule->GetScaledCapsuleHalfHeight();
    }
    else
    {
        return Super::GetDefaultHalfHeight();
    }
}
// Sets default values
AAntCharacter::AAntCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	UCapsuleComponent* MyCapsule = CreateDefaultSubobject<UCapsuleComponent>(ACharacter::CapsuleComponentName);
	MyCapsule->InitCapsuleSize(34.0f, 50.0f);
	APhysicsVolume* CapsulePhysicsVolume;
	CapsulePhysicsVolume = MyCapsule->GetPhysicsVolume();
	//CapsulePhysicsVolume->SetPrePivot(FVector(0.0,0.0,0.0));
	MyCapsule->SetPhysicsVolume(CapsulePhysicsVolume, true);
	RootComponent = MyCapsule;
}
Esempio n. 8
0
APlayerProxy::APlayerProxy() {
	bReplicates = true;

	// It seems that without a RootComponent, we can't place the Actual Character easily
	UCapsuleComponent* TouchCapsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("dummy"));
	TouchCapsule->InitCapsuleSize(1.0f, 1.0f);
	TouchCapsule->SetCollisionEnabled(ECollisionEnabled::NoCollision);
	TouchCapsule->SetCollisionResponseToAllChannels(ECR_Ignore);
	RootComponent = TouchCapsule;

	if (Role == ROLE_Authority)	{
		static ConstructorHelpers::FObjectFinder<UClass> PlayerPawnBPClass(TEXT("/Game/Blueprints/MyCharacter.MyCharacter_C"));
		CharacterClass = PlayerPawnBPClass.Object;
	}
}
void UNavMovementComponent::UpdateNavAgent(const UCapsuleComponent& CapsuleComponent)
{
	if (ShouldUpdateNavAgentWithOwnersCollision() == false)
	{
		return;
	}

	// initialize properties from navigation system
	UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
	if (NavSys != nullptr)
	{
		NavAgentProps.NavWalkingSearchHeightScale = NavSys->GetDefaultSupportedAgentConfig().NavWalkingSearchHeightScale;
	}

	NavAgentProps.AgentRadius = CapsuleComponent.GetScaledCapsuleRadius();
	NavAgentProps.AgentHeight = CapsuleComponent.GetScaledCapsuleHalfHeight() * 2.f;
}
Esempio n. 10
0
void AShooterCharacter::OnDeath(float KillingDamage, FDamageEvent const& DamageEvent, APawn* PawnInstigator, AActor* DamageCauser)
{
	if (bIsDying)
	{
		return;
	}

	bReplicateMovement = false;
	bTearOff = true;
	bIsDying = true;

	PlayHit(KillingDamage, DamageEvent, PawnInstigator, DamageCauser, true);

	DetachFromControllerPendingDestroy();

	/* Disable all collision on capsule */
	UCapsuleComponent* CapsuleComp = GetCapsuleComponent();
	CapsuleComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
	CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);

	USkeletalMeshComponent* Mesh3P = GetMesh();
	if (Mesh3P)
	{
		Mesh3P->SetCollisionProfileName(TEXT("Ragdoll"));
	}
	SetActorEnableCollision(true);

	SetRagdollPhysics();

	/* Apply physics impulse on the bone of the enemy skeleton mesh we hit (ray-trace damage only) */
	if (DamageEvent.IsOfType(FPointDamageEvent::ClassID))
	{
		FPointDamageEvent PointDmg = *((FPointDamageEvent*)(&DamageEvent));
		{
			// TODO: Use DamageTypeClass->DamageImpulse
			Mesh3P->AddImpulseAtLocation(PointDmg.ShotDirection * 12000, PointDmg.HitInfo.ImpactPoint, PointDmg.HitInfo.BoneName);
		}
	}
	if (DamageEvent.IsOfType(FRadialDamageEvent::ClassID))
	{
		FRadialDamageEvent RadialDmg = *((FRadialDamageEvent const*)(&DamageEvent));
		{
			Mesh3P->AddRadialImpulse(RadialDmg.Origin, RadialDmg.Params.GetMaxRadius(), 100000 /*RadialDmg.DamageTypeClass->DamageImpulse*/, ERadialImpulseFalloff::RIF_Linear);
		}
	}
}
Esempio n. 11
0
AShooterPickup::AShooterPickup(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	UCapsuleComponent* CollisionComp = ObjectInitializer.CreateDefaultSubobject<UCapsuleComponent>(this, TEXT("CollisionComp"));
	CollisionComp->InitCapsuleSize(40.0f, 50.0f);
	CollisionComp->SetCollisionObjectType(COLLISION_PICKUP);
	CollisionComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
	CollisionComp->SetCollisionResponseToAllChannels(ECR_Ignore);
	CollisionComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
	RootComponent = CollisionComp;

	PickupPSC = ObjectInitializer.CreateDefaultSubobject<UParticleSystemComponent>(this, TEXT("PickupFX"));
	PickupPSC->bAutoActivate = false;
	PickupPSC->bAutoDestroy = false;
	PickupPSC->AttachParent = RootComponent;

	RespawnTime = 10.0f;
	bIsActive = false;
	PickedUpBy = NULL;

	SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy);
	bReplicates = true;
}