• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetActorRotation函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetActorRotation函数的典型用法代码示例。如果您正苦于以下问题:C++ GetActorRotation函数的具体用法?C++ GetActorRotation怎么用?C++ GetActorRotation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetActorRotation函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetNearbySocket

void ACoverActor::DetermineMovementDirection(FVector& MovementDirection, FRotator& FacingDirection)
{
	FName NearbySocket = GetNearbySocket();
	
	AActor* Char = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);

	//Determine the movement and facing direction of the player, based on the described logic
	//The way that we're deciding the facing direction is similar to the way we've decided
	//the movement direction
	if (NearbySocket.IsEqual("ForwardSocket"))
	{
		MovementDirection = -GetActorRightVector();
		FacingDirection = GetActorRotation();
	}
	else if (NearbySocket.IsEqual("BackwardSocket"))
	{
		MovementDirection = GetActorRightVector();
		FacingDirection = GetActorRotation() + FRotator(0, 180, 0);
	}
	else if (NearbySocket.IsEqual("RightSocket"))
	{
		MovementDirection = GetActorForwardVector();
		FacingDirection = GetActorRotation() + FRotator(0, 90, 0);
	}
	else
	{
		MovementDirection = -GetActorForwardVector();
		FacingDirection = GetActorRotation() + FRotator(0, -90.f, 0);
	}
}
开发者ID:orfeasel,项目名称:UE4-Game-Systems,代码行数:30,代码来源:CoverActor.cpp


示例2: FObjectAction

void ABrainNormalInteractiveObject::BeginPlay()
{
	Super::BeginPlay();

	int8 flags = (_canBeRotate ? EAction::ROTATE : 0)
		| (_canBeTranslate ? EAction::TRANSLATE : 0)
		| (_canBeScale ? EAction::SCALE : 0)
		| (_canBeShear ? EAction::SHEAR : 0);
	_actions = FObjectAction(flags);

	// Init Rotate
	_currentRotation = GetActorRotation();
	_targetRotation = GetActorRotation();

	// Init Translate
	_currentTranslation = GetActorLocation();
	_targetTranslation = GetActorLocation();

	// Init Scale
	_targetScale = _initScale;
	_currentScale = _initScale;

	// Init Shear
	_currentShearFirstAxis = 0;
	_currentShearSecondAxis = 0;
	_targetShearFirstAxis = 0;
	_targetShearSecondAxis = 0;

	_cachedTransform = GetTransform();

	if (this->GetClass()->ImplementsInterface(UBrainSaveInterface::StaticClass()))
		Load();
}
开发者ID:gamer08,项目名称:prog,代码行数:33,代码来源:BrainNormalInteractiveObject.cpp


示例3: UE_LOG

void AZombieShooterCharacter::ServerPerformAttack_Implementation(){
	//Perform the actual attack here
	UE_LOG(LogTemp, Warning, TEXT("Server Performing attack!"));

	//In final product, will call the currently equipped weapon's fire function
	//For now, just fire a basic projectile
	if (ProjectileClass != NULL)
	{
		//MuzzleRotation.Pitch += 10.0f;
		UWorld* const World = GetWorld();
		if (World)
		{
			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = this;
			SpawnParams.Instigator = Instigator;
			//Spawn projectile at muzzle
			FVector FireLocation = GetActorLocation() + FTransform(GetActorRotation()).TransformVector(FVector(25.0f, 0.0f, 0.0f));
			Projectile = World->SpawnActor<AProjectile>(ProjectileClass, FireLocation, GetActorRotation(), SpawnParams);

			if (Projectile)
			{
				//Find launch direction
				FVector const LaunchDir = GetActorRotation().Vector();
				//FVector const LaunchDir = CameraBoom->GetComponentRotation().Vector();
				Projectile->SetReplicates(true);
				Projectile->InitVelocity(LaunchDir);
			}
		}
	}
}
开发者ID:DisposedCheese,项目名称:ZombieShooter,代码行数:30,代码来源:ZombieShooterCharacter.cpp


示例4: GetWorld

