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

C++ UPrimitiveComponent类代码示例

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

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



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

示例1: FlushRenderingCommands

FGlobalComponentReregisterContext::FGlobalComponentReregisterContext(const TArray<AActor*>& InParentActors)
{
	ActiveGlobalReregisterContextCount++;

	// wait until resources are released
	FlushRenderingCommands();

	// Detach only actor components that are children of the actors list provided
	for(TObjectIterator<UActorComponent> ComponentIt;ComponentIt;++ComponentIt)
	{
		bool bShouldReregister=false;
		UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(*ComponentIt);
		if (PrimitiveComponent && PrimitiveComponent->ReplacementPrimitive.Get())
		{
			UPrimitiveComponent* ReplacementPrimitive = PrimitiveComponent->ReplacementPrimitive.Get();
			AActor* ParentActor = Cast<AActor>(ReplacementPrimitive->GetOuter());
			if (ParentActor && InParentActors.Contains(ParentActor))
			{
				bShouldReregister = true;
			}
		}
		if( bShouldReregister )
		{
			new(ComponentContexts) FComponentReregisterContext(*ComponentIt);		
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:27,代码来源:ActorComponent.cpp


示例2: GatherCurrentMovement

void AActor::GatherCurrentMovement()
{
	UPrimitiveComponent* RootPrimComp = Cast<UPrimitiveComponent>(GetRootComponent());
	if (RootPrimComp && RootPrimComp->IsSimulatingPhysics())
	{
		FRigidBodyState RBState;
		RootPrimComp->GetRigidBodyState(RBState);

		ReplicatedMovement.FillFrom(RBState);
	}
	else if(RootComponent != NULL)
	{
		// If we are attached, don't replicate absolute position
		if( RootComponent->AttachParent != NULL )
		{
			// Networking for attachments assumes the RootComponent of the AttachParent actor. 
			// If that's not the case, we can't update this, as the client wouldn't be able to resolve the Component and would detach as a result.
			if( AttachmentReplication.AttachParent != NULL )
			{
				AttachmentReplication.LocationOffset = RootComponent->RelativeLocation;
				AttachmentReplication.RotationOffset = RootComponent->RelativeRotation;
				AttachmentReplication.RelativeScale3D = RootComponent->RelativeScale3D;
			}
		}
		else
		{
			ReplicatedMovement.Location = RootComponent->GetComponentLocation();
			ReplicatedMovement.Rotation = RootComponent->GetComponentRotation();
			ReplicatedMovement.LinearVelocity = GetVelocity();
			ReplicatedMovement.bRepPhysics = false;
		}
	}
}
开发者ID:johndpope,项目名称:UE4,代码行数:33,代码来源:ActorReplication.cpp


示例3:

void FBodyInstance2D::TermBody()
{
#if WITH_BOX2D
	UPrimitiveComponent* OwnerComponent = OwnerComponentPtr.Get();
	//@TODO: Handle this - check(OwnerComponent);
	if (OwnerComponent == NULL)
	{
		return;
	}

	if (BodyInstancePtr != NULL)
	{
		if (b2World* World = FPhysicsIntegration2D::FindAssociatedWorld(OwnerComponent->GetWorld()))
		{
			World->DestroyBody(BodyInstancePtr);
		}
		else
		{
			BodyInstancePtr->SetUserData(NULL);
		}

		BodyInstancePtr = NULL;
	}
#endif
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:25,代码来源:BodyInstance2D.cpp


示例4: SetActorSelectionFlags

void UUnrealEdEngine::SetActorSelectionFlags (AActor* InActor)
{
	TInlineComponentArray<UActorComponent*> Components;
	InActor->GetComponents(Components);

	//for every component in the actor
	for(int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
	{
		UActorComponent* Component = Components[ComponentIndex];
		if (Component->IsRegistered())
		{
			// If we have a 'child actor' component, want to update its visible selection state
			UChildActorComponent* ChildActorComponent = Cast<UChildActorComponent>(Component);
			if(ChildActorComponent != NULL && ChildActorComponent->ChildActor != NULL)
			{
				SetActorSelectionFlags(ChildActorComponent->ChildActor);
			}

			UPrimitiveComponent* PrimComponent = Cast<UPrimitiveComponent>(Component);
			if(PrimComponent != NULL && PrimComponent->IsRegistered())
			{
				PrimComponent->PushSelectionToProxy();
			}

			UDecalComponent* DecalComponent = Cast<UDecalComponent>(Component);
			if(DecalComponent != NULL)// && DecalComponent->IsRegistered())
			{
				DecalComponent->PushSelectionToProxy();
			}
		}
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:32,代码来源:EditorSelectUtils.cpp


示例5: GetPawn

void ACinemotusPlayerController::AbsoluteTick(float DeltaTime)
{

	
	TotalYawAbs += addYaw;
	UPrimitiveComponent* prim = GetPawn()->GetMovementComponent()->UpdatedComponent;
	//USceneComponent* sComponent = GetPawn()->GetRootComponent();
	//sComponent->SetRelativeLocation;

	bool SetPrimDirectly = true;
	FQuat finalQuat;

	if (((currentCaptureState&ECinemotusCaptureState::EAbsolute) == ECinemotusCaptureState::EAbsolute) && 
		((currentCaptureState&ECinemotusCaptureState::EAbsoluteOff) == 0))
	{
		finalQuat = FRotator(0, TotalYawAbs, 0).Quaternion()*(HydraLatestData->controllers[CAM_HAND].quat);
	}
	else
	{
		finalQuat =  FRotator(0, addYaw, 0).Quaternion()*prim->GetComponentQuat();
	}
	SetControlRotation(finalQuat.Rotator());
	if (SetPrimDirectly && prim)
	{
		prim->SetWorldLocationAndRotation(prim->GetComponentLocation(), finalQuat);// not sure need
	}


	HandleMovementAbs(DeltaTime, ((currentCaptureState&ECinemotusCaptureState::EAbsolute) == ECinemotusCaptureState::EAbsolute));
}
开发者ID:erinmichno,项目名称:CinemotusUE4,代码行数:30,代码来源:CinemotusPlayerController.cpp


示例6: GetWorld

void UBuoyancyForceComponent::InitializeComponent()
{
	Super::InitializeComponent();

	//UE_LOG(LogTemp, Warning, TEXT("We're initializing..."));

	//Store the world ref.
	World = GetWorld();

	// If no OceanManager is defined, auto-detect
	if (!OceanManager)
	{
		for (TActorIterator<AOceanManager> ActorItr(World); ActorItr; ++ActorItr)
		{
			OceanManager = Cast<AOceanManager>(*ActorItr);
			break;
		}
	}

	TestPointRadius = FMath::Abs(TestPointRadius);

	UPrimitiveComponent* BasePrimComp = Cast<UPrimitiveComponent>(GetAttachParent());
	if (BasePrimComp)
	{
		ApplyUprightConstraint(BasePrimComp);

		//Store the initial damping values.
		_baseLinearDamping = BasePrimComp->GetLinearDamping();
		_baseAngularDamping = BasePrimComp->GetAngularDamping();
	}
}
开发者ID:midgen,项目名称:cashgenUE,代码行数:31,代码来源:BuoyancyForceComponent.cpp


示例7: OnGetBodyMass

FText FPrimitiveComponentDetails::OnGetBodyMass() const
{
	UPrimitiveComponent* Comp = NULL;

	float Mass = 0.0f;
	bool bMultipleValue = false;

	for (auto ObjectIt = ObjectsCustomized.CreateConstIterator(); ObjectIt; ++ObjectIt)
	{
		if(ObjectIt->IsValid() && (*ObjectIt)->IsA(UPrimitiveComponent::StaticClass()))
		{
			Comp = Cast<UPrimitiveComponent>(ObjectIt->Get());

			float CompMass = Comp->CalculateMass();
			if (Mass == 0.0f || FMath::Abs(Mass - CompMass) < 0.1f)
			{
				Mass = CompMass;
			}
			else
			{
				bMultipleValue = true;
				break;
			}
		}
	}

	if (bMultipleValue)
	{
		return LOCTEXT("MultipleValues", "Multiple Values");
	}

	return FText::AsNumber(Mass);
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:33,代码来源:PrimitiveComponentDetails.cpp


示例8: BeginPlay

/** This occurs when play begins */
void AMagicBattleSoccerBall::BeginPlay()
{
    Super::BeginPlay();

    if (Role < ROLE_Authority)
    {
        // The server manages the game state; the soccer ball will be replicated to us.

        // Physics however are not replicated. We will need to have the ball orientation
        // replicated to us. We need to turn off physics simulation and collision detection.
        UPrimitiveComponent *Root = Cast<UPrimitiveComponent>(GetRootComponent());
        Root->PutRigidBodyToSleep();
        Root->SetSimulatePhysics(false);
        Root->SetEnableGravity(false);
        SetActorEnableCollision(false);
    }
    else
    {
        // Servers should add this soccer ball to the game mode cache.
        // It will get replicated to clients for when they need to access
        // the ball itself to get information such as who possesses it.
        AMagicBattleSoccerGameState* GameState = GetGameState();
        GameState->SoccerBall = this;
    }
}
开发者ID:Gamieon,项目名称:UBattleSoccerPrototype,代码行数:26,代码来源:MagicBattleSoccerBall.cpp


示例9: GetBodyInstance

bool UPrimitiveComponent::WeldToImplementation(USceneComponent * InParent, FName ParentSocketName /* = Name_None */, bool bWeldSimulatedChild /* = false */)
{
	//WeldToInternal assumes attachment is already done
	if (AttachParent != InParent || AttachSocketName != ParentSocketName)
	{
		return false;
	}

	//Check that we can actually our own socket name
	FBodyInstance* BI = GetBodyInstance(NAME_None, false);
	if (BI == NULL)
	{
		return false;
	}

	if (BI->ShouldInstanceSimulatingPhysics() && bWeldSimulatedChild == false)
	{
		return false;
	}

	UnWeldFromParent();	//make sure to unweld from wherever we currently are

	FName SocketName;
	UPrimitiveComponent * RootComponent = GetRootWelded(this, ParentSocketName, &SocketName, true);

	if (RootComponent)
	{
		if (FBodyInstance* RootBI = RootComponent->GetBodyInstance(SocketName, false))
		{
			if (BI->WeldParent == RootBI)	//already welded so stop
			{
				return true;
			}

			BI->bWelded = true;
			//There are multiple cases to handle:
			//Root is kinematic, simulated
			//Child is kinematic, simulated
			//Child always inherits from root

			//if root is kinematic simply set child to be kinematic and we're done
			if (RootComponent->IsSimulatingPhysics(SocketName) == false)
			{
				BI->WeldParent = NULL;
				SetSimulatePhysics(false);
				return false;	//return false because we need to continue with regular body initialization
			}

			//root is simulated so we actually weld the body
			FTransform RelativeTM = RootComponent == AttachParent ? GetRelativeTransform() : GetComponentToWorld().GetRelativeTransform(RootComponent->GetComponentToWorld());	//if direct parent we already have relative. Otherwise compute it
			RootBI->Weld(BI, GetComponentToWorld());
			BI->WeldParent = RootBI;

			return true;
		}
	}

	return false;
}
开发者ID:johndpope,项目名称:UE4,代码行数:59,代码来源:PrimitiveComponentPhysics.cpp


示例10: MoveIgnoreActorRemove

void APawn::MoveIgnoreActorRemove(AActor* ActorToIgnore)
{
	UPrimitiveComponent* RootPrimitiveComponent = Cast<UPrimitiveComponent>(GetRootComponent());
	if( RootPrimitiveComponent )
	{
		RootPrimitiveComponent->IgnoreActorWhenMoving(ActorToIgnore, false);
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:8,代码来源:Pawn.cpp


示例11: RemoveViewFromActorViewVisibility

void FLayers::RemoveViewFromActorViewVisibility( FLevelEditorViewportClient* ViewportClient )
{
	const int32 ViewIndex = ViewportClient->ViewIndex;

	// get the bit for the view index
	uint64 ViewBit = ((uint64)1 << ViewIndex);
	// get all bits under that that we want to keep
	uint64 KeepBits = ViewBit - 1;

	// Iterate over all actors, looking for actors in the specified layers.
	for( FActorIterator It(ViewportClient->GetWorld()) ; It ; ++It )
	{
		const TWeakObjectPtr< AActor > Actor = *It;

		if( !IsActorValidForLayer( Actor ) )
		{
			continue;
		}

		// remember original bits
		uint64 OriginalHiddenViews = Actor->HiddenEditorViews;

		uint64 Was = Actor->HiddenEditorViews;

		// slide all bits higher than ViewIndex down one since the view is being removed from Editor
		uint64 LowBits = Actor->HiddenEditorViews & KeepBits;

		// now slide the top bits down by ViewIndex + 1 (chopping off ViewBit)
		uint64 HighBits = Actor->HiddenEditorViews >> (ViewIndex + 1);
		// then slide back up by ViewIndex, which will now have erased ViewBit, as well as leaving 0 in the low bits
		HighBits = HighBits << ViewIndex;

		// put it all back together
		Actor->HiddenEditorViews = LowBits | HighBits;

		// reregister if we changed the visibility bits, as the rendering thread needs them
		if (OriginalHiddenViews == Actor->HiddenEditorViews)
		{
			continue;
		}

		// Find all registered primitive components and update the scene proxy with the actors updated visibility map
		TInlineComponentArray<UPrimitiveComponent*> Components;
		Actor->GetComponents(Components);

		for( int32 ComponentIdx = 0; ComponentIdx < Components.Num(); ++ComponentIdx )
		{
			UPrimitiveComponent* PrimitiveComponent = Components[ComponentIdx];
			if (PrimitiveComponent->IsRegistered())
			{
				// Push visibility to the render thread
				PrimitiveComponent->PushEditorVisibilityToProxy( Actor->HiddenEditorViews );
			}
		}
	}
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:56,代码来源:Layers.cpp


示例12: OnConstruction

void ABomb::OnConstruction(const FTransform &Transform)
{
	UPrimitiveComponent *pc = Cast<UPrimitiveComponent>(GetComponent(RootComponent, "BombMesh"));

	if (pc)
	{
		BombMIB = pc->CreateDynamicMaterialInstance(0, NULL);
		SetBombColor(FLinearColor::Black);
	}
}
开发者ID:marcthenarc,项目名称:NetGameCPP,代码行数:10,代码来源:Bomb.cpp


示例13: GetSequencer

UMaterialInterface* FComponentMaterialTrackEditor::GetMaterialInterfaceForTrack( FGuid ObjectBinding, UMovieSceneMaterialTrack* MaterialTrack )
{
	UObject* ComponentObject = GetSequencer()->GetFocusedMovieSceneSequence()->FindObject( ObjectBinding );
	UPrimitiveComponent* Component = Cast<UPrimitiveComponent>( ComponentObject );
	UMovieSceneComponentMaterialTrack* ComponentMaterialTrack = Cast<UMovieSceneComponentMaterialTrack>( MaterialTrack );
	if ( Component != nullptr && ComponentMaterialTrack != nullptr )
	{
		return Component->GetMaterial( ComponentMaterialTrack->GetMaterialIndex() );
	}
	return nullptr;
}
开发者ID:ErwinT6,项目名称:T6Engine,代码行数:11,代码来源:MaterialTrackEditor.cpp


示例14: MoveWithPossessor

void AMagicBattleSoccerBall::Tick(float DeltaSeconds)
{
    Super::Tick(DeltaSeconds);

    if (nullptr != Possessor)
    {
        // If the ball is possessed by a player, then the ball should move as a function
        // of the possessor
        MoveWithPossessor();
    }
    else
    {
        // No possessor. The ball is freely moving.
        if (Role < ROLE_Authority)
        {
            // Clients should update its local position based on where it is on the server
            ClientSimulateFreeMovingBall();
        }
        else
        {
            // Update the charging value
            if (GetVelocity().SizeSquared() > 1.f)
            {
                IsCharging = false;
            }

            // Servers should simulate the ball physics freely and replicate the orientation
            UPrimitiveComponent *Root = Cast<UPrimitiveComponent>(GetRootComponent());
            ServerPhysicsState.pos = GetActorLocation();
            ServerPhysicsState.rot = GetActorRotation();
            ServerPhysicsState.vel = Root->GetComponentVelocity();
            ServerPhysicsState.timestamp = AMagicBattleSoccerPlayerController::GetLocalTime();

            // Servers should also test the distance from the old possessor and reset it
            if (nullptr != PossessorToIgnore)
            {
                if (!PossessorToIgnore->IsAlive())
                {
                    PossessorToIgnore = nullptr;
                }
                else
                {
                    FVector2D PossessorLoc(PossessorToIgnore->GetActorLocation());
                    FVector2D BallLoc(GetActorLocation());
                    float d = FVector2D::DistSquared(PossessorLoc, BallLoc);
                    if (d > 14000)
                    {
                        PossessorToIgnore = nullptr;
                    }
                }
            }
        }
    }
}
开发者ID:Gamieon,项目名称:UBattleSoccerPrototype,代码行数:54,代码来源:MagicBattleSoccerBall.cpp


示例15: GetActorLocation

void AFP_FirstPersonCharacter::OnFire()
{
	// Play a sound if there is one
	if (FireSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
	}

	// try and play a firing animation if specified
	if(FireAnimation != NULL)
	{
		// Get the animation object for the arms mesh
		UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
		if(AnimInstance != NULL)
		{
			AnimInstance->Montage_Play(FireAnimation, 1.f);
		}
	}

	// Now send a trace from the end of our gun to see if we should hit anything
	APlayerController* PlayerController = Cast<APlayerController>(GetController());
	
	// Calculate the direction of fire and the start location for trace
	FVector CamLoc;
	FRotator CamRot;
	PlayerController->GetPlayerViewPoint(CamLoc, CamRot);
	const FVector ShootDir = CamRot.Vector();

	FVector StartTrace = FVector::ZeroVector;
	if (PlayerController)
	{
		FRotator UnusedRot;
		PlayerController->GetPlayerViewPoint(StartTrace, UnusedRot);

		// Adjust trace so there is nothing blocking the ray between the camera and the pawn, and calculate distance from adjusted start
		StartTrace = StartTrace + ShootDir * ((GetActorLocation() - StartTrace) | ShootDir);
	}

	// Calculate endpoint of trace
	const FVector EndTrace = StartTrace + ShootDir * WeaponRange;

	// Check for impact
	const FHitResult Impact = WeaponTrace(StartTrace, EndTrace);

	// Deal with impact
	AActor* DamagedActor = Impact.GetActor();
	UPrimitiveComponent* DamagedComponent = Impact.GetComponent();

	// If we hit an actor, with a component that is simulating physics, apply an impulse
	if ((DamagedActor != NULL) && (DamagedActor != this) && (DamagedComponent != NULL) && DamagedComponent->IsSimulatingPhysics())
	{
		DamagedComponent->AddImpulseAtLocation(ShootDir*WeaponDamage, Impact.Location);
	}
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:54,代码来源:FP_FirstPersonCharacter.cpp


示例16: PostNetReceivePhysicState

void AActor::PostNetReceivePhysicState()
{
	UPrimitiveComponent* RootPrimComp = Cast<UPrimitiveComponent>(RootComponent);
	if (RootPrimComp)
	{
		FRigidBodyState NewState;
		ReplicatedMovement.CopyTo(NewState);

		FVector DeltaPos(FVector::ZeroVector);
		RootPrimComp->ConditionalApplyRigidBodyState(NewState, GEngine->PhysicErrorCorrection, DeltaPos);
	}
}
开发者ID:johndpope,项目名称:UE4,代码行数:12,代码来源:ActorReplication.cpp


示例17: GetMovementBase

bool APawn::IsBasedOnActor(const AActor* Other) const
{
	UPrimitiveComponent * MovementBase = GetMovementBase();
	AActor* MovementBaseActor = MovementBase ? MovementBase->GetOwner() : NULL;

	if (MovementBaseActor && MovementBaseActor == Other)
	{
		return true;
	}

	return Super::IsBasedOnActor(Other);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:12,代码来源:Pawn.cpp


示例18: ClosestPoint

bool APhysicsVolume::IsOverlapInVolume(const class USceneComponent& TestComponent) const
{
	bool bInsideVolume = true;
	if (!bPhysicsOnContact)
	{
		FVector ClosestPoint(0.f);
		UPrimitiveComponent* RootPrimitive = Cast<UPrimitiveComponent>(GetRootComponent());
		const float DistToCollision = RootPrimitive ? RootPrimitive->GetDistanceToCollision(TestComponent.GetComponentLocation(), ClosestPoint) : 0.f;
		bInsideVolume = (DistToCollision == 0.f);
	}

	return bInsideVolume;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:13,代码来源:PhysicsVolume.cpp


示例19: GetPhysicsGrip

bool UGripMotionControllerComponent::TeleportMoveGrippedActor(AActor * GrippedActorToMove)
{
	if (!GrippedActorToMove || !GrippedActors.Num())
		return false;

	FTransform WorldTransform;
	FTransform InverseTransform = this->GetComponentTransform().Inverse();
	for (int i = GrippedActors.Num() - 1; i >= 0; --i)
	{
		if (GrippedActors[i].Actor == GrippedActorToMove)
		{
			// GetRelativeTransformReverse had some serious fucking floating point errors associated with it that was fucking everything up
			// Not sure whats wrong with the function but I might want to push a patch out eventually
			WorldTransform = GrippedActors[i].RelativeTransform.GetRelativeTransform(InverseTransform);

			// Need to use WITH teleport for this function so that the velocity isn't updated and without sweep so that they don't collide
			GrippedActors[i].Actor->SetActorTransform(WorldTransform, false, NULL, ETeleportType::TeleportPhysics);
			
			FBPActorPhysicsHandleInformation * Handle = GetPhysicsGrip(GrippedActors[i]);
			if (Handle && Handle->KinActorData)
			{

				{
					PxScene* PScene = GetPhysXSceneFromIndex(Handle->SceneIndex);
					if (PScene)
					{
						SCOPED_SCENE_WRITE_LOCK(PScene);
						Handle->KinActorData->setKinematicTarget(PxTransform(U2PVector(WorldTransform.GetLocation()), Handle->KinActorData->getGlobalPose().q));
						Handle->KinActorData->setGlobalPose(PxTransform(U2PVector(WorldTransform.GetLocation()), Handle->KinActorData->getGlobalPose().q));
					}
				}
				//Handle->KinActorData->setGlobalPose(PxTransform(U2PVector(WorldTransform.GetLocation()), Handle->KinActorData->getGlobalPose().q));

				UPrimitiveComponent *root = Cast<UPrimitiveComponent>(GrippedActors[i].Actor->GetRootComponent());
				if (root)
				{
					FBodyInstance * body = root->GetBodyInstance();
					if (body)
					{
						body->SetBodyTransform(WorldTransform, ETeleportType::TeleportPhysics);
					}
				}
			}
			
			return true;
		}
	}

	return false;
}
开发者ID:ProteusVR,项目名称:SteamVR_Template,代码行数:50,代码来源:GripMotionControllerComponent.cpp


示例20: SetActorEnableCollision

/** Sets the current ball possessor */
void AMagicBattleSoccerBall::SetPossessor(AMagicBattleSoccerCharacter* Player)
{
    if (Role < ROLE_Authority)
    {
        // Safety check. Only authority entities should drive the ball.
    }
    else
    {
        // We only allow a possession change if the ball is being unpossessed or the player is not one we're ignoring
        if (nullptr == Player || (CanPossessBall(Player) && (PossessorToIgnore != Player)))
        {
            AMagicBattleSoccerCharacter *OldPossessor = Possessor;

            // Assign the new possessor
            Possessor = Player;

            // Handle cases when the ball had a possessor in the previous frame
            if (nullptr != OldPossessor)
            {
                // Assign the last possessor
                LastPossessor = OldPossessor;
                // Assign the possessor to ignore
                PossessorToIgnore = OldPossessor;
            }

            // Toggle physics
            UPrimitiveComponent *Root = Cast<UPrimitiveComponent>(GetRootComponent());
            if (nullptr != Possessor)
            {
                Possessor->StopWeaponFire(Possessor->PrimaryWeapon);
                Possessor->StopWeaponFire(Possessor->SecondaryWeapon);
                Root->PutRigidBodyToSleep();
                Root->SetSimulatePhysics(false);
                Root->SetEnableGravity(false);
                SetActorEnableCollision(false);
                MoveWithPossessor();
            }
            else
            {
                Root->SetSimulatePhysics(true);
                Root->SetEnableGravity(true);
                SetActorEnableCollision(true);
                Root->PutRigidBodyToSleep();
            }
        }

        // Force the orientation to be replicated at the same time the possessor is replicated
        UPrimitiveComponent *Root = Cast<UPrimitiveComponent>(GetRootComponent());
        ServerPhysicsState.pos = GetActorLocation();
        ServerPhysicsState.rot = GetActorRotation();
        ServerPhysicsState.vel = Root->GetComponentVelocity();
        ServerPhysicsState.timestamp = AMagicBattleSoccerPlayerController::GetLocalTime();
    }
}
开发者ID:Gamieon,项目名称:UBattleSoccerPrototype,代码行数:55,代码来源:MagicBattleSoccerBall.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ UProperty类代码示例发布时间:2022-05-31
下一篇:
C++ UPaperSprite类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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