コード例 #1
0
// Called every frame
void AItemPickupActorParent::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	if (m_PulseScale)
	{
		float multi = FMath::Sin(GetWorld()->GetRealTimeSeconds() * 3) * (double)m_PulseScaleAmount;
		if (multi < 0)
			multi = multi * -1;
		multi += m_PulseScaleAmount * 0.5;
		SetActorRelativeScale3D(FVector(multi, multi, multi));
	}
	if (m_Rotate)
	{
		float angleMultiX = FMath::Sin(GetWorld()->GetRealTimeSeconds()*m_RotateAxis.X) * 360;
		float angleMultiY = FMath::Sin(GetWorld()->GetRealTimeSeconds()*m_RotateAxis.Y) * 360;
		float angleMultiZ = FMath::Sin(GetWorld()->GetRealTimeSeconds()*m_RotateAxis.Z) * 360;
		SetActorRelativeRotation(FQuat::MakeFromEuler(FVector(angleMultiX, angleMultiY, angleMultiZ)));
	}
}
コード例 #2
0
ファイル: RTSUnit.cpp プロジェクト: OpenMachines/machines
/* Called every frame. */
void ARTSUnit::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	switch (State)
	{
		/* Move unit to destination. */
		case UnitAction::Move:
			CurrentDistance = FVector::Dist(CurrentDestination, GetActorLocation());
			if (CurrentDistance < StopDistance)
			{
				State = UnitAction::Idle;
			}
			break;
		/* Tell unit to attack target. */
		case UnitAction::Attack:
			if (Target != NULL)
			{
				CurrentDistance = FVector::Dist(Target->GetActorLocation(), GetActorLocation());

				float Cooldown = 1.0f / CurrentAttackSpeed;

				if (CurrentDistance < AttackDistance)
				{
					GetController()->StopMovement();
					if (GetWorld()->GetTimeSeconds() >= NextTimeToAttack)
					{
						OnFire();
						NextTimeToAttack = GetWorld()->GetTimeSeconds() + Cooldown;
					}
				}

				FRotator LookRot = (Target->GetActorLocation() - GetActorLocation()).Rotation();

				FRotator NewRot = FMath::RInterpTo(GetActorRotation(), LookRot, DeltaTime, CharacterMovement->RotationRate.Yaw * DeltaTime);

				SetActorRelativeRotation(NewRot);
			}
			break;
	}
}
コード例 #3
0
void AWorldCamera::Tick(float delta) {
	float maxDistance = 0;
	FVector average(0,0,0);
	
	
	for (AActor* act : Actors)
	{
		average = average + act->GetActorLocation();
		if (maxDistance < (act->GetActorLocation() - GetActorLocation()).Size()) {
			maxDistance = (act->GetActorLocation() - GetActorLocation()).Size();
		}
	}
	average =  average / (float)Actors.Num();

	//average.Z = 0;

	FRotator Rot = FRotationMatrix::MakeFromX(average - GetActorLocation()).Rotator(); //Actors[0]->GetActorLocation()
	SetActorRelativeRotation(Rot);
	
	SetActorLocation(average + -GetActorForwardVector() * maxDistance);

}