void AFireDart::OnHit_Implementation(AActor * OtherActor) 
{
	if (OtherActor != GetOwner())
	{
		ABanditCharacter* Bandit = Cast<ABanditCharacter>(OtherActor);
		ABaseTicker* Ticker = Cast<ABaseTicker>(OtherActor);
		if (Bandit)
		{
			if (Explosion)
			{
				UWorld* const World = GetWorld();
				const FVector SpawnLocation = GetActorLocation();
				const FRotator SpawnRotation = GetActorRotation();
				World->SpawnActor<AActor>(Explosion, SpawnLocation,SpawnRotation);
				UGameplayStatics::ApplyDamage(Bandit, Damage, this->GetInstigatorController(), this, UDamageType::StaticClass());
				this->Destroy();
			}
			
		}
		else if (Ticker)
		{
			if (Explosion)
			{
				UWorld* const World = GetWorld();
				const FVector SpawnLocation = GetActorLocation();
				const FRotator SpawnRotation = GetActorRotation();
				World->SpawnActor<AActor>(Explosion, SpawnLocation, SpawnRotation);
				UGameplayStatics::ApplyDamage(Ticker, Damage, this->GetInstigatorController(), this, UDamageType::StaticClass());
				this->Destroy();
			}

		}
	}
	
}
开发者ID:TheRealKevinStone,项目名称:Max,代码行数:35,代码来源:FireDart.cpp


示例5: FName

void ADuckTower::Shoot(float distance)
{
	/*
	const FName filename = FName(TEXT("Blueprint'/Game/Blueprints/PickUp.PickUp'"));
	FVector loc = GetAttachParentActor()->GetActorLocation();
	FRotator rot = GetAttachParentActor()->GetActorRotation();
	SpawnBP(GetWorld(), (UClass*)LoadObjFromPath<UBlueprint>(&filename), loc, rot);
	*/
	APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 1)->GetControlledPawn();
	int randomValue = distance / 10000;
	FVector vec = player->GetActorLocation() + FVector(FMath::RandRange(-randomValue, randomValue), FMath::RandRange(-randomValue, randomValue), 0.0f); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10;
	FVector vec2 = GetActorLocation();
	FVector Direction = vec - vec2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	FRotator test2 = FRotator(1.0f, 0.0f, 0.0f);
	FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion());


	FVector forward = GetActorForwardVector();
	finalrot.Roll = -finalrot.Roll;
	finalrot.Yaw = -finalrot.Yaw;
	finalrot.Pitch = -finalrot.Pitch;
	FVector loc = GetActorLocation() + forward * 500.0f;
	FRotator rot = GetActorRotation();
	AActor* actor = GetWorld()->SpawnActor<AActor>(BulletBlueprint, loc, GetActorRotation());
	actor->SetActorScale3D(FVector(3.0f, 3.0f, 3.0f));
	//actor->GetRootPrimitiveComponent()->AddImpulse(actor->GetActorForwardVector()* 5000.0f);

	//actor->GetRootPrimitiveComponent()->SetPhysicsLinearVelocity(actor->GetActorForwardVector()*10000.0f); //* (distance/10000 * 1.0f));
}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:30,代码来源:DuckTower.cpp


示例6: SetActorRotation

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();

}
开发者ID:AnagramMC,项目名称:fantastic_pancakes,代码行数:7,代码来源:GGJ16_Player.cpp


示例7: GetActorRotation

// Called when the game starts or when spawned
void AInteractDoors::BeginPlay()
{
	Super::BeginPlay();

	bIsOpen = false;
	rotationClosed = GetActorRotation();
	rotationOpen = GetActorRotation();
	rotationOpen.Yaw += 90;
}
开发者ID:Snowman5717,项目名称:SymphonyOfShadows,代码行数:10,代码来源:InteractDoors.cpp


示例8: GetActorRotation

