当前位置: 首页>>代码示例>>C++>>正文


C++ UPrimitiveComponent::PutRigidBodyToSleep方法代码示例

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


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

示例1: SetPossessor

/** 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

示例2: 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

示例3: RoundHasStarted_Implementation

/** Called by the GameMode object when the next round has begun */
void AMagicBattleSoccerBall::RoundHasStarted_Implementation()
{
    if (Role == ROLE_Authority)
    {
        if (nullptr != Possessor)
        {
            SetPossessor(nullptr); // This change will be replicated to all clients
        }
        else
        {
            UPrimitiveComponent *Root = Cast<UPrimitiveComponent>(GetRootComponent());
            Root->PutRigidBodyToSleep();
        }
        PossessorToIgnore = nullptr;
    }
}
开发者ID:Gamieon,项目名称:UBattleSoccerPrototype,代码行数:17,代码来源:MagicBattleSoccerBall.cpp


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