bool FEdModeGeometry::GetCustomDrawingCoordinateSystem( FMatrix& InMatrix, void* InData )
{
	if( GetSelectionState() == GSS_None )
	{
		return 0;
	}

	if( InData )
	{
		InMatrix = FRotationMatrix( ((FGeomBase*)InData)->GetNormal().Rotation() );
	}
	else
	{
		// If we don't have a specific geometry object to get the normal from
		// use the one that was last selected.

		for( int32 o = 0 ; o < GeomObjects.Num() ; ++o )
		{
			FGeomObject* go = GeomObjects[o];
			go->CompileSelectionOrder();

			if( go->SelectionOrder.Num() )
			{
				InMatrix = FRotationMatrix( go->SelectionOrder[ go->SelectionOrder.Num()-1 ]->GetWidgetRotation() );
				return 1;
			}
		}
	}

	return 0;
}
Example #2
0
void ACharacter::PostNetReceiveBase()
{	
	const bool bBaseChanged = (RelativeMovement.MovementBase != MovementBase);
	if (bBaseChanged)
	{
		SetBase(RelativeMovement.MovementBase);
	}

	if (RelativeMovement.HasRelativePosition())
	{
		if (bBaseChanged || (RelativeMovement.Location != SavedRelativeLocation) || (RelativeMovement.Rotation != SavedRelativeRotation))
		{
			const FVector OldLocation = GetActorLocation();
			const FRotator NewRotation = (FRotationMatrix(RelativeMovement.Rotation) * FRotationMatrix(MovementBase->GetComponentRotation())).Rotator();
			SetActorLocationAndRotation( MovementBase->GetComponentLocation() + RelativeMovement.Location, NewRotation, false);

			INetworkPredictionInterface* PredictionInterface = InterfaceCast<INetworkPredictionInterface>(GetMovementComponent());
			if (PredictionInterface)
			{
				PredictionInterface->SmoothCorrection(OldLocation);
			}
		}
	}

	if ( CharacterMovement )
	{
		CharacterMovement->bJustTeleported = false;
	}
}
Example #3
0
/**	Change the Pawn's base. */
void ACharacter::SetBase( UPrimitiveComponent* NewBaseComponent, bool bNotifyPawn )
{
	if (NewBaseComponent != MovementBase)
	{
		// Verify no recursion.
		APawn* Loop = (NewBaseComponent ? Cast<APawn>(NewBaseComponent->GetOwner()) : NULL);
		for(  ; Loop!=NULL; Loop=Cast<APawn>(Loop->GetMovementBase()) )
		{
			if( Loop == this )
			{
				UE_LOG(LogCharacter, Warning, TEXT(" SetBase failed! Recursion detected. Pawn %s already based on %s."), *GetName(), *NewBaseComponent->GetName());
				return;
			}
		}

		// Set base.
		MovementBase = NewBaseComponent;

		if (Role == ROLE_Authority)
		{
			// Update replicated value
			UE_LOG(LogCharacter, Verbose, TEXT("Setting base on server for '%s' to '%s'"), *GetName(), *GetFullNameSafe(NewBaseComponent));
			RelativeMovement.MovementBase = NewBaseComponent;
			RelativeMovement.bServerHasBaseComponent = (NewBaseComponent != NULL); // Flag whether the server had a non-null base.
		}
		else
		{
			UE_LOG(LogCharacter, Verbose, TEXT("Setting base on CLIENT for '%s' to '%s'"), *GetName(), *GetFullNameSafe(NewBaseComponent));
		}

		// Update relative location/rotation
		if ( Role == ROLE_Authority || Role == ROLE_AutonomousProxy )
		{
			if (MovementBaseUtility::UseRelativePosition(MovementBase))
			{
				RelativeMovement.Location = GetActorLocation() - MovementBase->GetComponentLocation();
				RelativeMovement.Rotation = (FRotationMatrix(GetActorRotation()) * FRotationMatrix(MovementBase->GetComponentRotation()).GetTransposed()).Rotator();
			}
		}

		// Notify this actor of his new floor.
		if ( bNotifyPawn )
		{
			BaseChange();
		}

		if (MovementBase && CharacterMovement)
		{
			// Update OldBaseLocation/Rotation as those were referring to a different base
			CharacterMovement->OldBaseLocation = MovementBase->GetComponentLocation();
			CharacterMovement->OldBaseRotation = MovementBase->GetComponentRotation();
		}
	}
}
Example #4
0
void UCheatManager::DamageTarget(float DamageAmount)
{
	APlayerController* const MyPC = GetOuterAPlayerController();
	if ((MyPC == NULL) || (MyPC->PlayerCameraManager == NULL))
	{
		return;
	}

	check(GetWorld() != NULL);
	FVector const CamLoc = MyPC->PlayerCameraManager->GetCameraLocation();
	FRotator const CamRot = MyPC->PlayerCameraManager->GetCameraRotation();

	FCollisionQueryParams TraceParams(NAME_None, true, MyPC->GetPawn());
	FHitResult Hit;
	bool bHit = GetWorld()->LineTraceSingle(Hit, CamLoc, CamRot.Vector() * 100000.f + CamLoc, ECC_Pawn, TraceParams);
	if (bHit)
	{
		check(Hit.GetActor() != NULL);
		FVector ActorForward, ActorSide, ActorUp;
		FRotationMatrix(Hit.GetActor()->GetActorRotation()).GetScaledAxes(ActorForward, ActorSide, ActorUp);

		FPointDamageEvent DamageEvent(DamageAmount, Hit, -ActorForward, UDamageType::StaticClass());
		Hit.GetActor()->TakeDamage(DamageAmount, DamageEvent, MyPC, MyPC->GetPawn());
	}
}
Example #5
0
void AFPSGCharacter::moveRight(float moveValue)
{
	//Dont execute this input if the in game menu is open
	if (isInGameMenuOpen()) return;

	if (Controller != NULL && moveValue != 0.0f)
	{
		//Retrieve the viewing/aiming direction of the controlled pawn
		FRotator rotation = Controller->GetControlRotation();

		//Move the character
		const FVector moveDirection = FRotationMatrix(rotation).GetScaledAxis(EAxis::Y);
		AddMovementInput(moveDirection, moveValue);

		if (moveValue == 1.0f)
		{
			if (movementDirection != EMoveDirection::RIGHT)
			{
				serverUpdateMovementDirection(static_cast<uint8>(EMoveDirection::RIGHT));
			}
		}
		if (moveValue == -1.0f)
		{
			if (movementDirection != EMoveDirection::LEFT)
			{
				serverUpdateMovementDirection(static_cast<uint8>(EMoveDirection::LEFT));
			}
		}
	}
}
Example #6
0
void ANimModCharacter::OnCameraUpdate(const FVector& PreviousCameraLocation, const FVector& CameraLocation, const FRotator& CameraRotation)
{
	USkeletalMeshComponent* DefMesh1P = Cast<USkeletalMeshComponent>(GetClass()->GetDefaultSubobjectByName(TEXT("PawnMesh1P")));
	//USkeletalMeshComponent* DefMesh1P = Mesh1P;
	const FMatrix DefMeshLS = FRotationTranslationMatrix(DefMesh1P->RelativeRotation, DefMesh1P->RelativeLocation);
	const FMatrix LocalToWorld = ActorToWorld().ToMatrixWithScale();

	// Mesh rotating code expect uniform scale in LocalToWorld matrix

	const FRotator RotCameraPitch(CameraRotation.Pitch, 0.0f, 0.0f);
	const FRotator RotCameraYaw(0.0f, CameraRotation.Yaw, 0.0f);

	const FMatrix LeveledCameraLS = FRotationTranslationMatrix(RotCameraYaw, CameraLocation) * LocalToWorld.Inverse();
	const FMatrix PitchedCameraLS = FRotationMatrix(RotCameraPitch) * LeveledCameraLS;
	const FMatrix MeshRelativeToCamera = DefMeshLS * LeveledCameraLS.Inverse();
	const FMatrix PitchedMesh = MeshRelativeToCamera * PitchedCameraLS;

	//FVector origin = PitchedMesh.GetOrigin();
	FVector origin = Mesh1P->GetRelativeTransform().GetLocation();
	//FVector originalLocation = Mesh1P->GetRelativeTransform().GetLocation();
	////FVector origin = Mesh1P->ComponentToWorld.GetLocation();
	//if (bIsCrouched)
	//{
	//	//origin.Z = (origin.Z - (DefaultBaseEyeHeight - DefMesh1P->RelativeLocation.Z));
	//	origin.Z = (PreviousCameraLocation.Z - CameraLocation.Z);
	//}

	Mesh1P->SetRelativeLocationAndRotation(origin, PitchedMesh.Rotator(), false, nullptr, ETeleportType::TeleportPhysics);
	/*FVector newLocation = Mesh1P->GetRelativeTransform().GetLocation();
	int i = -1;*/
}
void ACoverSystemCharacter::MoveRight(float Value)
{
	//for the animation bp
	CoverValue = Value;

	if ((Controller != NULL) && (Value != 0.0f))
	{
		if (!bIsInCover)
		{
			//default movement functionality

			// find out which way is right
			const FRotator Rotation = Controller->GetControlRotation();
			const FRotator YawRotation(0, Rotation.Yaw, 0);

			// get right vector 
			FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
			AddMovementInput(Direction, Value);
		}
		else
		{
			//Move according to the cover actor's position
			AddMovementInput(CoverDirectionMovement, Value);
		}
	}
}
Example #8
0
// Called every frame
void AMonster::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	ARaiderCharacter *avatar = Cast<ARaiderCharacter>(UGameplayStatics::GetPlayerPawn(GetWorld(), 0));
	if (!avatar) return;
	FVector toPlayer = avatar->GetActorLocation() -	GetActorLocation();
	
	this->GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction

	float distanceToPlayer = toPlayer.Size();
	// If the player is not in the SightSphere of the monster,
	// go back
	if (distanceToPlayer > SightSphere->GetScaledSphereRadius())
	{
		// If the player is out of sight,
		// then the enemy cannot chase
		return;
	}
	toPlayer /= distanceToPlayer; // normalizes the vector
	
	FRotator Rotation = toPlayer.Rotation();
	const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
	AddMovementInput(Direction, m_fSpeed * DeltaTime);
}
Example #9
0
void ACharacter::OnRep_ReplicatedBasedMovement()
{
    if (Role != ROLE_SimulatedProxy)
    {
        return;
    }

    // Skip base updates while playing root motion, it is handled inside of OnRep_RootMotion
    if (IsPlayingNetworkedRootMotionMontage())
    {
        return;
    }

    TGuardValue<bool> bInBaseReplicationGuard(bInBaseReplication, true);

    const bool bBaseChanged = (BasedMovement.MovementBase != ReplicatedBasedMovement.MovementBase || BasedMovement.BoneName != ReplicatedBasedMovement.BoneName);
    if (bBaseChanged)
    {
        // Even though we will copy the replicated based movement info, we need to use SetBase() to set up tick dependencies and trigger notifications.
        SetBase(ReplicatedBasedMovement.MovementBase, ReplicatedBasedMovement.BoneName);
    }

    // Make sure to use the values of relative location/rotation etc from the server.
    BasedMovement = ReplicatedBasedMovement;

    if (ReplicatedBasedMovement.HasRelativeLocation())
    {
        // Update transform relative to movement base
        const FVector OldLocation = GetActorLocation();
        const FQuat OldRotation = GetActorQuat();
        MovementBaseUtility::GetMovementBaseTransform(ReplicatedBasedMovement.MovementBase, ReplicatedBasedMovement.BoneName, CharacterMovement->OldBaseLocation, CharacterMovement->OldBaseQuat);
        const FVector NewLocation = CharacterMovement->OldBaseLocation + ReplicatedBasedMovement.Location;

        if (ReplicatedBasedMovement.HasRelativeRotation())
        {
            // Relative location, relative rotation
            FRotator NewRotation = (FRotationMatrix(ReplicatedBasedMovement.Rotation) * FQuatRotationMatrix(CharacterMovement->OldBaseQuat)).Rotator();

            // TODO: need a better way to not assume we only use Yaw.
            NewRotation.Pitch = 0.f;
            NewRotation.Roll = 0.f;

            SetActorLocationAndRotation(NewLocation, NewRotation);
        }
        else
        {
            // Relative location, absolute rotation
            SetActorLocationAndRotation(NewLocation, ReplicatedBasedMovement.Rotation);
        }

        // When position or base changes, movement mode will need to be updated. This assumes rotation changes don't affect that.
        CharacterMovement->bJustTeleported |= (bBaseChanged || GetActorLocation() != OldLocation);

        INetworkPredictionInterface* PredictionInterface = Cast<INetworkPredictionInterface>(GetMovementComponent());
        if (PredictionInterface)
        {
            PredictionInterface->SmoothCorrection(OldLocation, OldRotation);
        }
    }
}
Example #10
0
void ACloud10Character::MoveForward(float Value)
{
	if (isDiving)
	{
		float prevPitch = GetActorRotation().Pitch;
		float minDeltaPitch = minPitch - prevPitch;
		float maxDeltaPitch = maxPitch - prevPitch;
		//roll character in an angle front and back
		float curPitchAmt = Value;
		FRotator dRotation(0,0,0);
		dRotation.Pitch = FMath::ClampAngle(curPitchAmt * rotationRate, minDeltaPitch, maxDeltaPitch);
		AddActorLocalRotation(dRotation);
	}
	else
	{
		if ((Controller != NULL) && (Value != 0.0f))
		{
			// find out which way is forward
			const FRotator Rotation = Controller->GetControlRotation();
			const FRotator YawRotation(0, Rotation.Yaw, 0);

			// get forward vector
			const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
			AddMovementInput(Direction, Value);
		}
	}

}
Example #11
0
void AKIMCharacter::MoveRight(float Value) {
	if (Value < -0.09f || Value > 0.09f) {
		if (IsInRoationState) {
			RotateRight(Value*10);
			return;
		}
		if (PickedUpItem) {
			if (Value < -0.09f) {
				Value += FMath::Clamp((((AKIMInteractionActor*)PickedUpItem)->Weight / 100), 0.f, abs(Value));
			}
			else if (Value > 0.09f) {
				Value -= FMath::Clamp((((AKIMInteractionActor*)PickedUpItem)->Weight / 100), 0.f,  abs(Value));
			}
			else return;
		}

		//Value *= MovementSpeed;

		// find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// get right vector 
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		// add movement in that direction
		AddMovementInput(Direction, Value);
	}
}
Example #12
0
void AARCharacter::MoveForward(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		//if (Value < 0)
		//{
		//	float orignal = CharacterMovement->MaxWalkSpeed;
		//	CharacterMovement->MaxWalkSpeed = CharacterMovement->MaxWalkSpeed / 2;
		//	FRotator Rotation = GetBaseAimRotation();

		//	FVector Location; //not used, just need for below.
		//	//Controller->GetPlayerViewPoint(Location, Rotation);
		//	Rotation.Normalize();
		//	FRotator YawRotation(0, Rotation.Yaw, 0);
		//	//const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis( EAxis::X );
		//	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		//	AddMovementInput(Direction, Value);
		//	CharacterMovement->MaxWalkSpeed = orignal;
		//	return;
		//}
		FRotator Rotation = GetBaseAimRotation();

		FVector Location; //not used, just need for below.
		//Controller->GetPlayerViewPoint(Location, Rotation);
		Rotation.Normalize();
		FRotator YawRotation(0, Rotation.Yaw, 0);
		//const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis( EAxis::X );
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		AddMovementInput(Direction, Value);
	}
}
void AZombieShooterCharacter::MoveUp(float Value)
{
	const FRotator Rotation = TopDownCameraComponent->GetComponentRotation();
	const FRotator YawRotation(0.0f, Rotation.Yaw, 0.0f);

	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	AddMovementInput(Direction, Value);
}
Example #14
0
void ABrainCharacter::MoveSide(float value)
{
	const FRotator Rotation = Cast<ABrainPlayerController>(Controller)->GetCameraRotation();
	const FRotator YawRotation(0, Rotation.Yaw, 0);

	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
	AddMovementInput(Direction, value);
}
Example #15
0
void AKIMCharacter::MoveForward(float Value) {
	// find out which way is forward
	const FRotator Rotation = Controller->GetControlRotation();
	const FRotator YawRotation(0, Rotation.Yaw, 0);

	// get forward vector
	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	AddMovementInput(Direction, Value);
}
Example #16
0
void ANimModCharacter::MoveRight(float Val)
{
	if (Val != 0.f)
	{
		const FRotator Rotation = GetActorRotation();
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
		AddMovementInput(Direction, Val);
	}
}
/**
*	MOVEMENT FUNCTION
*	Check If player exists, get rotation value of player. Gets direction to move in.
*	Move in direction by Value passed in.
*
*	@param Rate to move
*	@return void
**/
void APlayerCharacter::MoveLeftRight(float Value)
{
	if (Value != 0.0f)
	{
		FRotator const Rotation = GetActorRotation();
		FVector const Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
		AddMovementInput(Direction, Value);
	}
}
Example #18
0
void ABrowserCharacter::MoveRight(float Val)
{
	if ((Val != 0.0f) && (Controller != NULL))
	{
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotationMatrix R = FRotationMatrix(FRotator(0, Rotation.Yaw, 0));
		const FVector WorldSpaceAccel = R.GetScaledAxis(EAxis::Y);
		AddMovementInput(WorldSpaceAccel, Val * SpeedY * (CHARACTER_MOVEMENT_SPEED(cameraZoom_current)));
	}
}
Example #19
0
void ABrowserCharacter::MoveUp(float Val)
{
	if ((Val != 0.0f) && (Controller != NULL) && bEnable3D)
	{
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotationMatrix R = FRotationMatrix(FRotator(Rotation.Pitch, 0, Rotation.Roll));
		const FVector WorldSpaceAccel = R.GetScaledAxis(EAxis::Z);
		AddMovementInput(WorldSpaceAccel, Val * SpeedZ * (CHARACTER_MOVEMENT_SPEED(cameraZoom_current)));
	}
}
Example #20
0
void AsbrPlayer::MoveRight(float value)
{
    if ((Controller != NULL) && (value != 0.0f))
    {
        const FRotator Rotation = Controller->GetControlRotation();
        const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);

        AddMovementInput(Direction, value);
    }
}
Example #21
0
void AKIMCharacter::MoveRight(float Value) {
	// find out which way is right
	const FRotator Rotation = Controller->GetControlRotation();
	const FRotator YawRotation(0, Rotation.Yaw, 0);

	// get right vector 
	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
	// add movement in that direction
	AddMovementInput(Direction, Value);
}
void ATopDown_HitmanCleanCharacter::MoveForward(float Value){
	if ((Controller != NULL) && (Value != 0.0f)){
		// find out which way is forward
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// get forward vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		AddMovementInput(Direction, Value);
	}
}
	virtual FMatrix GetWidgetCoordSystem() const override
	{
		if (Widget.IsValid() && Widget->OnGetWidgetRotation.IsBound())
		{
			return FRotationMatrix(Widget->OnGetWidgetRotation.Execute(Widget.Get()));
		}
		else
		{
			return FEditorViewportClient::GetWidgetCoordSystem();
		}
	}