void ACloud10Character::DiveRight(float Value, float deltaSeconds)
{
	
	float prevYaw = GetActorRotation().Yaw;
	float minDeltaYaw = minYaw - prevYaw;
	float maxDeltaYaw = maxYaw - prevYaw;
	//roll character in an angle front and back
	curYawAmt = Value;

	/*
	const FRotator Rotation = GetActorRotation();
	FRotator dRotation(0, 0, 0);
	//curYawAmt * rotationRate
	const FVector Direction = FVector(0.0f, (curYawAmt * rotationRate), 0.0f) ;//= FRotationMatrix(Rotation).GetUnitAxis(EAxis::Z);
	dRotation = Direction.Rotation();
	dRotation.Yaw = FMath::ClampAngle(dRotation.Yaw, minDeltaYaw, maxDeltaYaw);
	//dRotation.Yaw = curYawAmt + Direction.Z;//FMath::ClampAngle(curYawAmt * Direction.Z, minDeltaYaw, maxDeltaYaw);
	//Controller->SetControlRotation(dRotation);
	//AddControllerYawInput(dRotation.Yaw);
	FRotator tempRotation = FMath::RInterpTo(Rotation, dRotation, 3, 0);
	AddActorLocalRotation(tempRotation);
	//AddActorWorldRotation(dRotation);
	*/
	
	FRotator Rotation = GetActorRotation();
	FVector moveDirection = FRotationMatrix(Rotation).GetUnitAxis(EAxis::Z);
	//velocity movement based upon forward vector in left/right direction
	const FVector ForwardDir = GetActorForwardVector();
	FVector AddPos = ForwardDir;
	AddPos = moveDirection * AddPos;
	//add forward velocity and value of direction
	AddMovementInput(AddPos, Value);
	
	//adjust yaw
		/*float val = 30;
		float axisVal;
		UStaticMeshComponent* smc = Cast<UStaticMeshComponent>(RootComponent);

		axisVal = Value * val;
		//add tilting movement control on left & right
		FRotator Rotation = GetActorRotation();
		Rotation.Roll = Value;
		AddActorLocalRotation(Rotation);*/
		//curRollAmt = Value;

		// find out which way is right

		/*const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);
		// get right vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		//smc->SetPhysicsLinearVelocity(Direction * axisVal);
		AddControllerYawInput((Direction * axisVal));*/
}
开发者ID:KaroA,项目名称:Cloud-10,代码行数:54,代码来源:Cloud10Character.cpp


示例9: GetWorld

void AdeezProjectile::OnHit(UPrimitiveComponent* ThisComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL))
	{

		// spawn FX
		AImpactFX* FX = GetWorld()->SpawnActorDeferred<AImpactFX>(ImpactTemplate, FTransform(Hit.Normal.Rotation(), Hit.Location), nullptr, Instigator, ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
		if (FX)
		{

			FCollisionQueryParams Params = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);
			Params.bTraceComplex = true;
			Params.bTraceAsyncScene = true;
			Params.bReturnPhysicalMaterial = true;

			FHitResult secondHit(ForceInit);

			FVector StartTrace;
			FVector EndTrace;

			StartTrace = GetActorLocation() - GetActorRotation().Vector() * 50;
			EndTrace = GetActorLocation() + GetActorRotation().Vector() * 200;

			GetWorld()->LineTraceSingleByChannel(secondHit, StartTrace, EndTrace, COLLISION_Weapon, Params);

			FPointDamageEvent PointDmg;
			//PointDmg.DamageTypeClass = DamageType;
			PointDmg.HitInfo = secondHit;
			PointDmg.ShotDirection = this->GetActorForwardVector();
			PointDmg.Damage = Damage;

			if (this->GetOwner() && this->GetOwner()->GetInstigatorController())
			{
				OtherActor->TakeDamage(Damage, PointDmg, this->GetOwner()->GetInstigatorController(), this->GetOwner());
			}

			if (secondHit.bBlockingHit)
			{
				FX->SurfaceHit = secondHit;
				UGameplayStatics::FinishSpawningActor(FX, FTransform(FX->SurfaceHit.Normal.Rotation(), FX->SurfaceHit.Location));
			}

			// simulate impact
			if (OtherComp->IsSimulatingPhysics())
			{
				OtherComp->AddImpulseAtLocation(GetProjectileMovement()->Velocity * MassMultiplier, GetActorLocation());
			}

		}
	
	} 
	Destroy();
}
开发者ID:s7evinkelevra,项目名称:deez,代码行数:53,代码来源:deezProjectile.cpp


示例10: SetActorRotation

// 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));
	}
}
开发者ID:Snowman5717,项目名称:SymphonyOfShadows,代码行数:14,代码来源:InteractDoors.cpp


示例11: FRotator

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));
}
开发者ID:dark2224,项目名称:Space_Redemption,代码行数:50,代码来源:PlayerShip.cpp


示例12: GetActorRotation

