void ABouncerPlayer::Strafe(float Scale)
{
	if (bIsStunned)
		return;
	//stops the player from moving outside their bounds
	if (FVector::Dist(GetActorLocation(), leftBounds) > 20 && (bReverseControls ? Scale *-1 : Scale)<0)
	{
		AddActorWorldOffset(rightVector*(bReverseControls ? Scale *-1: Scale)* (MoveSpeed * MoveScalar));

	}
	else if (FVector::Dist(GetActorLocation(), rightBounds) > 20 && (bReverseControls ? Scale *-1 : Scale) > 0)
	{
		AddActorWorldOffset(rightVector*(bReverseControls ? Scale *-1 : Scale) * (MoveSpeed* MoveScalar));
	}
}
Пример #2
0
// Called every frame
void ADKBarrel::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	if (RotMovement)
		RotMovement->RotationRate = RotationRate;
	FVector DeltaMovement = FVector::ZeroVector;
	
	FHitResult hit;
	if (GetFloor(hit) && !bMovingOnLadder)
	{
		if (bMoveDirection)
		{
			DeltaMovement.Y = FMath::Abs<float>(Move) * -1;// FVector(0, -400, 0);
			TraceStartDistance = FMath::Abs<float>(40);
			RotationRate = FRotator(0, 0, -180);
		}
		else
		{
			DeltaMovement.Y = FMath::Abs<float>(Move);// FVector(0, 400, 0);;
			TraceStartDistance = FMath::Abs<float>(40) * -1;;
			RotationRate = FRotator(0, 0, 180);
		}
		bChangeDirection = true;

		FVector CurrentLocation = GetActorLocation();
		float DesiredLocationZ = hit.Location.Z + 40;
		CurrentLocation.Z = DesiredLocationZ;
		SetActorLocation(FMath::VInterpTo(GetActorLocation(), CurrentLocation, DeltaTime, 5));
	}
	else
	{
		DeltaMovement = FVector(0, 0, Falling);
		if (bChangeDirection)
		{
			if (bMoveDirection)
			{
				bMoveDirection = false;
			}
			else
			{
				bMoveDirection = true;
			}
		}
		bChangeDirection = false;
	}
	DeltaMovement = DeltaMovement * DeltaTime;
	AddActorWorldOffset(DeltaMovement);
}
Пример #3
0
// Called every frame
void AFlyingEnemy::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	AddActorWorldOffset(Velocity * DeltaTime, true);
}