예제 #1
0
void AWindShaman::ServerSpawnGrenade_Implementation()
{
	FVector GrenadeLoc;
	FRotator GrenadeRot;

	GrenadeLoc = GetActorLocation();
	GrenadeRot = GetControlRotation();

	UWorld* const World = GetWorld();
	if (World != NULL)
	{
		//to add owner and instigator information
		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = Controller;
		SpawnParams.Instigator = Instigator;
		CurrentGrenade = World->SpawnActor<AVortexGrenade>(VortexClass, GrenadeLoc + GetControlRotation().RotateVector(GunOffset + 15.0f), GrenadeRot, SpawnParams);
		if (CurrentGrenade)
		{
			CurrentGrenade->AddVelocity(GetCharacterMovement()->Velocity);
		}
	}
	MakeVisible();
	FadingTime = 0.0f;

#if WRITE_METRICS
	
	ATotemPlayerController* control = Cast<ATotemPlayerController>(Controller);
	if (control)
	{
		ATotemPlayerState* state = Cast<ATotemPlayerState>(control->PlayerState);
		if (state)
		{
			std::string team;
			switch (state->Team)
			{
			case ETeam::RED_TEAM:
				team = "Red";
				break;
			case ETeam::BLUE_TEAM:
				team = "Blue";
				break;
			default:
				team = "None";
				break;
			}
			Metrics::WriteToFile(std::string(TCHAR_TO_UTF8(*(state->MyName))), team, std::string("Vortex grenade"));
		}
	}
#endif
}
예제 #2
0
void APlayerCharacter::SpawnKeeper()
{
    if (Role < ROLE_Authority)
    {
        return;
    }

    // try and fire a projectile
    if (KeeperClass)
    {
        FournoidUtils::BlueMessage(TEXT("Spwaning Keeper"));
        // Get the actors rotation caused by control in world space.
        const FRotator SpawnRotation = GetControlRotation();
        // Tarnsform the SpawnOffset from local space to world space.
        const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(SpawnOffset);

        UWorld* const World = GetWorld();
        if (World)
        {
            FournoidUtils::BlueMessage(TEXT("Spwaning..."));
            // spawn the projectile at the muzzle
            auto SpawnedKeeper = World->SpawnActor<AFournoidKeeper>(KeeperClass, SpawnLocation, SpawnRotation);
            SpawnedKeeper->SetKeeperMaster(this);
        }
    }
}
bool AKinectPlayerController::FindDeathCameraSpot(FVector& CameraLocation, FRotator& CameraRotation)
{

	const FVector PawnLocation = GetPawn()->GetActorLocation();
	FRotator ViewDir = GetControlRotation();
	ViewDir.Pitch = -45.0f;

	const float YawOffsets[] = { 0.0f, -180.0f, 90.0f, -90.0f, 45.0f, -45.0f, 135.0f, -135.0f };
	const float CameraOffset = 600.0f;
	FCollisionQueryParams TraceParams(TEXT("DeathCamera"), true, GetPawn());

	for (int32 i = 0; i < ARRAY_COUNT(YawOffsets); i++)
	{
		FRotator CameraDir = ViewDir;
		CameraDir.Yaw += YawOffsets[i];
		CameraDir.Normalize();

		const FVector TestLocation = PawnLocation - CameraDir.Vector() * CameraOffset;
		const bool bBlocked = GetWorld()->LineTraceTest(PawnLocation, TestLocation, ECC_Camera, TraceParams);

		if (!bBlocked)
		{
			CameraLocation = TestLocation;
			CameraRotation = CameraDir;
			return true;
		}
	}

	return false;
}
void AMobileOpenCVCharacter::OnFire()
{ 
	// try and fire a projectile
	if (ProjectileClass != NULL)
	{
		const FRotator SpawnRotation = GetControlRotation();
		// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
		const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

		UWorld* const World = GetWorld();
		if (World != NULL)
		{
			// spawn the projectile at the muzzle
			World->SpawnActor<AMobileOpenCVProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);
		}
	}

	// try and play the sound if specified
	if (FireSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
	}

	// try and play a firing animation if specified
	if(FireAnimation != NULL)
	{
		// Get the animation object for the arms mesh
		UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
		if(AnimInstance != NULL)
		{
			AnimInstance->Montage_Play(FireAnimation, 1.f);
		}
	}

}
예제 #5
0
void AAIController::UpdateControlRotation(float DeltaTime, bool bUpdatePawn)
{
	// Look toward focus
	FVector FocalPoint = GetFocalPoint();
	APawn* const Pawn = GetPawn();

	if (Pawn)
	{
		FVector Direction = FAISystem::IsValidLocation(FocalPoint) ? (FocalPoint - Pawn->GetPawnViewLocation()) : Pawn->GetActorForwardVector();
		FRotator NewControlRotation = Direction.Rotation();

		// Don't pitch view unless looking at another pawn
		if (Cast<APawn>(GetFocusActor()) == nullptr)
		{
			NewControlRotation.Pitch = 0.f;
		}
		NewControlRotation.Yaw = FRotator::ClampAxis(NewControlRotation.Yaw);

		if (GetControlRotation().Equals(NewControlRotation, 1e-3f) == false)
		{
			SetControlRotation(NewControlRotation);

			if (bUpdatePawn)
			{
				Pawn->FaceRotation(NewControlRotation, DeltaTime);
			}
		}
	}
}
예제 #6
0
void AController::SetControlRotation(const FRotator& NewRotation)
{
	ControlRotation = NewRotation;

	if (RootComponent && RootComponent->bAbsoluteRotation)
	{
		RootComponent->SetWorldRotation(GetControlRotation());
	}
}
void AUDKPresentationCharacter::OnFire()
{ 
	if (CharacterMovement->IsMovingOnGround()) {
		ammo = maxAmmo;
	}
	if (ammo <= 0) return;
	// try and fire a projectile
	if (ProjectileClass != NULL)
	{
		const FRotator SpawnRotation = GetControlRotation();
		// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
		const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

		ammo--;
		CharacterMovement->Velocity = GetControlRotation().Vector()*(-1000) + 0.5f * CharacterMovement->Velocity;

		UWorld* const World = GetWorld();
		if (World != NULL)
		{
			// spawn the projectile at the muzzle
			World->SpawnActor<AUDKPresentationProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);
		}
	}

	// try and play the sound if specified
	if (FireSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
	}

	// try and play a firing animation if specified
	if(FireAnimation != NULL)
	{
		// Get the animation object for the arms mesh
		UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
		if(AnimInstance != NULL)
		{
			AnimInstance->Montage_Play(FireAnimation, 1.f);
		}
	}

}
void APlayableCharacter::MoveForward(float Step)
{
	/*
	const FRotator rot = GetControlRotation();	// Получаем Rotator контроллера
	const newRot = FRotator(0, rot.Yaw, 0);		// Но нам не нужен весь Ротатор, а только поворот(Yaw)
	const FVector dir = FRotationMatrix(newRot)::GetUnitAxis(EAxis::X);	// Выделяем из нового Ротатора вектор вперед Персонажа
	AddMovementInput(dir, Step);	// и добавляем движение на этот вектор
	 */

	const FVector direction = FRotationMatrix(FRotator(0, GetControlRotation().Yaw, 0)).GetUnitAxis(EAxis::X);
	AddMovementInput(direction, Step);
}
예제 #9
0
void AOutsiderCharacter::OnFire()
{
	const FRotator SpawnRotation = GetControlRotation();
	// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
	const FVector SpawnLocation = ((FP_MuzzleLocation != nullptr) ? FP_MuzzleLocation->GetComponentLocation() : GetActorLocation()) + SpawnRotation.RotateVector(GunOffset);

	UWorld* const World = GetWorld();
	if (World != NULL)
	{
		// spawn the projectile at the muzzle
		World->SpawnActor<AOutsiderProjectile>(AOutsiderProjectile::StaticClass(), SpawnLocation, SpawnRotation);
	}
}
void AUnrealRpgPlayerController::MoveStrafe(float value) {
	if (GetPawn() != NULL && value != 0.0f)
	{
		// find out which way is right
		const FRotator RotationControlSpace = GetControlRotation();
		const FRotator YawRotation(0, RotationControlSpace.Yaw, 0);
		// get right vector 
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		// add movement in that direction
		GetPawn()->AddMovementInput(Direction, value);
	}
	MoveValX = value;
}
void AUnrealRpgPlayerController::MoveForwardBack(float value) {
	if (GetPawn() != NULL && value != 0.0f) {
		// find out which way is forward
		const FRotator RotationControlSpace = GetControlRotation();
		const FRotator YawRotation(0, RotationControlSpace.Yaw, 0);
		// get forward vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		//const FVector Direction = FRotationMatrix(ControlSpaceRot).GetScaledAxis(EAxis::Y)
		// transform to world space and add it
		GetPawn()->AddMovementInput(Direction, value);
	}
	MoveValY = value;
}
예제 #12
0
float AMurphysLawCharacter::TakeDamage(float DamageAmount, struct FDamageEvent const & DamageEvent, class AController * EventInstigator, AActor * DamageCauser)
{
	float ActualDamage = 0.f;

	if (CurrentHealth > 0.f)
	{
		if (Role == ROLE_Authority)
		{
			ActualDamage = Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);

			// If the player actually took damage
			if (ActualDamage > 0.f)
			{
				// If the character has a HUD, we show the damages on it
				auto MyController = Cast<AMurphysLawPlayerController>(GetController());
				if (MyController != nullptr)
				{
					// We start by getting best info on the hit
					FVector ImpulseDirection;
					FHitResult Hit;
					DamageEvent.GetBestHitInfo(this, DamageCauser, Hit, ImpulseDirection);

					// We calculate the vector from the character to the damage causer
					FVector2D HitVector = FVector2D(FRotationMatrix(GetControlRotation()).InverseTransformVector(-ImpulseDirection));
					HitVector.Normalize();

					// We compute the vector representing the ForwardVector
					FVector2D StraightVector = FVector2D(1.f, 0.f);
					StraightVector.Normalize();

					// Finally, we calculate the angle where the hit came from
					float Angle = UKismetMathLibrary::DegAcos(FVector2D::DotProduct(StraightVector, HitVector));

					// The angle ranges from -180.f to 180.f
					Angle = HitVector.Y < 0.f ? -Angle : Angle;

					// Dispatch to the controller
					MyController->ShowDamage(Angle);
				}
			}
		}
		else
		{
			// Let the server do it
			Server_TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
		}
	}

	return ActualDamage;
}
void ACinemotusPlayerController::HandleMovementAbs(float DeltaTime, bool useHydraMotion = false)
{
	APawn* pawn = GetPawn();
	if (!pawn)
	{
		return;
	}

	

	//check velocities
	FVector velocity = useHydraMotion ? HydraLatestData->controllers[CAM_HAND].velocity : FVector::ZeroVector;
	FVector velRel = FVector(velocity);
	FRotationMatrix mat(GetControlRotation());
	float scalar = 2.5;
	if (useHydraMotion)
	{
		FRotationMatrix cMat(HydraLatestData->controllers[CAM_HAND].rotation);
		velRel.X = FVector::DotProduct(cMat.GetScaledAxis(EAxis::X), velocity);
		velRel.Y = FVector::DotProduct(cMat.GetScaledAxis(EAxis::Y), velocity);
		velRel.Z = FVector::DotProduct(cMat.GetScaledAxis(EAxis::Z), velocity); //take motion and make relative to the orientation of the controller
	}
	//velocity.X*DeltaTime * scaleCmToMetres*fSpeedMulitplier +

	pawn->AddMovementInput(mat.GetScaledAxis(EAxis::X), velRel.X*DeltaTime * scalar*fSpeedMulitplier + vXYandCrane.X);
	pawn->AddMovementInput(mat.GetScaledAxis(EAxis::Y), velRel.Y*DeltaTime * scalar*fSpeedMulitplier + vXYandCrane.Y);
	pawn->AddMovementInput(mat.GetScaledAxis(EAxis::Z), velRel.Z*DeltaTime * scalar*fSpeedMulitplier);
	pawn->AddMovementInput(FVector::UpVector, vXYandCrane.Z);


	//Add Movement input for offhand

	FVector xPlanar = mat.GetScaledAxis(EAxis::X);
	xPlanar.Z = 0;
	bool didNorm = xPlanar.Normalize();
	if (!didNorm)
	{ 
		xPlanar.X = 1.0; xPlanar.Normalize(); }
	pawn->AddMovementInput(xPlanar, offHandPlanarMovement.X);


	FVector yPlanar = mat.GetScaledAxis(EAxis::Y);
	yPlanar.Z = 0;
	didNorm = yPlanar.Normalize();
	if (!didNorm) { yPlanar.Y = 1.0; yPlanar.Normalize(); }
	pawn->AddMovementInput(yPlanar, offHandPlanarMovement.Y);



}
예제 #14
0
void AController::SetControlRotation(const FRotator& NewRotation)
{
	if (!ControlRotation.Equals(NewRotation, 1e-3f))
	{
		ControlRotation = NewRotation;

		if (RootComponent && RootComponent->bAbsoluteRotation)
		{
			RootComponent->SetWorldRotation(GetControlRotation());
		}
	}
	else
	{
		//UE_LOG(LogPlayerController, Log, TEXT("Skipping SetControlRotation for %s (Pawn %s)"), *GetNameSafe(this), *GetNameSafe(GetPawn()));
	}
}
예제 #15
0
void AController::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if ( !IsPendingKill() )
	{
		GetWorld()->AddController( this );

		// Since we avoid updating rotation in SetControlRotation() if it hasn't changed,
		// we should make sure that the initial RootComponent rotation matches it if ControlRotation was set directly.
		if (RootComponent && RootComponent->bAbsoluteRotation)
		{
			RootComponent->SetWorldRotation(GetControlRotation());
		}
	}
}
예제 #16
0
void ASearchFinalCharacter::OnSearch()
{
	AActor *hitActor;

	FVector CameraOrigin;
	FQuat OutOrientation;
	float OutHFOV, OutVFOV, OutCameraDistance, OutNearPlane, OutFarPlane;
	GEngine->HMDDevice->GetPositionalTrackingCameraProperties(CameraOrigin, OutOrientation, OutHFOV, OutVFOV, OutCameraDistance, OutNearPlane, OutFarPlane);

	FHitResult *hit = new FHitResult;
	FVector start = FirstPersonCameraComponent->GetComponentLocation();
	//FVector start = CameraOrigin;
	FVector dir = FirstPersonCameraComponent->GetForwardVector();
	FVector end = start + GetControlRotation().Vector() * 150;


	FCollisionQueryParams *traceParams = new FCollisionQueryParams;
	traceParams->bTraceComplex = true;
	traceParams->bTraceAsyncScene = true;
	traceParams->bReturnPhysicalMaterial = false;

	GetWorld()->LineTraceSingleByChannel(*hit, start, end, ECC_Visibility, *traceParams);
	if (hit->bBlockingHit)
	{
		DrawDebugLine(
			GetWorld(),
			start, // Start Trace
			hit->Location, // Hit Result Location
			FColor(255, 0, 0), // Red
			false, // Persistent Lines
			2.0, // Time
			0, // Depth Priority
			2.0 // Thickness
		);

		hitActor = Cast<AActor>(hit->Actor.Get());
		GEngine->AddOnScreenDebugMessage(0, 3.f, FColor::Red, "Hit");

		if (hitActor->GetActorLabel().Contains(TEXT("SearchObj"), ESearchCase::IgnoreCase, ESearchDir::FromEnd)) {
			ASearchObj *hitSearchObj = Cast<ASearchObj>(hitActor);
			hitSearchObj->Search();
		}
	}
	else {
		GEngine->AddOnScreenDebugMessage(0, 3.f, FColor::Red, "No Hit ");
	}
}
예제 #17
0
void AWindShaman::ServerSpawnCyclone_Implementation()
{
	FVector CycloneLoc;
	FRotator CycloneRot;

	CycloneLoc = GetActorLocation();
	CycloneRot = GetControlRotation();

	UWorld* const World = GetWorld();
	if (World != NULL)
	{
		//to add owner and instigator information
		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = Controller;
		SpawnParams.Instigator = Instigator;
		World->SpawnActor<ACyclone>(CycloneClass, CycloneLoc, CycloneRot, SpawnParams);
	}
	MakeVisible();
	FadingTime = 0.0f;

#if WRITE_METRICS

	ATotemPlayerController* control = Cast<ATotemPlayerController>(Controller);
	if (control)
	{
		ATotemPlayerState* state = Cast<ATotemPlayerState>(control->PlayerState);
		if (state)
		{
			std::string team;
			switch (state->Team)
			{
			case ETeam::RED_TEAM:
				team = "Red";
				break;
			case ETeam::BLUE_TEAM:
				team = "Blue";
				break;
			default:
				team = "None";
				break;
			}
			Metrics::WriteToFile(std::string(TCHAR_TO_UTF8(*(state->MyName))), team, std::string("Cyclone"));
		}
	}
#endif
}
예제 #18
0
void ATotemCharacter::OnFire()
{
	//only server can spawn projectile theoretically
	// try and fire a projectile
	if (ProjectileClass != NULL || FireProjectileClass != NULL)
	{
		const FRotator SpawnRotation = GetControlRotation();
		// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
		const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

		UWorld* const World = GetWorld();
		if (World != NULL)
		{
			//to add owner and instigator information
			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = Cast<ATotemPlayerController>(Controller);
			SpawnParams.Instigator = Instigator;
			//When the server function is called by serve, it also execute. 
			ServerSpawnProjectile(SpawnLocation, SpawnRotation, SpawnParams.Owner, SpawnParams.Instigator);
			// spawn the projectile at the muzzle single player version
			//World->SpawnActor<ATotemProjectile>(ProjectileClass, SpawnLocation, SpawnRotation, SpawnParams);
		}
	}


	// try and play the sound if specified
	if (FireSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
	}

	// try and play a firing animation if specified
	if (FireAnimation != NULL)
	{
		// Get the animation object for the arms mesh
		UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
		if (AnimInstance != NULL)
		{
			AnimInstance->Montage_Play(FireAnimation, 1.f);
		}
	}

}
예제 #19
0
void AFPSHorrorCharacter::ShootBloodBall()
{
	Health -= 10;
	if (Health <= 0)
	{
		LoadMainMenu();
	}
	if (ProjectileClass != NULL)
	{
		const FRotator SpawnRotation = GetControlRotation();
		// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
		//const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

		const FVector SpawnLocation = GetActorLocation();

		UWorld* const World = GetWorld();
		if (World != NULL)
		{
			// spawn the projectile at the muzzle
			World->SpawnActor<AFPSHorrorProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);
		}
	}
}
예제 #20
0
void AAIController::UpdateControlRotation(float DeltaTime, bool bUpdatePawn)
{
    APawn* const MyPawn = GetPawn();
    if (MyPawn)
    {
        FRotator NewControlRotation = GetControlRotation();

        // Look toward focus
        const FVector FocalPoint = GetFocalPoint();
        if (FAISystem::IsValidLocation(FocalPoint))
        {
            NewControlRotation = (FocalPoint - MyPawn->GetPawnViewLocation()).Rotation();
        }
        else if (bSetControlRotationFromPawnOrientation)
        {
            NewControlRotation = MyPawn->GetActorRotation();
        }

        // Don't pitch view unless looking at another pawn
        if (NewControlRotation.Pitch != 0 && Cast<APawn>(GetFocusActor()) == nullptr)
        {
            NewControlRotation.Pitch = 0.f;
        }

        SetControlRotation(NewControlRotation);

        if (bUpdatePawn)
        {
            const FRotator CurrentPawnRotation = MyPawn->GetActorRotation();

            if (CurrentPawnRotation.Equals(NewControlRotation, 1e-3f) == false)
            {
                MyPawn->FaceRotation(NewControlRotation, DeltaTime);
            }
        }
    }
}
// Called every frame
void APlayerCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (isWalkingForward || isWalkingRight)
	{
		if (CanJump())
			UGameplayStatics::PlaySoundAtLocation(GetWorld(), WalkSound, GetActorLocation());
	}
	if (isJumpingGruntCheck)
	{
		UGameplayStatics::PlaySoundAtLocation(GetWorld(), GruntSound, GetActorLocation());
		isJumpingGruntCheck = false;
	}

	if (GetVelocity().Z == 0 && isJumpingGroundCheck)
	{
		UGameplayStatics::PlaySoundAtLocation(GetWorld(), JumpSound, GetActorLocation());
		isJumpingGroundCheck = false;

		UPeterAnimInstance* PeterAnimInstance = Cast<UPeterAnimInstance>(GetMesh()->GetAnimInstance());

		if (PeterAnimInstance)
		{
		}

	}
	if (CameraIsChanging == true)
	{
		UpdateCamera(FantasyCounter);
	}
	if (ShowTime == true)
	{
		FadeToWhite();
	}

	if (PhysicsHandleActive)
	{
		if (PhysicsHandler)
		{
			FVector HandleLocation;

			FVector ControllerForwardVector = UKismetMathLibrary::GetForwardVector(GetControlRotation());

			HandleLocation = ControllerForwardVector * 250 + GetActorLocation();

			HandleLocation.Z += 50;

			PhysicsHandler->SetTargetLocationAndRotation(HandleLocation, GetControlRotation());
		}
	}
	else if (PhysicsHandleActive == false)
	{
		PhysicsHandler->ReleaseComponent();
		if (PickedUpBox)
		{
			PickedUpBox->Drop(this);
		}
	}

	UPeterAnimInstance* PeterAnimInstance = Cast<UPeterAnimInstance>(GetMesh()->GetAnimInstance());
}
예제 #22
0
void AWindShaman::ServerSpawnAirCurrent_Implementation()
{
		UWorld* const World = GetWorld();
		if (World)
		{
			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = Controller;
			SpawnParams.Instigator = Instigator;

			AAirCurrent* const AirCurrent = World->SpawnActor<AAirCurrent>(AirCurrentClass, GetActorLocation(), GetControlRotation(), SpawnParams);

			if (Currents.size() >= MaxAirCurrents)
			{
				AAirCurrent* current = Currents[0];
				RemoveAirCurrent(current);
			}
			Currents.push_back(AirCurrent);
			if (AirCurrent)
			{
				AirCurrent->Caster = this;
			}
		}
		MakeVisible();
		FadingTime = 0.0f;

#if WRITE_METRICS
		
		ATotemPlayerController* control = Cast<ATotemPlayerController>(Controller);
		if (control)
		{
			ATotemPlayerState* state = Cast<ATotemPlayerState>(control->PlayerState);
			if (state)
			{
				std::string team;
				switch (state->Team)
				{
				case ETeam::RED_TEAM:
					team = "Red";
					break;
				case ETeam::BLUE_TEAM:
					team = "Blue";
					break;
				default:
					team = "None";
					break;
				}
				Metrics::WriteToFile(std::string(TCHAR_TO_UTF8(*(state->MyName))), team, std::string("Air current"));
			}
		}
#endif
}
예제 #23
0
void AWizardsCharacter::OnFire()
{
	if (!mySpellBook.IsValidIndex(0)) {
		UE_LOG(LogTemp, Warning, TEXT("Spell Gathering Needed!"));
		newCharactersSpells();
	}
	if (Mana > mySpellBook[currSpell].spellCost) {
		Mana -= mySpellBook[currSpell].spellCost;
		// try and fire a projectile

		if (mySpellBook[currSpell].spellType == 0)
		{
			const FRotator SpawnRotation = GetControlRotation();
			const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

			UWorld* const World = GetWorld();
			if (World)
			{
				// spawn the projectile at the muzzle
				/*UParticleSystem* projParticle = particleList[mySpellBook[currSpell].spellEffect + mySpellBook[currSpell].spellType * 5];
				UParticleSystem* blastParticle = particleList[mySpellBook[currSpell].spellEffect + 5];
				AWizardsProjectile* wizardsSpell = World->SpawnActor<AWizardsProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);// , myparams);
				wizardsSpell->SpellCreation(&mySpellBook[currSpell], projParticle, blastParticle, this);*/
				if (Role < ROLE_Authority)
				{
					ServerFireProjectile(mySpellBook[currSpell], SpawnRotation, SpawnLocation);//mySpellBook[currSpell]);
				}
				else {
					ClientFireProjectile(mySpellBook[currSpell], SpawnRotation, SpawnLocation);
				}
			}
		}
		else if (mySpellBook[currSpell].spellType == 1) {
			const FRotator SpawnRotation = FRotator(0.0);//GetControlRotation();
														 // MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
			const FVector SpawnLocation = FVector(0.0);//GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

			UWorld* const World = GetWorld();
			if (World)
			{
				// spawn the projectile at the muzzle
				/*UParticleSystem* blastParticle = particleList[mySpellBook[currSpell].spellEffect + mySpellBook[currSpell].spellType * 5];
				AWizardsBlast* wizardsSpell = World->SpawnActor<AWizardsBlast>(BlastClass, SpawnLocation, SpawnRotation);// , myparams);
				wizardsSpell->SpellCreation(blastParticle, mySpellBook[currSpell].spellSize, mySpellBook[currSpell].spellDamage, this);
				wizardsSpell->AttachRootComponentTo(GetCapsuleComponent());//Probably useful for Blasts, Rays, and Conical attacks*/
				if (Role < ROLE_Authority)
				{
					ServerFireProjectile(mySpellBook[currSpell], SpawnRotation, SpawnLocation);
				}
				else {
					ClientFireProjectile(mySpellBook[currSpell], SpawnRotation, SpawnLocation);
				}
			}
		}
		else if (mySpellBook[currSpell].spellType == 2) {
			const FRotator SpawnRotation = FRotator(0.0);//GetControlRotation();
														 // MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
			const FVector SpawnLocation = FVector(0.0);//GetActorLocation() + SpawnRotation.RotateVector(GunOffset);

			UWorld* const World = GetWorld();
			if (World)
			{
				// spawn the projectile at the muzzle
				/*UParticleSystem* coneParticle = particleList[mySpellBook[currSpell].spellEffect + mySpellBook[currSpell].spellType * 5];
				AWizardsCone* wizardsCone = World->SpawnActor<AWizardsCone>(ConeClass, SpawnLocation, SpawnRotation);// , myparams);
				wizardsCone->SpellCreation(coneParticle, mySpellBook[currSpell].spellSize, mySpellBook[currSpell].spellDamage, this);
				wizardsCone->AttachRootComponentTo(GetCapsuleComponent());//Probably useful for Blasts, Rays, and Conical attacks
				activeAttack = Cast<AActor>(wizardsCone);*/
				if (Role < ROLE_Authority)
				{
					ServerFireProjectile(mySpellBook[currSpell], SpawnRotation, SpawnLocation);
				}
				else {
					ClientFireProjectile(mySpellBook[currSpell], SpawnRotation, SpawnLocation);
				}
			}
		}
		// God this sound is so annoying
		/*if (FireSound != NULL)
		{
		UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
		}*/

		// try and play a firing animation if specified
		if (FireAnimation != NULL)
		{
			// Get the animation object for the arms mesh
			UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
			if (AnimInstance != NULL)
			{
				AnimInstance->Montage_Play(FireAnimation, 1.f);
			}
		}

	}
}
예제 #24
0
FRotator AController::GetDesiredRotation() const
{
	return GetControlRotation();
}
예제 #25
-1
void ABaseCharacter::moveRight(float Val)
{
    //Positive values correspond to moving positively along the X axis
    if(Controller != NULL && Val != 0.0f)
    {
        FRotator dir = GetControlRotation();
        dir.Yaw = (Val > 0.0f ? 0.0f : 180.0f);
        GetController()->SetControlRotation(dir);

        FRotator v = GetActorRotation();
        v.Yaw = dir.Yaw;
        SetActorRotation(v);

        AddMovementInput(FVector(1.0f, 0.0f, 0.0f), Val);
    }
}
/*	Метод из домашнего задания
 *	Здесь мы делаем ровным счетом то же самое, что и в методе MoveForward, 
 *	с разницей в том, что получаем вектор вправо Персонажа (вправо в Unreal'e - ось Y)
 */
void APlayableCharacter::MoveRight(float Step)
{
	const FVector direction = FRotationMatrix(FRotator(0, GetControlRotation().Yaw, 0)).GetUnitAxis(EAxis::Y);
	AddMovementInput(direction, Step);
}