// Called every frame
void APawnWithCamera::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	//zooming in and out code
	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 springArms length based on zoomfactor
	OurCamera->FieldOfView = FMath::Lerp<float>(90.0f, 60.0f, ZoomFactor);
	OurCameraSpringArm->TargetArmLength = FMath::Lerp<float>(400.0f, 300.0f, ZoomFactor);

	//camera control code
	{
		//rotate our actor's yaw which will turn our camera because we're attached to it
		FRotator newRot = GetActorRotation();
		newRot.Yaw += CameraInput.X;
		SetActorRotation(newRot);
		//rotate the camera's pitch, but limit it so we're always looking downward
		FRotator newRot2 = OurCameraSpringArm->GetComponentRotation();
		newRot2.Pitch = FMath::Clamp(newRot2.Pitch + CameraInput.Y, -80.0f, -15.0f);
		OurCameraSpringArm->SetWorldRotation(newRot2);

		FRotator newRot3 = OurCamera->GetComponentRotation();
		newRot3.Roll = FMath::Lerp<float>(newRot.Roll, 120.0f * MovementInput.Y, DeltaTime);
		OurCamera->SetWorldRotation(newRot3);
	}

	//handle movememnt based on out movex and movey axes
	if (!MovementInput.IsZero())
	{
		//scale our moevement input axis values by 100 units per second
		MovementInput = MovementInput.GetSafeNormal();
		FVector newLoc = GetActorLocation();
		newLoc += GetActorForwardVector() * MovementInput.X * DeltaTime * ForwardSpeed;
		newLoc += GetActorRightVector() * MovementInput.Y * DeltaTime * StrafeSpeed;
		SetActorLocation(newLoc);

		//also slightly roll the camera when the player strafes
		FRotator newRot = FRotator(GetActorRotation().Pitch, GetActorRotation().Yaw, 0.0f);
		newRot.Roll += MovementInput.Y * DeltaTime * StrafeSpeed;
	}
}
开发者ID:dimmondslice,项目名称:ShotgunGladiators,代码行数:50,代码来源:PawnWithCamera.cpp


示例13: GetActorRotation

void AActor::EditorApplyRotation(const FRotator& DeltaRotation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
	if( RootComponent != NULL )
	{
		const FRotator Rot = RootComponent->GetAttachParent() != NULL ? GetActorRotation() : RootComponent->RelativeRotation;

		FRotator ActorRotWind, ActorRotRem;
		Rot.GetWindingAndRemainder(ActorRotWind, ActorRotRem);

		const FQuat ActorQ = ActorRotRem.Quaternion();
		const FQuat DeltaQ = DeltaRotation.Quaternion();
		const FQuat ResultQ = DeltaQ * ActorQ;
		const FRotator NewActorRotRem = FRotator( ResultQ );
		FRotator DeltaRot = NewActorRotRem - ActorRotRem;
		DeltaRot.Normalize();

		if( RootComponent->GetAttachParent() != NULL )
		{
			RootComponent->SetWorldRotation( Rot + DeltaRot );
		}
		else
		{
			// No attachment.  Directly set relative rotation (to support winding)
			RootComponent->SetRelativeRotation( Rot + DeltaRot );
		}
	}
	else
	{
		UE_LOG(LogActor, Warning, TEXT("WARNING: EditorApplyRotation %s has no root component"), *GetName() );
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:31,代码来源:ActorEditor.cpp


示例14: GetActorLocation

bool ARobot::isObjectVisible(FVector objectPosition)
{
	FVector ownLocation = GetActorLocation();
	FRotator ownRotation = GetActorRotation();
	float distance = sqrt(pow(ownLocation.X - objectPosition.X, 2) + pow(ownLocation.Y - objectPosition.X, 2));

	if (distance < 500) //See everyting in a distance of 5 meter
	{
		return true;
	}

	//See everypting in the field of view
	float angle = FMath::RadiansToDegrees(atan2(ownLocation.Y - objectPosition.Y, ownLocation.X - objectPosition.X));
	float deltaAngle = angle - ownRotation.Yaw + 180;
	if (deltaAngle < -180) deltaAngle += 360;
	{
		if (deltaAngle > 180) deltaAngle -= 360;
		{
			if (FMath::Abs(deltaAngle) <= HalfFieldOfView)
			{
				return true;
			}
		}
	}

	return false;
}
开发者ID:RocketRider,项目名称:UnrealCup,代码行数:27,代码来源:Robot.cpp


示例15: GetMaxHealth

void ANimModCharacter::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if (Role == ROLE_Authority)
	{
		Health = GetMaxHealth();
		SpawnDefaultInventory();
	}

	// set initial mesh visibility (3rd person view)
	UpdatePawnMeshes();

	// create material instance for setting team colors (3rd person view)
	for (int32 iMat = 0; iMat < GetMesh()->GetNumMaterials(); iMat++)
	{
		MeshMIDs.Add(GetMesh()->CreateAndSetMaterialInstanceDynamic(iMat));
	}

	// play respawn effects
	if (GetNetMode() != NM_DedicatedServer)
	{
		if (RespawnFX)
		{
			UGameplayStatics::SpawnEmitterAtLocation(this, RespawnFX, GetActorLocation(), GetActorRotation());
		}

		if (RespawnSound)
		{
			UGameplayStatics::PlaySoundAtLocation(this, RespawnSound, GetActorLocation());
		}
	}
}
开发者ID:Nimgoble,项目名称:NimMod,代码行数:33,代码来源:NimModCharacter.cpp


示例16: FVector

// 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);
	}

}
开发者ID:dialcforchris,项目名称:SwarmPlugGood,代码行数:30,代码来源:TheSwarmActor.cpp


