void ACSUEGameMode::endRound(FString winningTeam){ if(winningTeam == FString(TEXT("t"))) tWins+=1; else ctWins+=1; //reset round time GetWorldTimerManager().ClearTimer(roundTimer); time = 180; //start new round if game is not over if (tWins == 5 || ctWins == 5) endGame(winningTeam); else { startRound(); auto myChar = (ACSUECharacter*)UGameplayStatics::GetPlayerCharacter(GetWorld(), 0); if (myChar->myTeam == FString(TEXT("CT"))) { FVector spawn = FVector(-3163.f, 1183.f, -227.f); myChar->SetActorRotation(FRotator::ZeroRotator); myChar->SetActorLocation(spawn, false); } else { FVector spawn = FVector(-6305.f, 9740.f, 584.f); myChar->SetActorRotation(FRotator::ZeroRotator); myChar->SetActorLocation(spawn, false); } } }
void AGameplayAbilityWorldReticle::FaceTowardSource(bool bFaceIn2D) { if (TargetingActor) { if (bFaceIn2D) { FVector FacingVector = (TargetingActor->StartLocation.GetTargetingTransform().GetLocation() - GetActorLocation()).GetSafeNormal2D(); if (FacingVector.IsZero()) { FacingVector = -GetActorForwardVector().GetSafeNormal2D(); } if (!FacingVector.IsZero()) { SetActorRotation(FacingVector.Rotation()); } } else { FVector FacingVector = (TargetingActor->StartLocation.GetTargetingTransform().GetLocation() - GetActorLocation()).GetSafeNormal(); if (FacingVector.IsZero()) { FacingVector = -GetActorForwardVector().GetSafeNormal(); } SetActorRotation(FacingVector.Rotation()); } } }
void ABrainCharacter::Load() { if (!GetName().IsEmpty()) { if (UBrainGameInstance* gameInstance = Cast<UBrainGameInstance>(GetGameInstance())) { if (UBrainSaveManager* saveManager = gameInstance->GetSaveManager()) { FBrainCharacterSaveData savedData = saveManager->GetDataFromSave<FBrainCharacterSaveData>(GetName()); if (savedData._loadFromfile) { SetActorLocation(savedData._location); SetActorRotation(savedData._rotation); _energy = savedData._energy; } else { SetActorRotation(FRotator(0)); _energy = _maxEnergy; } } } } }
// Called every frame void AInteractDoors::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); if (bIsOpen) { SetActorRotation(FMath::RInterpTo(GetActorRotation(), rotationOpen, DeltaTime, 5.f)); } else { SetActorRotation(FMath::RInterpTo(GetActorRotation(), rotationClosed, DeltaTime, 5.f)); } }
// Called every frame void ATheSwarmActor::Tick(float DeltaTime) { Super::Tick(DeltaTime); UCapsuleComponent* move = NULL; TArray<UCapsuleComponent*>comps; actor->GetComponents(comps); if (comps.Num() > 0) { move = comps[0]; } //adjust Z axis for allowing gravity FVector gravityFudge = FVector(GetActorLocation().X, GetActorLocation().Y, actor->GetActorLocation().Z); SetActorLocation(gravityFudge + velocity * DeltaTime); //moves swarm actor and child actor actor->SetActorLocation(GetActorLocation()); velocity = velocity.GetClampedToSize(0, 360); SetActorRotation(velocity.Rotation()); actor->SetActorRotation(GetActorRotation()); //allows animation assets to be used if (move != NULL) { move->SetAllPhysicsLinearVelocity(velocity); } }
void APawn::FaceRotation(FRotator NewControlRotation, float DeltaTime) { // Only if we actually are going to use any component of rotation. if (bUseControllerRotationPitch || bUseControllerRotationYaw || bUseControllerRotationRoll) { const FRotator CurrentRotation = GetActorRotation(); if (!bUseControllerRotationPitch) { NewControlRotation.Pitch = CurrentRotation.Pitch; } if (!bUseControllerRotationYaw) { NewControlRotation.Yaw = CurrentRotation.Yaw; } if (!bUseControllerRotationRoll) { NewControlRotation.Roll = CurrentRotation.Roll; } #if ENABLE_NAN_DIAGNOSTIC if (NewControlRotation.ContainsNaN()) { logOrEnsureNanError(TEXT("APawn::FaceRotation about to apply NaN-containing rotation to actor! New:(%s), Current:(%s)"), *NewControlRotation.ToString(), *CurrentRotation.ToString()); } #endif SetActorRotation(NewControlRotation); } }
FRotator AGGJ16_Player::CalculateTargetRotation() { float Yaw = FMath::RadiansToDegrees(FMath::Atan2(CurrentInputRotation.Y, CurrentInputRotation.X)); SetActorRotation(FMath::Lerp(GetActorRotation(), FRotator(0.f, Yaw, 0.f), RotationAlpha)); return GetActorRotation(); }
void ABrainCharacter::LookUp(float value) { FRotator actorRotation = GetActorRotation(); actorRotation.Pitch += value; LimitPitch(actorRotation, _minPitch, _maxPitch); SetActorRotation(actorRotation); }
void ABrainNormalInteractiveObject::Tick(float deltaTime) { Super::Tick(deltaTime); if (_canBeRotate) { _currentRotation += (_deltaRotation * (deltaTime / _animDuration)); _durationRotation += deltaTime; if (_durationRotation > _animDuration) { _currentRotation = _targetRotation; _deltaRotation = FRotator(0, 0, 0); // Annulation du deltaRotation } SetActorRotation(_currentRotation); } if (_canBeTranslate) { _currentTranslation += (_deltaTranslation * deltaTime / _animDuration); _durationTranslation += deltaTime; if (_durationTranslation > _animDuration) { _currentTranslation = _targetTranslation; _deltaTranslation = FVector(0, 0, 0); // Annulation du deltaSize } SetActorLocation(_currentTranslation,true); } if (_canBeScale) { _currentScale += (_deltaScale * deltaTime / _animDuration); _durationScale += deltaTime; if (_durationScale > _animDuration) { _currentScale = _targetScale; _deltaScale = FVector(0,0,0); // Annulation du deltaSize } SetActorScale3D(_currentScale); } if (_canBeShear) { _currentShearFirstAxis += (_deltaShearFirstAxis * deltaTime / _animDuration); _currentShearSecondAxis += (_deltaShearSecondAxis * deltaTime / _animDuration); _durationShear += deltaTime; if (_durationShear > _animDuration) { _currentShearFirstAxis = _targetShearFirstAxis; _currentShearSecondAxis = _targetShearSecondAxis; _deltaShearFirstAxis = 0; _deltaShearSecondAxis = 0; } FTransform sTrans = FTransform(Shear(_currentShearFirstAxis, _currentShearSecondAxis)); SetActorTransform(sTrans*_cachedTransform); } }
// Called every frame void APawnWithCamera::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); //Zoom in if ZoomIn button is down, zoom back out if it's not { if (bZoomingIn) { ZoomFactor += DeltaTime / 0.5f; //Zoom in over half a second } else { ZoomFactor -= DeltaTime / 0.25f; //Zoom out over a quarter of a second } ZoomFactor = FMath::Clamp<float>(ZoomFactor, 0.0f, 1.0f); //Blend our camera's FOV and our SpringArm's length based on ZoomFactor OurCamera->FieldOfView = FMath::Lerp<float>(90.0f, 60.0f, ZoomFactor); OurCameraSpringArm->TargetArmLength = FMath::Lerp<float>(400.0f, 300.0f, ZoomFactor); } //Rotate our actor's yaw, which will turn our camera because we're attached to it { FRotator NewRotation = GetActorRotation(); NewRotation.Yaw += CameraInput.X; SetActorRotation(NewRotation); } //Rotate our camera's pitch, but limit it so we're always looking downward { FRotator NewRotation = OurCameraSpringArm->GetComponentRotation(); NewRotation.Pitch = FMath::Clamp(NewRotation.Pitch + CameraInput.Y, -80.0f, -15.0f); OurCameraSpringArm->SetWorldRotation(NewRotation); } }
// Called every frame void AMyPlayer::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); SetActorRotation(FQuat(FRotator(0, 0, 0))); }
void ACoin::Tick(float DeltaTime) { Super::Tick(DeltaTime); FRotator newRot = GetActorRotation(); newRot.Yaw += RotationSpeed*DeltaTime; SetActorRotation(newRot); }
void AEmptyPotUE4ShoesPickUp::Tick(float DeltaTime) { Super::Tick(DeltaTime); FRotator newRot = GetActorRotation(); newRot.Yaw += RotationSpeed*DeltaTime; SetActorRotation(newRot); }
void ATP_FlyingPawn::NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) { Super::NotifyHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit); // Deflect along the surface when we collide. FRotator CurrentRotation = GetActorRotation(RootComponent); SetActorRotation(FQuat::Slerp(CurrentRotation.Quaternion(), HitNormal.ToOrientationQuat(), 0.025f)); }
// Called every frame void ATorus::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); m_fRotation += DeltaTime * ROT_SPEED; SetActorRotation(FRotator(0.0f, m_fRotation, 0.0f)); }
void AVoyager::Pitch(float AxisValue) { if(!inBearingMode) { FRotator NewRotation = GetActorRotation(); NewRotation.Pitch += AxisValue; SetActorRotation(NewRotation); } }
void ABrush::InitPosRotScale() { check(BrushComponent); SetActorLocation(FVector::ZeroVector, false); SetActorRotation(FRotator::ZeroRotator); SetPrePivot( FVector::ZeroVector ); }
void APickups::Tick(float DeltaTime) { Super::Tick(DeltaTime); FRotator MyRot = GetActorRotation(); MyRot.Roll += RotationRate * DeltaTime; SetActorRotation(MyRot); }
void UEnemyRoadSplineComponent::SetActorRotationMulticast_Implementation(const FRotator& rotator) { auto Owner = GetOwner(); if (Owner) { Owner->SetActorRotation(rotator); } }
void AManaJourneyCharacter::faceNpc(ABasicNpc* npcFound) { if (npcFound) { const FVector playerLocation = player->GetActorLocation(); const FVector npcLocation = npcFound->GetActorLocation(); FRotator lookRotation = UKismetMathLibrary::FindLookAtRotation(playerLocation, npcLocation); SetActorRotation(FMath::Lerp(GetActorRotation(), lookRotation, 0.2f)); } }
// Called every frame void APickup::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); //Makes the pickup rotate on Z axis FRotator ActorRotation = GetActorRotation(); ActorRotation.Yaw += RotationRate*DeltaTime; SetActorRotation(ActorRotation); }
void AMech_RPGCharacter::LookAt(AMech_RPGCharacter * other) { FRotator rotation = GetActorRotation(); FVector Direction = GetActorLocation() - other->GetActorLocation(); Direction = FVector(Direction.X, Direction.Y, 0); rotation.Yaw = FRotationMatrix::MakeFromX(Direction).Rotator().Yaw + 180; SetActorRotation(rotation); }
void ADynamicWeather::Update() { // Modify this actor's rotation according to Sun position. if (!SetActorRotation(FQuat(GetSunDirection().Rotation()), ETeleportType::None)) { UE_LOG(LogCarla, Warning, TEXT("Unable to rotate actor")); } if (bRefreshAutomatically) { RefreshWeather(); } }
// Called when the game starts or when spawned void AFrostFeet::BeginPlay() { Super::BeginPlay(); AMaxCharacter* Player = Cast<AMaxCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); if (Player) { FVector SpawnPoint = Player->GetActorLocation(); SetActorRotation(FRotator::ZeroRotator); this->SetActorLocation(SpawnPoint); } }
void AInertiaCamera::Tick(float Delta) { if (FollowComponent == NULL) { return; } FVector Location = GetActorLocation(); FRotator Rotation = GetActorRotation(); FVector CompLocation = FollowComponent->GetComponentLocation(); FRotator CompRotation = FollowComponent->GetComponentRotation(); Location = Location * 0.7 + CompLocation * 0.3; Rotation = Rotation * 0.7 + CompRotation * 0.3; LocationError = (CompLocation - Location) * 0.05 + LocationError * 0.95; RotationError = (CompRotation - Rotation) * 0.05 + RotationError * 0.95; //Location = FMath::VInterpTo(Location, CompLocation, Delta, 10); //Rotation = FMath::RInterpTo(Rotation, CompRotation, Delta, 10); SetActorRotation(Rotation + RotationError); SetActorLocation(Location + LocationError); /* CurrentLocation = 0.5 * CurrentLocation + 0.5 * FollowComponent->GetComponentLocation(); FTransform Transform = FollowComponent->ComponentToWorld; FTransform CurrentTransform = GetTransform(); Transform.Rotat FTransform ThisTransform = UKismetMathLibrary::TInterpTo(GetTransform(), Transform, Delta, 10); SetActorTransform(ThisTransform);*/ //SetActorLocation(CurrentLocation); //FVector MyLocation = GetActorLocation(); //FVector CurrentLocation = FollowComponent->GetComponentLocation(); //SetActorLocation(CurrentLocation, false); //SetActorRotation(FollowComponent->GetComponentRotation()); //SetActorLocation(FollowActor->GetActorLocation() + FollowComponent->RelativeLocation); //SetActorTransform(FollowComponent->GetRelativeTransform() * FollowActor->GetTransform()); //SetActorLocation(FollowActor->GetActorLocation() + FVector(0, 0, 1000)); //FTransform Trans = FollowComponent->ComponentToWorld; //FVector LocationComp = CurrentLocation; //FVector LocationAct = FollowActor->GetActorLocation(); //FVector MyLoc = GetActorLocation(); //SetActorLocation(LocationComp); //SetActorRotation(FollowComponent->GetComponentRotation()); }
void ACapTheBrainCharacter::LooseBrain() { GotHit = false; FellDown = false; FVector newBrainPosition = this->GetActorLocation(); SetActorLocation(startPosition); SetActorRotation(startRotation); gameState->brain->DetachFromHead(this, newBrainPosition); for (int i = 0; i < gameState->characters.Num(); i++) { gameState->arrows[gameState->characters[i]->id]->ChangeMaterial(false, false, true); } }
// Called every frame void AMapActor::Tick( float DeltaTime ) { Super::Tick( DeltaTime ); //rotate the sphere if (framesPerRotation > 0) { FRotator currentRotation = GetActorRotation(); currentRotation.Yaw += 360.0 / framesPerRotation; SetActorRotation(currentRotation); } }
void ABoardGamePlayerController::PlayerTick(float DeltaTime) { Super::PlayerTick(DeltaTime); if ((rotatingRight && !rotatingLeft) || (rotatingLeft && !rotatingRight)) { auto character = (ABoardGameCharacter*)GetPawn(); auto rotation = character->GetActorRotation(); float deltaRotation = DeltaTime * RotationVelocity; rotation.Yaw += rotatingRight? deltaRotation : -deltaRotation; character->SetActorRotation(rotation); } }
void AAnchovieCharacter::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (PatrolPath != NULL) { if (LightOn == true) { if (PatrolPath->GetSplineLength() <= DistanceOnSpline) { DistanceOnSpline = 0; } else { DistanceOnSpline += AnchovySpeed * DeltaTime; } SetActorRotation(PatrolPath->GetRotationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World)); SetActorLocation(PatrolPath->GetLocationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World)); } else { if (DistanceOnSpline <= 0) { DistanceOnSpline = PatrolPath->GetSplineLength(); } else { DistanceOnSpline -= AnchovySpeed * DeltaTime; } rotationTarget = PatrolPath->GetRotationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World); rotationTarget.Yaw += 180; SetActorRotation(rotationTarget); SetActorLocation(PatrolPath->GetLocationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World)); } } }
void ADayTimeLight::Tick(float DeltaSeconds){ Super::Tick(DeltaSeconds); FRotator SunRot = GetActorRotation(); MyRot.X += SunSpeed*DeltaSeconds; if (MyRot.X > 360) MyRot.X -= 360; SunRot.Pitch = MyRot.X; SunRot.Roll = MyRot.Y; SunRot.Yaw = MyRot.Z; SetActorRotation(SunRot); }