Example #24
0
void ACloud10Character::DiveRight(float Value, float deltaSeconds)
{
	
	float prevYaw = GetActorRotation().Yaw;
	float minDeltaYaw = minYaw - prevYaw;
	float maxDeltaYaw = maxYaw - prevYaw;
	//roll character in an angle front and back
	curYawAmt = Value;

	/*
	const FRotator Rotation = GetActorRotation();
	FRotator dRotation(0, 0, 0);
	//curYawAmt * rotationRate
	const FVector Direction = FVector(0.0f, (curYawAmt * rotationRate), 0.0f) ;//= FRotationMatrix(Rotation).GetUnitAxis(EAxis::Z);
	dRotation = Direction.Rotation();
	dRotation.Yaw = FMath::ClampAngle(dRotation.Yaw, minDeltaYaw, maxDeltaYaw);
	//dRotation.Yaw = curYawAmt + Direction.Z;//FMath::ClampAngle(curYawAmt * Direction.Z, minDeltaYaw, maxDeltaYaw);
	//Controller->SetControlRotation(dRotation);
	//AddControllerYawInput(dRotation.Yaw);
	FRotator tempRotation = FMath::RInterpTo(Rotation, dRotation, 3, 0);
	AddActorLocalRotation(tempRotation);
	//AddActorWorldRotation(dRotation);
	*/
	
	FRotator Rotation = GetActorRotation();
	FVector moveDirection = FRotationMatrix(Rotation).GetUnitAxis(EAxis::Z);
	//velocity movement based upon forward vector in left/right direction
	const FVector ForwardDir = GetActorForwardVector();
	FVector AddPos = ForwardDir;
	AddPos = moveDirection * AddPos;
	//add forward velocity and value of direction
	AddMovementInput(AddPos, Value);
	
	//adjust yaw
		/*float val = 30;
		float axisVal;
		UStaticMeshComponent* smc = Cast<UStaticMeshComponent>(RootComponent);

		axisVal = Value * val;
		//add tilting movement control on left & right
		FRotator Rotation = GetActorRotation();
		Rotation.Roll = Value;
		AddActorLocalRotation(Rotation);*/
		//curRollAmt = Value;

		// find out which way is right

		/*const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);
		// get right vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		//smc->SetPhysicsLinearVelocity(Direction * axisVal);
		AddControllerYawInput((Direction * axisVal));*/
}
Example #25
0
void AFPSCharacter::MoveRight(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		// find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
		// add movement in that direction
		AddMovementInput(Direction, Value);
	}
}
FMatrix FStaticMeshEditorViewportClient::GetWidgetCoordSystem() const 
{
	const UStaticMeshSocket* SelectedSocket = StaticMeshEditorPtr.Pin()->GetSelectedSocket();
	if( SelectedSocket )
	{
		//FMatrix SocketTM;
		//SelectedSocket->GetSocketMatrix(SocketTM, StaticMeshComponent);

		return FRotationMatrix( SelectedSocket->RelativeRotation );
	}

	FTransform PrimTransform = FTransform::Identity;
	const bool bSelectedPrim = StaticMeshEditorPtr.Pin()->GetLastSelectedPrimTransform(PrimTransform);
	if (bSelectedPrim)
	{
		return FRotationMatrix(PrimTransform.Rotator());
	}

	return FMatrix::Identity;
}
Example #27
0
void ANimModCharacter::MoveForward(float Val)
{
	if (Controller && Val != 0.f)
	{
		// Limit pitch when walking or falling
		const bool bLimitRotation = (GetCharacterMovement()->IsMovingOnGround() || GetCharacterMovement()->IsFalling());
		const FRotator Rotation = bLimitRotation ? GetActorRotation() : Controller->GetControlRotation();
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
		AddMovementInput(Direction, Val);
	}
}
void ATopDown_HitmanCleanCharacter::MoveRight(float Value){
	if ( (Controller != NULL) && (Value != 0.0f) ){
		// find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// get right vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		// add movement in that direction
		AddMovementInput(Direction, Value);
	}
}
void AGoldenOculusCharacter::MoveRight(float val)
{
	if (Controller != NULL && val != 0.0f)
	{
		// get forward direction
		FRotator rotation = Controller->GetControlRotation();

		// add movement in that direction
		const FVector direction = FRotationMatrix(rotation).GetScaledAxis(EAxis::Y);
		AddMovementInput(direction, val);
	}
}
Example #30
0
void AsbrPlayer::MoveForward(float value)
{
    if ((Controller != NULL) && (value != 0.0f))
    {
        FRotator Rotation = Controller->GetControlRotation();
        if (GetCharacterMovement()->IsMovingOnGround() || GetCharacterMovement()->IsFalling())
            Rotation.Pitch = 0.0f;

        const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
        AddMovementInput(Direction, value);
    }
}