示例17: SetActorLocationAndRotation

void ACharacter::UpdateSimulatedPosition(const FVector & NewLocation, const FRotator & NewRotation)
{
	// Always consider Location as changed if we were spawned this tick as in that case our replicated Location was set as part of spawning, before PreNetReceive()
	if( (NewLocation != GetActorLocation()) || (CreationTime == GetWorld()->TimeSeconds) )
	{
		FVector FinalLocation = NewLocation;
		if( GetWorld()->EncroachingBlockingGeometry(this, NewLocation, NewRotation) )
		{
			bSimGravityDisabled = true;
		}
		else
		{
			// Correction to make sure pawn doesn't penetrate floor after replication rounding
			FinalLocation.Z += 0.01f;
			bSimGravityDisabled = false;
		}
		
		// Don't use TeleportTo(), that clears our base.
		SetActorLocationAndRotation(FinalLocation, NewRotation, false);
	}
	else if( NewRotation != GetActorRotation() )
	{
		GetRootComponent()->MoveComponent(FVector::ZeroVector, NewRotation, false);
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:25,代码来源:Character.cpp


示例18: GetActorRotation

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);
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:32,代码来源:Pawn.cpp


示例19: GetWorld

void ABlinkAbility::StartAbility()
{

	float ManaCost = 20;
	float CoolDown = 5;
	float curMana = owner->getMana();

	if (curMana - ManaCost >= 0 && !(owner->getbCDBlink()))
	{
		owner->setMana(curMana - ManaCost);
		//owner->BlinkInCD();
		bCoolDown = true;

		GetWorld()->GetTimerManager().SetTimer(CDHandle_Ability, this, &ABlinkAbility::callCoolDown, CoolDown);
		if (AbilitySound && AbilityFX)
		{
			UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), AbilityFX, GetActorLocation());
			UGameplayStatics::PlaySoundAttached(AbilitySound, owner->ShipMeshComponent);
		}

		FRotator curFacing = GetActorRotation();
		FVector curLoc = GetActorLocation();

		//get facing 
		FVector destLoc = curLoc + curFacing.Vector() * 700;
		owner->TeleportTo(destLoc, curFacing);
		UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), AbilityFX, GetActorLocation());
	}
}
开发者ID:AlexZhangji,项目名称:ShootingStar,代码行数:29,代码来源:BlinkAbility.cpp


示例20: FRotator

