void ACloud10Character::LookUp(float Value) { //get rotation from player controller which = camera/mouse FRotator Rotation = Controller->GetControlRotation(); Rotation.Pitch = Value; AddActorLocalRotation(Rotation); }
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); } } }
// 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 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); }
void ARobot::RotateTick(float DeltaSeconds) { if (Controller && GEngine) { FRotator Rotation = GetActorRotation(); double deltaRotation = rotation - Rotation.Yaw; if (FMath::Abs(deltaRotation)>180) deltaRotation = Rotation.Yaw - rotation; if (FMath::Abs(deltaRotation)>0.0001) { float maxRotate = DeltaSeconds*400; if (deltaRotation > maxRotate) deltaRotation = maxRotate; if (deltaRotation < -maxRotate) deltaRotation = -maxRotate; AddActorLocalRotation(FRotator(0, deltaRotation, 0)); } } }