void ADonkeyKongCharacter::Climb(float Value)
{
	ClimbingDirection = Value;
	if (bIsClimbing)
	{
		FVector Move = ClimbDirection * Value;
		AddActorLocalOffset(Move);
		UnEquipWeapon();
	}
	
}
void AsixDOFPawn::Tick(float DeltaSeconds)
{
    bool ret = OurTick(DeltaSeconds);
    if(ret)
    {
	    //printf("running %f\n",DeltaSeconds);
		const FVector LocalMove = FVector(m_vx*10, m_vy*10, -m_vz*10);//(CurrentForwardSpeed * DeltaSeconds, 0.f, 0.f);
		//FVector curMove = GetVelocity();//(CurrentForwardSpeed * DeltaSeconds, 0.f, 0.f);
		FVector curMove = ReplicatedMovement.LinearVelocity;
		printf("------> %f %f %f \n",curMove.X, curMove.Y, curMove.Z );

		// Move plan forwards (with sweep so we stop when we collide with things)
		AddActorLocalOffset(LocalMove, true);

		// Calculate change in rotation this frame
		FRotator DeltaRotation(0,0,0);
		//printf("Delta -> %f %f %f \n",m_Deltaroll, m_Deltapitch, m_Deltayaw );
		//printf("raw -> %f %f %f \n",m_roll, m_pitch, m_yaw );
		
		DeltaRotation.Pitch = m_Deltapitch;
		DeltaRotation.Yaw 	= m_Deltayaw;
		DeltaRotation.Roll 	= m_Deltaroll;
		/*
		FRotator actorRotation(0,0,0);
		DeltaRotation.Yaw 	= m_Deltayaw;
		AddActorLocalRotation(DeltaRotation);
		*/
		// Rotate plane
		Camera->AddLocalRotation(DeltaRotation);
	}
	// Call any parent class Tick implementation
	Super::Tick(DeltaSeconds);
}
// Called every frame
void AObstacle::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	float gameSpeed = GetCustomGameMode<ABountyDashGameMode>(GetWorld())->GetInvGameSpeed();

	AddActorLocalOffset(FVector(gameSpeed, 0.0f, 0.0f));

	if (GetActorLocation().X < KillPoint)
	{
		Destroy();
	}
}
// Called every frame
void AFloatingActor::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	FVector Offset;
	Offset.X = (FMath::Sin((RunningTime + DeltaTime) * Period.X) - FMath::Sin(RunningTime * Period.X)) * Scale.X;
	Offset.Y = (FMath::Sin((RunningTime + DeltaTime) * Period.Y) - FMath::Sin(RunningTime * Period.Y)) * Scale.Y;
	Offset.Z = (FMath::Sin((RunningTime + DeltaTime) * Period.Z) - FMath::Sin(RunningTime * Period.Z)) * Scale.Z;
	RunningTime += DeltaTime;

	AddActorLocalOffset(Offset);

	AddActorLocalRotation(Rotation * DeltaTime);
}
void APlayerShip::Tick(float DeltaTime)
{
	// 회전
	Super::Tick(DeltaTime);
	if (HandleStick->GetNormalizedFacingVector().IsZero())
	{
		if (RotatorSize(CurrentRotationSpeed) > DeltaTime*RotationDeccelration)
			CurrentRotationSpeed -= DeltaTime*RotationDeccelration / (RotatorSize(CurrentRotationSpeed))*CurrentRotationSpeed;
		else
			CurrentRotationSpeed = FRotator::ZeroRotator;
	}
	else
	{
		TargetRotationSpeed = FRotator(-MaxRotationspeed*HandleStick->GetNormalizedFacingVector().X, MaxRotationspeed*HandleStick->GetNormalizedFacingVector().Y,0.0f);
		CurrentRotationSpeed += DeltaTime*RotationAcceleration / RotatorSize(TargetRotationSpeed - CurrentRotationSpeed)*(TargetRotationSpeed - CurrentRotationSpeed);
		
		//CurrentRotationSpeed += DeltaTime*RotationAcceleration*FRotator(-HandleStick->GetNormalizedFacingVector().X, HandleStick->GetNormalizedFacingVector().Y, 0);
		//if (RotatorSize(CurrentRotationSpeed) > MaxRotationspeed)
		//	CurrentRotationSpeed = MaxRotationspeed / RotatorSize(CurrentRotationSpeed)*CurrentRotationSpeed;
	}

	if (GetActorRotation().Pitch > PitchClamper)
		CurrentRotationSpeed.Pitch = fmin(0, CurrentRotationSpeed.Pitch);
	if (GetActorRotation().Pitch < -PitchClamper)
		CurrentRotationSpeed.Pitch = fmax(0, CurrentRotationSpeed.Pitch);
	SetActorRotation(GetActorRotation() + DeltaTime*FRotator(CurrentRotationSpeed.Pitch, CurrentRotationSpeed.Yaw, 0));
	//전진
	//if (IsAccelerating)
	//	CurrentSpeed += DeltaTime*Acceleration;
	//else
	//	if (CurrentSpeed > DeltaTime*Decceleration)
	//		CurrentSpeed -= DeltaTime*Decceleration;
	//	else
	//		CurrentSpeed = 0;
	// 전방방향 이동
	// 엑셀 밟고 있을때
	if (HandleStick->GetisPushingSecond())
	{
		CurrentSpeed = (CurrentSpeed + DeltaTime*Acceleration > MaxSpeed) ? MaxSpeed : CurrentSpeed + DeltaTime*Acceleration;
	}
	else
	{
		CurrentSpeed = (CurrentSpeed - DeltaTime*Decceleration < 0) ? 0 : CurrentSpeed - DeltaTime*Decceleration;
	}
	AddActorLocalOffset(FVector(CurrentSpeed*DeltaTime, 0, 0));
	//AddActorLocalRotation((DeltaTime*CurrentRotationSpeed).Quaternion());
	//AddActorWorldRotation(FRotator(0,0,GetActorRotation().Roll));
	//SetActorRotation(FRotator(GetActorRotation().Pitch, GetActorRotation().Yaw,0.0f));
	//AddActorLocalRotation(FRotator(0,0, GetActorRotation().Roll));
}
void ATP_FlyingPawn::Tick(float DeltaSeconds)
{
	const FVector LocalMove = FVector(CurrentForwardSpeed * DeltaSeconds, 0.f, 0.f);

	// Move plan forwards (with sweep so we stop when we collide with things)
	AddActorLocalOffset(LocalMove, true);

	// Calculate change in rotation this frame
	FRotator DeltaRotation(0,0,0);
	DeltaRotation.Pitch = CurrentPitchSpeed * DeltaSeconds;
	DeltaRotation.Yaw = CurrentYawSpeed * DeltaSeconds;
	DeltaRotation.Roll = CurrentRollSpeed * DeltaSeconds;

	// Rotate plane
	AddActorLocalRotation(DeltaRotation);

	// Call any parent class Tick implementation
	Super::Tick(DeltaSeconds);
}
Beispiel #7
0
void ASpaceRocksPawn::Tick(float DeltaSeconds)
{
	const FVector LocalMove = FVector(CurrentXAxisSpeed * DeltaSeconds, CurrentYAxisSpeed * DeltaSeconds, CurrentZAxisSpeed * DeltaSeconds);

	// Move Craft's Root Component through X,Y and Z axis (with sweep so we stop when we collide with things)
	// Note that orientation/rotation of root component always remains fixed, but the craft's static mesh + camera do the rotation.
	AddActorLocalOffset(LocalMove, true);

	// Calculate change in rotation this frame (For player's mesh and camera)
	FRotator DeltaRotation(0, 0, 0);
	DeltaRotation.Pitch = CurrentPitchSpeed * DeltaSeconds;
	DeltaRotation.Roll = CurrentRollSpeed * DeltaSeconds;
	DeltaRotation.Yaw = CurrentYawSpeed * DeltaSeconds;

	// Rotate Craft
	PlaneMesh->AddLocalRotation(DeltaRotation);

	// Call any parent class Tick implementation
	Super::Tick(DeltaSeconds);

	// Are the fire button(s) pressed? If so, do something about it
	/*
	if (primary_on)
	{
		// Primary Fire

		// Just some test(ish) code to start with

		// Fire, if firerate not breached
		if (lastfired <= (this->GetWorld()->GetTimeSeconds() - WeapInfo.getFireRate(PlayerInv.weaponInventory[weapon])))
		{
			// ** TODO ** Can we make this all more efficient?

			// This big gets the Location an orientation of the player
			//FireLocation = ShieldMesh->RelativeLocation;
			FireLocation = RootComponent->RelativeLocation;
			FireRotation = PlaneMesh->RelativeRotation;

			// This gets the default direction the fire should head from the PlaneMesh forward vector.
			FireDirection = PlaneMesh->GetForwardVector();

			//Now we calculate various offsets to the player position, so we are not firing from the middle of the mesh



			// - Mid Left
			//FireLocation_Mid_Left = FireLocation;
			FireLocation_Mid_Left = FireLocation - PlaneMesh->GetRightVector() * 105.f;
			FireLocation_Mid_Left = FireLocation_Mid_Left + PlaneMesh->GetForwardVector() * 50.f;
			FireDirection_Mid_Left = FireDirection;
			FireRotation_Mid_Left = FireRotation;

			// - Mid Right
			//FireLocation_Mid_Right = FireLocation;
			FireLocation_Mid_Right = FireLocation + PlaneMesh->GetRightVector() * 105.f;
			FireLocation_Mid_Right = FireLocation_Mid_Right + PlaneMesh->GetForwardVector() * 50.f;
			FireDirection_Mid_Right = FireDirection;
			FireRotation_Mid_Right = FireRotation;

			// - Infront and centre

			FireLocation = FireLocation + FireDirection * 205.f;

			// This now changes the FireDirection by calculating the direction the fire should head to hit where the player's crosshair is.

			if (!bIsThirdPerson)
			{
				LineTraceStart = FireLocation;
				LineTraceEnd = LineTraceStart + FireDirection * 10000.f;
			}
			else
			{
				LineTraceStart = TP_Camera->GetComponentLocation();
				LineTraceEnd = LineTraceStart + TP_Camera->GetForwardVector() * 10000.f;
			}


			GetWorld()->LineTraceSingle(
				CrossHair_Hit,			 //result
				LineTraceStart,					//start
				LineTraceEnd,					//end
				ECC_Pawn,				//collision channel
				CrossHair_TraceParams
				);

			if (CrossHair_Hit.bBlockingHit)
			{
				FireDirection_Mid_Left = CrossHair_Hit.ImpactPoint - FireLocation_Mid_Left;

				FireRotation_Mid_Left = FireDirection_Mid_Left.Rotation();
				FireDirection_Mid_Right = CrossHair_Hit.ImpactPoint - FireLocation_Mid_Right;

				FireRotation_Mid_Right = FireDirection_Mid_Right.Rotation();
				CrossHair_Hit.bBlockingHit = false;	// why I have to reset this, I don't know? UE bug?
			}


			// Finally, fire the appropriate weapon
			if (PlayerInv.ammo[weapon] != 0)
			{

				AActor * spawned;

				if (PlayerInv.ammo[weapon] > 0) PlayerInv.ammo[weapon] --;

				switch (PlayerInv.weaponInventory[weapon])
				{
				case PHASEOID:
					spawned = GetWorld()->SpawnActor(AReconOneWP_phaseoid::StaticClass(), &FireLocation, &FireRotation);
					break;
				case PULSER:
					if (weap_cycle == 1 || weap_cycle == 3)
					{
						spawned = GetWorld()->SpawnActor(AReconOneWP_pulser::StaticClass(), &FireLocation_Mid_Left, &FireRotation_Mid_Left);
					}
					else
					{
						spawned = GetWorld()->SpawnActor(AReconOneWP_pulser::StaticClass(), &FireLocation_Mid_Right, &FireRotation_Mid_Right);
					}
					break;
				default:
					spawned = GetWorld()->SpawnActor(AReconOneWP_phaseoid::StaticClass(), &FireLocation, &FireRotation);
					break;
				}

				// Tag the projectile with the name of the Actor that spawned it.
				AReconOneWeaponProjectile* const TestProj = Cast<AReconOneWeaponProjectile>(spawned);
				if (TestProj)
				{
					TestProj->SpawnedBy = GetUniqueID();
				}

				lastfired = this->GetWorld()->GetTimeSeconds();
			}

			//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, GetFName().ToString());
			//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("UniqueID = %d"), GetUniqueID()));



			// Increment weapon fire position cycle
			weap_cycle++;
			if (weap_cycle > 4)
			{
				weap_cycle = 1;
			}
		}
	}
	*/
}