// Called every frame
void ASandShip::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	if (Player == nullptr) {
		CapsuleComponent->SetPhysicsLinearVelocity(FVector::ZeroVector);
		return;
	}

	FRotator NewSpringArmRotation = SpringArm->GetComponentRotation();
	NewSpringArmRotation.Pitch = FMath::Clamp(NewSpringArmRotation.Pitch + CameraInput.Y*DeltaTime*180.0f, -89.0f, 89.0f);
	NewSpringArmRotation.Yaw += CameraInput.X*DeltaTime*180.0f;
	SpringArm->SetWorldRotation(NewSpringArmRotation);

	MovementInput = MovementInput.GetClampedToSize(0.0f, 1.0f);
	FVector Forward = FVector::VectorPlaneProject(CapsuleComponent->GetForwardVector(), FVector::UpVector).GetSafeNormal();
	FVector Right = FVector::VectorPlaneProject(CapsuleComponent->GetRightVector(), FVector::UpVector).GetSafeNormal();

	//FHitResult groundtrace;
	//FCollisionShape traceshape = FCollisionShape::MakeSphere(CapsuleComponent->GetScaledCapsuleRadius()-5.0f);
	//FCollisionQueryParams gtparams;
	//gtparams.AddIgnoredActor(this);
	//GetWorld()->SweepSingleByChannel(groundtrace, GetActorLocation(), GetActorLocation() - 1000.0f*FVector::UpVector, FQuat::Identity, ECC_Visibility, traceshape, gtparams);
	//if (groundtrace.IsValidBlockingHit()) {
	//	SetActorLocation(GetActorLocation()*FVector(1.0f, 1.0f, 0.0f) + FVector::UpVector*groundtrace.ImpactPoint.Z + FVector::UpVector*CapsuleComponent->GetScaledCapsuleHalfHeight(), false, nullptr, ETeleportType::TeleportPhysics);
	//}

	FVector Velocity2D = FVector::VectorPlaneProject(CapsuleComponent->GetPhysicsLinearVelocity(),FVector::UpVector);
	if (CurrentDrag > 1.0f) {
		MovementInput.Y = 0.0f;
	}

	FVector AdjustedMovementInput = MovementInput.Y * Forward;
	CapsuleComponent->AddForce(AdjustedMovementInput*PhysicsSettings.AccelRate,NAME_None,true);
	
	float mult = FMath::Lerp(FMath::Sqrt(Velocity2D.Size() / PhysicsSettings.MaxVelocity), Velocity2D.Size() / PhysicsSettings.MaxVelocity, Velocity2D.Size() / PhysicsSettings.MaxVelocity)* CurrentDrag;
	float tangent = FMath::Pow(1.0f - FMath::Abs(Velocity2D.GetSafeNormal() | Forward),0.25f);
	CapsuleComponent->AddForce(-Velocity2D.GetSafeNormal()*PhysicsSettings.AccelRate*mult, NAME_None, true);
	if (CurrentDrag == PhysicsSettings.CoastingDrag) {
		//Root->AddForce(Right.GetSafeNormal()*PhysicsSettings.AccelRate*MovementInput.X*mult/1.0f, NAME_None, true);
	}

	if (!MovementComponent->onground) {
		CapsuleComponent->AddForce(Player->PhysicsSettings.Gravity*FVector::UpVector, NAME_None, true);
	}

	CapsuleComponent->SetPhysicsLinearVelocity(Velocity2D.Size()*Forward*FMath::Sign(Velocity2D |Forward) + CapsuleComponent->GetPhysicsLinearVelocity().Z*FVector::UpVector);

	float thing = FMath::Lerp(FMath::Clamp(DeltaTime,0.0f,1.0f), 1.0f, FMath::Lerp((Velocity2D.Size() / PhysicsSettings.MaxVelocity)/2.0f,FMath::Pow(Velocity2D.Size() / PhysicsSettings.MaxVelocity, 8.0f), (Velocity2D.Size() / PhysicsSettings.MaxVelocity)));
	AdjustedTurnInput = FMath::Lerp(AdjustedTurnInput, MovementInput.X, DeltaTime);
	//CapsuleComponent->AddTorque(FVector::UpVector*MovementInput.X*PhysicsSettings.TurnRate*FMath::Clamp(1.4f - FMath::Pow(Velocity2D.Size() / PhysicsSettings.MaxVelocity, 1.5f),0.0f,1.0f), NAME_None, true);
	//CapsuleComponent->BodyInstance.bLockZRotation = false;
	MovementComponent->grounddetecttfudgefactor = FMath::Clamp(1.0f - FMath::Pow(Velocity2D.Size() / PhysicsSettings.MaxVelocity,0.5f),0.0f,1.0f);
	CapsuleComponent->SetWorldRotation(CapsuleComponent->GetComponentRotation() + FRotator(0.0, AdjustedTurnInput*PhysicsSettings.TurnRate *(1.1f - FMath::Pow(Velocity2D.Size() / PhysicsSettings.MaxVelocity, 1.5f))*DeltaTime,0.0f), NAME_None,nullptr, ETeleportType::TeleportPhysics);
	//CapsuleComponent->BodyInstance.bLockZRotation = true;


	Player->SetActorLocation(GetActorLocation() + 260.0f*FVector::UpVector, false, nullptr, ETeleportType::TeleportPhysics);
	Player->PlayerModel->SetWorldRotation(FRotator(0.0f, GetActorRotation().Yaw, 0.0f));
}
开发者ID:chris-hamer,项目名称:shards,代码行数:61,代码来源:SandShip.cpp



注:本文中的GetActorRotation函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetAdaptersInfo函数代码示例发布时间:2022-05-30
下一篇:
C++ GetActorLocation函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap