本文整理汇总了C++中GetWorld函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWorld函数的具体用法?C++ GetWorld怎么用?C++ GetWorld使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetWorld函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetMesh
void AZombieCharacter::Attack()
{
//This function is used only when it's permitted by the zombie's animation instance
//It creates a raycast in a sphere shape and checks for possible hits
//If the hits contain our player it makes sure it applies damage to him
//Setting up the start and end location of the raycast
FVector StartLocation = GetMesh()->GetSocketLocation(FName("MeleeStartSocket"));
FVector EndLocation = GetMesh()->GetSocketLocation(FName("MeleeEndSocket"));
//Raycasting in a sphere to detect collisions
TArray<FHitResult> HitResults;
//Setting up the shape of the raycast
FCollisionShape CollisionShape;
CollisionShape.ShapeType = ECollisionShape::Sphere;
CollisionShape.SetSphere(AttackRaycastRadius);
//Object query parameters
FCollisionObjectQueryParams ObjectQueryParams;
ObjectQueryParams.AllDynamicObjects;
//Handling ignored actors
FCollisionQueryParams QueryParams;
QueryParams.AddIgnoredActor(this);
UWorld* World = GetWorld();
if (World && ZAnimInstance->bEligibleForAttack)
{
//Raycasting...
bool bHit = World->SweepMultiByObjectType(HitResults, StartLocation, EndLocation, FQuat::Identity, ObjectQueryParams, CollisionShape, QueryParams);
//Raycast visualization
/*FVector Center = ((EndLocation - StartLocation) / 2) + StartLocation;
DrawDebugSphere(World, Center, AttackRaycastRadius, 20, FColor::Green, false, 2.f);*/
//Checking for possible hits
if (bHit)
{
for (auto It = HitResults.CreateIterator(); It; It++)
{
ARoguelikeChar* Char = Cast<ARoguelikeChar>(It->GetActor());
if (Char && ZAnimInstance && GetCharacterMovement())
{
//Calling the attack function from character
Char->TakeDamageFromZombie(Damage);
//Closing the flag which checks for the attack function
ZAnimInstance->bEligibleForAttack = false;
//Updating with new movement speed
GetCharacterMovement()->MaxWalkSpeed = InitialMaxWalkSpeed;
ZAnimInstance->Speed = InitialMaxWalkSpeed;
break;
}
}
}
}
}
开发者ID:AbDoMoHaMmEd,项目名称:PortfolioSnippets,代码行数:61,代码来源:ZombieCharacter.cpp
示例2: AddControllerPitchInput
// look up rate
void AClashOfBallsBall::LookUpAtRate(float Rate)
{
//UE_LOG(LogTemp, Warning, TEXT("LookUp/Down"));
// calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}
开发者ID:eternalst0rm,项目名称:ClashOfBalls,代码行数:7,代码来源:ClashOfBallsBall.cpp
示例3: TEXT
void ASpawnEnemy::SpawnRandomEnemy()
{
TArray<FString> Parsed;
TArray<FString> HowMuch;
TArray<FString> TypeEnemy;
const TCHAR* Delims[] = { TEXT(":"), TEXT(";") };
float RandomNumber = (float)rand() / (float)RAND_MAX;
int SetNumber = RandomNumber * (Enemies.Num());
Enemies[SetNumber].ParseIntoArray(&Parsed, Delims, 2);
int SizeOfArrayParsed = Parsed.Num() - 1;
for (int x = 0; x <= SizeOfArrayParsed; x = x + 2) {
HowMuch.Add(Parsed[x]);
}
for (int x = 1; x <= SizeOfArrayParsed; x = x + 2) {
TypeEnemy.Add(Parsed[x]);
}
for (auto Itr(HowMuch.CreateIterator()); Itr; Itr++) {
APawn* NewPawn = NULL;
FVector BoxOnWorld = GetActorLocation();
FRotator RotatorBoxOnWorld = GetActorRotation();
FBox BoxInfo = GetComponentsBoundingBox();
FVector BoxSize = BoxInfo.GetSize();
if (TypeEnemy[Itr.GetIndex()] == "PegEnemyLight")
{
EnemyClass = PegLightEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "PegDarkEnemy") {
EnemyClass = PegDarkEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "GarbageEnemy") {
EnemyClass = GarbageEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "MeleeBookEnemy") {
EnemyClass = MeleeBookEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "RangeBookEnemy") {
EnemyClass = RangeBookEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "PianoChargeEnemy") {
EnemyClass = PianoEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "BarrelChargeEnemy") {
EnemyClass = BarrelEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "FridgeChargeEnemy") {
EnemyClass = FridgeEnemyClass;
}
if (GetWorld())
{
int32 MyShinyNewInt = FCString::Atoi(*HowMuch[Itr.GetIndex()]);
for (int x = 1; x <= MyShinyNewInt; x++) {
float random = (float)rand() / (float)RAND_MAX;
float randomy = (float)rand() / (float)RAND_MAX;
int xValue = 1 + random * ((3) - (1));
int yValue = 1 + randomy * ((3) - (1));
float z, y;
if (xValue == 1)
z = random * (0 + (BoxSize[0] / 2));
else
z = random * (0 - (BoxSize[0] / 2));
if (yValue == 1)
y = random * (0 + (BoxSize[1] / 2));
else
y = random * (0 - (BoxSize[1] / 2));
BoxOnWorld[0] += z;
BoxOnWorld[1] += y;
if (ShouldSpawnEnemies)
{
if (BoxInfo.IsInside(BoxOnWorld))
{
NewPawn = GetWorld()->SpawnActor<AAI_BasicEnemy>(EnemyClass, BoxOnWorld, RotatorBoxOnWorld);
FVector BoxOnWorld = GetActorLocation();
if (NewPawn != NULL)
{
if (NewPawn->Controller == NULL)
{
NewPawn->SpawnDefaultController();
}
if (BehaviorTree != NULL)
{
AAIController* AIController = Cast<AAIController>(NewPawn->Controller);
if (AIController != NULL)
{
AIController->RunBehaviorTree(BehaviorTree);
}
}
}
//.........这里部分代码省略.........
开发者ID:pcerioli,项目名称:MOOnshineWorks,代码行数:101,代码来源:SpawnEnemy.cpp
示例4: GetWorld
float APhysicsVolume::GetGravityZ() const
{
return GetWorld()->GetGravityZ();
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:4,代码来源:PhysicsVolume.cpp
示例5: PostNetReceiveLocationAndRotation
void APawn::PostNetReceiveLocationAndRotation()
{
// 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( (ReplicatedMovement.Location == GetActorLocation() && ReplicatedMovement.Rotation == GetActorRotation()) && (CreationTime != GetWorld()->TimeSeconds) )
{
return;
}
if( Role == ROLE_SimulatedProxy )
{
// Correction to make sure pawn doesn't penetrate floor after replication rounding
ReplicatedMovement.Location.Z += 0.01f;
const FVector OldLocation = GetActorLocation();
const FQuat OldRotation = GetActorQuat();
SetActorLocationAndRotation(ReplicatedMovement.Location, ReplicatedMovement.Rotation, /*bSweep=*/ false);
INetworkPredictionInterface* PredictionInterface = Cast<INetworkPredictionInterface>(GetMovementComponent());
if (PredictionInterface)
{
PredictionInterface->SmoothCorrection(OldLocation, OldRotation, ReplicatedMovement.Location, ReplicatedMovement.Rotation.Quaternion());
}
}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:24,代码来源:Pawn.cpp
示例6: AddControllerPitchInput
void APluginsCharacter::LookUpAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}
开发者ID:ZioYuri78,项目名称:Unreal-Engine-4-Plugins,代码行数:5,代码来源:PluginsCharacter.cpp
示例7: GetNavData
bool UNavigationComponent::GeneratePathTo(const FVector& GoalLocation, TSharedPtr<const FNavigationQueryFilter> QueryFilter)
{
if (GetWorld() == NULL || GetWorld()->GetNavigationSystem() == NULL || GetOuter() == NULL)
{
return false;
}
// Make sure we're trying to path to the closest valid location TO that location rather than the absolute location.
// After talking with Steve P., if we need to ever allow pathing WITHOUT projecting to nav-mesh, it will probably be
// best to do so using a flag while keeping this as the default behavior. NOTE:` If any changes to this behavior
// are made, you should search for other places in UNavigationComponent using NavMeshGoalLocation and make sure the
// behavior remains consistent.
// make sure that nav data is updated
GetNavData();
const FNavAgentProperties* NavAgentProps = MyNavAgent ? MyNavAgent->GetNavAgentProperties() : NULL;
if (NavAgentProps != NULL)
{
FVector NavMeshGoalLocation;
#if ENABLE_VISUAL_LOG
UE_VLOG_LOCATION(GetOwner(), GoalLocation, 34, FColor(0,127,14), TEXT("GoalLocation"));
const FVector ProjectionExtent = MyNavData ? MyNavData->GetDefaultQueryExtent() : FVector(DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_HORIZONTAL, DEFAULT_NAV_QUERY_EXTENT_VERTICAL);
UE_VLOG_BOX(GetOwner(), FBox(GoalLocation - ProjectionExtent, GoalLocation + ProjectionExtent), FColor::Green, TEXT_EMPTY);
#endif
if (ProjectPointToNavigation(GoalLocation, NavMeshGoalLocation) == QuerySuccess)
{
UE_VLOG_SEGMENT(GetOwner(), GoalLocation, NavMeshGoalLocation, FColor::Blue, TEXT_EMPTY);
UE_VLOG_LOCATION(GetOwner(), NavMeshGoalLocation, 34, FColor::Blue, TEXT_EMPTY);
UNavigationSystem* NavSys = GetWorld()->GetNavigationSystem();
FPathFindingQuery Query(MyNavData, MyNavAgent->GetNavAgentLocation(), NavMeshGoalLocation, QueryFilter);
const EPathFindingMode::Type Mode = bDoHierarchicalPathfinding ? EPathFindingMode::Hierarchical : EPathFindingMode::Regular;
FPathFindingResult Result = NavSys->FindPathSync(*MyNavAgent->GetNavAgentProperties(), Query, Mode);
// try reversing direction
if (bSearchFromGoalWhenOutOfNodes && !bDoHierarchicalPathfinding &&
Result.Path.IsValid() && Result.Path->DidSearchReachedLimit())
{
// quick check if path exists
bool bPathExists = false;
{
DECLARE_SCOPE_CYCLE_COUNTER(TEXT("Pathfinding: HPA* test time"), STAT_Navigation_PathVerifyTime, STATGROUP_Navigation);
bPathExists = NavSys->TestPathSync(Query, EPathFindingMode::Hierarchical);
}
UE_VLOG(GetOwner(), LogNavigation, Log, TEXT("GeneratePathTo: out of nodes, HPA* path: %s"),
bPathExists ? TEXT("exists, trying reversed search") : TEXT("doesn't exist"));
// reverse search
if (bPathExists)
{
DECLARE_SCOPE_CYCLE_COUNTER(TEXT("Pathfinding: reversed test time"), STAT_Navigation_PathReverseTime, STATGROUP_Navigation);
TSharedPtr<FNavigationQueryFilter> Filter = QueryFilter.IsValid() ? QueryFilter->GetCopy() : MyNavData->GetDefaultQueryFilter()->GetCopy();
Filter->SetBacktrackingEnabled(true);
FPathFindingQuery ReversedQuery(MyNavData, Query.EndLocation, Query.StartLocation, Filter);
Result = NavSys->FindPathSync(*MyNavAgent->GetNavAgentProperties(), Query, Mode);
}
}
if (Result.IsSuccessful() || Result.IsPartial())
{
CurrentGoal = NavMeshGoalLocation;
SetPath(Result.Path);
if (IsFollowing() == true)
{
// make sure ticking is enabled (and it shouldn't be enabled before _first_ async path finding)
SetComponentTickEnabledAsync(true);
}
NotifyPathUpdate();
return true;
}
else
{
UE_VLOG(GetOwner(), LogNavigation, Display, TEXT("Failed to generate path to destination"));
}
}
else
{
UE_VLOG(GetOwner(), LogNavigation, Display, TEXT("Destination not on navmesh (and nowhere near!)"));
}
}
else
{
UE_VLOG(GetOwner(), LogNavigation, Display, TEXT("UNavigationComponent::GeneratePathTo: NavAgentProps == NULL (Probably Pawn died)"));
}
return false;
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:96,代码来源:NavigationComponent.cpp
示例8: UE_LOG
bool ANUTActor::NotifyControlMessage(UNetConnection* Connection, uint8 MessageType, FInBunch& Bunch)
{
bool bHandledMessage = false;
if (MessageType == NMT_NUTControl)
{
uint8 CmdType = 0;
FString Command;
FNetControlMessage<NMT_NUTControl>::Receive(Bunch, CmdType, Command);
// Console command
if (CmdType == ENUTControlCommand::Command_NoResult || CmdType == ENUTControlCommand::Command_SendResult)
{
UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Executing command: %s"), *Command);
FStringOutputDevice CmdResult;
CmdResult.SetAutoEmitLineTerminator(true);
bool bCmdSuccess = false;
bCmdSuccess = GEngine->Exec(GetWorld(), *Command, CmdResult);
UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Command result: %s"), *CmdResult);
bool bSendResult = CmdType == ENUTControlCommand::Command_SendResult;
if (bSendResult)
{
uint8 ReturnCmdType = (bCmdSuccess ? ENUTControlCommand::CommandResult_Success :
ENUTControlCommand::CommandResult_Failed);
FNetControlMessage<NMT_NUTControl>::Send(Connection, ReturnCmdType, CmdResult);
}
}
// Console command result
else if (CmdType == ENUTControlCommand::CommandResult_Failed || CmdType == ENUTControlCommand::CommandResult_Success)
{
bool bCmdSuccess = CmdType == ENUTControlCommand::CommandResult_Success;
if (bCmdSuccess)
{
UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Got command result:"));
UE_LOG(LogUnitTest, Log, TEXT("%s"), *Command);
}
else
{
UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Failed to execute command"));
}
}
// Ping request
else if (CmdType == ENUTControlCommand::Ping)
{
uint8 TempCmdType = ENUTControlCommand::Pong;
FString Dud;
FNetControlMessage<NMT_NUTControl>::Send(Connection, TempCmdType, Dud);
}
// Pong reply - this should only be implemented by custom unit tests; hence the assert
else if (CmdType == ENUTControlCommand::Pong)
{
UNIT_ASSERT(false);
}
// Custom implemented events, with the result triggered through 'NotifyEvent'
else if (CmdType == ENUTControlCommand::WatchEvent)
{
// NOTE: Only the last NetConnection to request a WatchEvent, will receive notifications
EventWatcher = Connection;
// Watch for the end of seamless travel
if (Command == TEXT("SeamlessTravelEnd"))
{
FCoreUObjectDelegates::PostLoadMap.AddStatic(&ANUTActor::NotifyPostLoadMap);
}
}
// Event watch notification - should only be implemented by custom unit tests
else if (CmdType == ENUTControlCommand::NotifyEvent)
{
UNIT_ASSERT(false);
}
// Create an actor instance (the 'summon' console command, doesn't work without a cheat manager)
else if (CmdType == ENUTControlCommand::Summon)
{
const TCHAR* Cmd = *Command;
FString SpawnClassName = FParse::Token(Cmd, false);
bool bForceBeginPlay = FParse::Param(Cmd, TEXT("ForceBeginPlay"));
// Hack specifically for getting the GameplayDebugger working - think the mainline code is broken
bool bGameplayDebuggerHack = FParse::Param(Cmd, TEXT("GameplayDebuggerHack"));
UClass* SpawnClass = FindObject<UClass>(NULL, *SpawnClassName);
if (SpawnClass != NULL)
{
FActorSpawnParameters SpawnParms;
SpawnParms.Owner = GetOwner();
AActor* NewActor = GetWorld()->SpawnActor<AActor>(SpawnClass, SpawnParms);
if (NewActor != NULL)
//.........这里部分代码省略.........
开发者ID:frobro98,项目名称:UnrealSource,代码行数:101,代码来源:NUTActor.cpp
示例9: GetActorLocation
void ALaser::checkLaserCollisions(float dt)
{
FHitResult hit;
FCollisionQueryParams queryParam;
queryParam.bFindInitialOverlaps = false;
queryParam.bReturnFaceIndex = true;
FCollisionObjectQueryParams objectParam = objectParam.DefaultObjectQueryParam;
if ( !canHitBall ) queryParam.AddIgnoredActor( GetWorld()->GetGameState<AProjectTapGameState>()->GetPlayer() );
auto pos = GetActorLocation();
auto rayStart = pos + dir * 5.0f;
auto laserVector = dir * length;
auto laserEmitter = laserParticle->EmitterInstances[0];
//ray cast to see if laser hits anything
GetWorld()->LineTraceSingleByObjectType(hit,rayStart, pos + laserVector, objectParam,queryParam);
auto hitActor = hit.Actor.Get();
if (hitActor != nullptr)
{
currHitPoint = hit.ImpactPoint;
if(!laserSparkParticle->bIsActive) laserSparkParticle->ActivateSystem();
//kills ball if laser hits it
auto ball = Cast<ABallPawn>(hitActor);
if (ball != nullptr)
{
ball->Kill();
laserEmitter->SetBeamTargetPoint(hit.ImpactPoint, 0);
KillSubLaser();
}
else
{
//if not set laser end point
laserEmitter->SetBeamTargetPoint(hit.ImpactPoint, 0);
bool typeFound = false;
//if hits deflective tile then spawn a new laser object
auto tile = Cast<ADeflectiveTile>(hitActor);
bool isFrame = false;
if (tile != nullptr)
{
typeFound = true;
TArray<USceneComponent*> Children;
tile->frameCollisionsComponent->GetChildrenComponents(true, Children);
for(int i = 0; i < Children.Num() && typeFound ; ++i)
{
// printonscreen(hit.Component.Get()->GetName());
// printonscreen(Children[i]->GetName());
if(hit.Component.Get() == Children[i])
{
typeFound = false;
isFrame = true;
}
}
//cut the laser length to make sure new sub laser start doesn't hit the same object
if (typeFound && CanSpawnSubLaser()) SpawnSubLaser(hit.ImpactPoint + hit.ImpactNormal * 10.0f, hit.ImpactNormal);
}
//if sub laser already exists then keep updating its rotation and position
auto subLaserExistsHitDeflectiveTile = currentDepth < MAX_DEPTH && nextLaser != nullptr && tile != nullptr;
if (subLaserExistsHitDeflectiveTile)
{
auto incomingVector = hit.ImpactPoint - GetActorLocation();
//if the incoming vector's angle is too small then kill sublasers to avoid laser flickering
auto dot = FVector::DotProduct(-incomingVector.GetSafeNormal(), hit.ImpactNormal);
auto angle = FMath::RadiansToDegrees(FMath::Acos(dot));
if (angle < 70.0f)
{
auto newDir = FMath::GetReflectionVector(incomingVector, hit.ImpactNormal);
auto start = hit.ImpactPoint + newDir * 2.0f;
nextLaser->SetActorLocation(hit.ImpactPoint);
nextLaser->dir = newDir.IsNormalized() ? newDir : newDir.GetSafeNormal();
nextLaser->laserParticle->EmitterInstances[0]->SetBeamSourcePoint(hit.ImpactPoint, 0);
nextLaser->laserParticle->EmitterInstances[0]->SetBeamTargetPoint(start + newDir * length, 0);
}
else
{
KillSubLaser();
}
}
//if the laser hits turret then kills it
if (!typeFound)
{
auto turret = Cast<ATurretPawn>(hitActor);
if (turret != nullptr)
{
typeFound = true;
turret->Damage(2.0f);
}
}
APortalTile* portal = nullptr;
if (!typeFound)
{
portal = Cast<APortalTile>(hitActor);
if (CanSpawnSubLaser() && portal != nullptr)
//.........这里部分代码省略.........
开发者ID:pokelege,项目名称:ProjectTap_Code,代码行数:101,代码来源:Laser.cpp
示例10: GetWorld
void ANUTActor::ServerClientStillAlive_Implementation()
{
LastAliveTime = GetWorld()->RealTimeSeconds;
}
开发者ID:frobro98,项目名称:UnrealSource,代码行数:4,代码来源:NUTActor.cpp
示例11: ServerAddItemOnSlot
void UGISInventoryBaseComponent::AddItemOnSlot(const FGISSlotInfo& TargetSlotType, const FGISSlotInfo& LastSlotType)
{
//Before we start swapping item, let's check if tags match!
if (GetOwnerRole() < ROLE_Authority)
{
ServerAddItemOnSlot(TargetSlotType, LastSlotType);
return;
}
//check if all data is valid.
if (!TargetSlotType.IsValid() || !LastSlotType.IsValid())
return;
//next check should be against item tags, but that's later!
if (LastSlotType.CurrentInventoryComponent->bRemoveItemsFromInvetoryOnDrag)
{
//Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotTabIndex].ItemData
if (TargetSlotType.GetItemData() == nullptr)
{
UGISItemData* TargetItem = LastSlotType.GetItemData();
UGISItemData* LastItem = TargetSlotType.GetItemData();
if (!CheckIfCanAddItemToSlot(TargetItem, TargetSlotType.SlotTabIndex, TargetSlotType.SlotIndex, LastItem))
return;
if (!TargetItem->HasAnyMatchingGameplayTags(TargetSlotType.GetTags()))
return;
if (TargetItem)
if (!TargetItem->CanItemBeSwapped())
return;
if (LastItem)
if (!LastItem->CanItemBeSwapped())
return;
TargetItem->AssignInventory(LastSlotType, TargetSlotType);
LastSlotType.DecrementItemCount();
TargetSlotType.IncrementItemCount();
TargetSlotType.SetItemData(TargetItem);
LastSlotType.SetItemData(nullptr);
if ((LastTargetTab != INDEX_NONE) && (LastOtherOriginTab != INDEX_NONE)
&& LastOtherOriginInventory)
{
LastOtherOriginInventory->CopyItemsFromOtherInventoryTab(this, LastOtherOriginTab, LastTargetTab);
}
TargetItem->SetWorld(GetWorld());
TargetItem->SetCurrentOwner(GetOwner());
OnItemAddedToSlot(TargetItem);
SlotSwapInfo.ReplicationCounter++;
SlotSwapInfo = FGISSlotSwapInfo(LastSlotType, LastItem, TargetSlotType, TargetItem);
if (GetNetMode() == ENetMode::NM_Standalone)
{
OnItemSlotSwapped.Broadcast(SlotSwapInfo);
LastSlotType.CurrentInventoryComponent->OnItemSlotSwapped.Broadcast(SlotSwapInfo);
}
//we will do it on server, to give chance for other
//componenets/actors to do something if item is removed/swapped in inventory.
if (GetNetMode() == ENetMode::NM_DedicatedServer)
{
OnItemSlotSwapped.Broadcast(SlotSwapInfo);
LastSlotType.CurrentInventoryComponent->OnItemSlotSwapped.Broadcast(SlotSwapInfo);
}
}
else
{
/*
Last copy item from last inventory, to be placed in Target inventory.
*/
UGISItemData* TargetItem = LastSlotType.GetItemData();
/*
Copy item from target inventory, to be placed in last inventory.
*/
UGISItemData* LastItem = TargetSlotType.GetItemData();
if (!CheckIfCanAddItemToSlot(TargetItem, TargetSlotType.SlotTabIndex, TargetSlotType.SlotIndex, LastItem))
return;
if (!TargetItem->HasAnyMatchingGameplayTags(TargetSlotType.GetTags()))
return;
if (!LastItem->HasAnyMatchingGameplayTags(LastSlotType.GetTags()))
return;
if (TargetItem)
if (!TargetItem->CanItemBeSwapped())
return;
if (LastItem)
if (!LastItem->CanItemBeSwapped())
return;
/*
Assign current inventory to current item.
*/
TargetItem->AssignInventory(LastSlotType, TargetSlotType);
//.........这里部分代码省略.........
开发者ID:Chooka,项目名称:ActionRPGGame,代码行数:101,代码来源:GISInventoryBaseComponent.cpp
示例12: CreateRagdollExperiment_0
void CreateRagdollExperiment_0(const dMatrix& location)
{
static dJointDefinition jointsDefinition[] =
{
{ "body" },
{ "leg", 100.0f,{ -15.0f, 15.0f, 30.0f },{ 0.0f, 0.0f, 180.0f }, dAnimationRagdollJoint::m_threeDof },
{ "foot", 100.0f,{ -15.0f, 15.0f, 30.0f },{ 0.0f, 90.0f, 0.0f }, dAnimationRagdollJoint::m_twoDof },
};
const int definitionCount = sizeof (jointsDefinition)/sizeof (jointsDefinition[0]);
NewtonWorld* const world = GetWorld();
DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(world);
DemoEntity* const modelEntity = DemoEntity::LoadNGD_mesh("selfbalance_01.ngd", GetWorld(), scene->GetShaderCache());
dMatrix matrix0(modelEntity->GetCurrentMatrix());
//matrix0.m_posit = location;
//modelEntity->ResetMatrix(*scene, matrix0);
scene->Append(modelEntity);
// add the root childBody
NewtonBody* const rootBody = CreateBodyPart(modelEntity);
// build the rag doll with rigid bodies connected by joints
dDynamicsRagdoll* const dynamicRagdoll = new dDynamicsRagdoll(rootBody, dGetIdentityMatrix());
AddModel(dynamicRagdoll);
dynamicRagdoll->SetCalculateLocalTransforms(true);
// save the controller as the collision user data, for collision culling
NewtonCollisionSetUserData(NewtonBodyGetCollision(rootBody), dynamicRagdoll);
int stackIndex = 0;
DemoEntity* childEntities[32];
dAnimationJoint* parentBones[32];
for (DemoEntity* child = modelEntity->GetChild(); child; child = child->GetSibling()) {
parentBones[stackIndex] = dynamicRagdoll;
childEntities[stackIndex] = child;
stackIndex++;
}
// walk model hierarchic adding all children designed as rigid body bones.
while (stackIndex) {
stackIndex--;
DemoEntity* const entity = childEntities[stackIndex];
dAnimationJoint* parentNode = parentBones[stackIndex];
const char* const name = entity->GetName().GetStr();
for (int i = 0; i < definitionCount; i++) {
if (!strcmp(jointsDefinition[i].m_boneName, name)) {
NewtonBody* const childBody = CreateBodyPart(entity);
// connect this body part to its parent with a rag doll joint
parentNode = CreateChildNode(childBody, parentNode, jointsDefinition[i]);
NewtonCollisionSetUserData(NewtonBodyGetCollision(childBody), parentNode);
break;
}
}
for (DemoEntity* child = entity->GetChild(); child; child = child->GetSibling()) {
parentBones[stackIndex] = parentNode;
childEntities[stackIndex] = child;
stackIndex++;
}
}
SetModelMass (100.0f, dynamicRagdoll);
// set the collision mask
// note this container work best with a material call back for setting bit field
//dAssert(0);
//controller->SetDefaultSelfCollisionMask();
// transform the entire contraction to its location
dMatrix worldMatrix(modelEntity->GetCurrentMatrix() * location);
worldMatrix.m_posit = location.m_posit;
NewtonBodySetMatrixRecursive(rootBody, &worldMatrix[0][0]);
// attach effectors here
for (dAnimationJoint* joint = GetFirstJoint(dynamicRagdoll); joint; joint = GetNextJoint(joint)) {
if (joint->GetAsRoot()) {
dAssert(dynamicRagdoll == joint);
dynamicRagdoll->SetHipEffector(joint);
} else if (joint->GetAsLeaf()) {
dynamicRagdoll->SetFootEffector(joint);
}
}
dynamicRagdoll->Finalize();
//return controller;
}
开发者ID:MADEAPPS,项目名称:newton-dynamics,代码行数:91,代码来源:DynamicRagdoll.cpp
示例13: check
ULocalPlayer* UGameInstance::CreateLocalPlayer(int32 ControllerId, FString& OutError, bool bSpawnActor)
{
check(GetEngine()->LocalPlayerClass != NULL);
ULocalPlayer* NewPlayer = NULL;
int32 InsertIndex = INDEX_NONE;
const int32 MaxSplitscreenPlayers = (GetGameViewportClient() != NULL) ? GetGameViewportClient()->MaxSplitscreenPlayers : 1;
if (FindLocalPlayerFromControllerId( ControllerId ) != NULL)
{
OutError = FString::Printf(TEXT("A local player already exists for controller ID %d,"), ControllerId);
}
else if (LocalPlayers.Num() < MaxSplitscreenPlayers)
{
// If the controller ID is not specified then find the first available
if (ControllerId < 0)
{
for (ControllerId = 0; ControllerId < MaxSplitscreenPlayers; ++ControllerId)
{
if (FindLocalPlayerFromControllerId( ControllerId ) == NULL)
{
break;
}
}
check(ControllerId < MaxSplitscreenPlayers);
}
else if (ControllerId >= MaxSplitscreenPlayers)
{
UE_LOG(LogPlayerManagement, Warning, TEXT("Controller ID (%d) is unlikely to map to any physical device, so this player will not receive input"), ControllerId);
}
NewPlayer = NewObject<ULocalPlayer>(GetEngine(), GetEngine()->LocalPlayerClass);
InsertIndex = AddLocalPlayer(NewPlayer, ControllerId);
if (bSpawnActor && InsertIndex != INDEX_NONE && GetWorld() != NULL)
{
if (GetWorld()->GetNetMode() != NM_Client)
{
// server; spawn a new PlayerController immediately
if (!NewPlayer->SpawnPlayActor("", OutError, GetWorld()))
{
RemoveLocalPlayer(NewPlayer);
NewPlayer = NULL;
}
}
else
{
// client; ask the server to let the new player join
NewPlayer->SendSplitJoin();
}
}
}
else
{
OutError = FString::Printf(TEXT( "Maximum number of players (%d) already created. Unable to create more."), MaxSplitscreenPlayers);
}
if (OutError != TEXT(""))
{
UE_LOG(LogPlayerManagement, Log, TEXT("UPlayer* creation failed with error: %s"), *OutError);
}
return NewPlayer;
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:64,代码来源:GameInstance.cpp
示例14: GetCharacterMovement
void AMMO_Character::BeginPlay()
{
Super::BeginPlay();
GetCharacterMovement()->MaxWalkSpeed = MovementSpeed;
Player_SkeletalMeshComponent = FindComponentByClass<class USkeletalMeshComponent>();
Player_SpringArmComponent = FindComponentByClass<class USpringArmComponent>();
Player_Widget = FindComponentByClass<class UWidgetComponent>();
CurrentHealth = MaxHealth;
OverheadUI = Cast<UMMO_OverheadUI_HUD>(Player_Widget->GetUserWidgetObject());
OverheadUI->CharName = CharacterName;
float TempPercetage = CurrentHealth / MaxHealth;
OverheadUI->HPBarValue = TempPercetage;
AnimInstance = Cast<UMMO_Char_AnimInstance>(Player_SkeletalMeshComponent->GetAnimInstance());
MyController = Cast<AMMO_Player_Controller>(GetController());
TArray<UCameraComponent*> Cameras;
GetComponents<UCameraComponent>(Cameras);
for (size_t i = 0; i < Cameras.Num(); i++)
{
if (Cameras[i]->ComponentHasTag("MainCam"))
{
MainCam = Cameras[i];
}
else
{
LockOnCam = Cameras[i];
}
}
if (!bIsWarrior)
{
TArray<UStaticMeshComponent*> StaticMeshes;
GetComponents<UStaticMeshComponent>(StaticMeshes);
for (size_t i = 0; i < StaticMeshes.Num(); i++)
{
if (StaticMeshes[i]->ComponentHasTag("HandArrow"))
{
HandArrow = StaticMeshes[i];
}
else if (StaticMeshes[i]->ComponentHasTag("ArrowShooterLoc"))
{
ShootingLocation = StaticMeshes[i];
}
else if (StaticMeshes[i]->ComponentHasTag("ShootTarget"))
{
ShootTarget = StaticMeshes[i];
}
}
}
//Get Reference to Other Character.
if (Role < ROLE_Authority)
{
for (TActorIterator<AMMO_Character> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
if (*ActorItr != this)
{
OtherCharacter = *ActorItr;
}
}
}
for (TActorIterator<AObjectPool> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
if (ActorItr->ActorHasTag("ObjectPooler"))
{
GlobalPool = *ActorItr;
}
}
}
开发者ID:DigitalDok,项目名称:MyPortfolioSnippets,代码行数:78,代码来源:MMO_Character.cpp
示例15: GetWorld
void AWorldSettings::NotifyMatchStarted()
{
UWorld* World = GetWorld();
World->bMatchStarted = true;
}
开发者ID:ErwinT6,项目名称:T6Engine,代码行数:5,代码来源:WorldSettings.cpp
示例16: AttemptToLockOn
void AMMO_Character::AttemptToLockOn()
{
if (bIsDead)return;
if (bMantineeHasControl)return;
// Part 1 of 2: Set / Unset LockOn Target
if (!LockedTarget)
{
TArray<AMMO_Mob_Character*> Enemies;
for (TActorIterator<AMMO_Mob_Character> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
if(!ActorItr->bIsDead)
Enemies.Add(*ActorItr);
}
int32 Index = -1;
float Distance = 100000000;
for (size_t i = 0; i < Enemies.Num(); i++)
{
if (FVector::Dist(GetActorLocation(), Enemies[i]->GetActorLocation()) <= PingAreaForLockOn)
{
if (FVector::Dist(GetActorLocation(), Enemies[i]->GetActorLocation()) < Distance)
{
if (!Enemies[i]->bIsDead && !Enemies[i]->MonsterAnimInstance->bHasDied )
{
Distance = FVector::Dist(GetActorLocation(), Enemies[i]->GetActorLocation());
Index = i;
}
}
}
}
if (Index != -1)
{
if (bIsInFocusMode)
{
bIsInFocusMode = false;
}
LockedTarget = Cast<AActor>(Enemies[Index]);
}
else
{
LockedTarget = nullptr;
}
}
else
{
Cast<AMMO_Mob_Character>(LockedTarget)->MyLockOnWidget->PlayersLockedOn[LockOnID]=-1;
LockedTarget = nullptr;
}
// Part 2 of 2: Activate and Deactivate as well as set some helper variables for Rotation of Actor and Camera.
if (LockedTarget)
{
LastKnownRotation = FRotator((LockedTarget->GetActorLocation() - LockOnCam->GetComponentLocation()).Rotation());
Cast<AMMO_Mob_Character>(LockedTarget)->MyLockOnWidget->PlayersLockedOn[LockOnID] = LockOnID;
SetActorRotation(LastKnownRotation);
Player_SkeletalMeshComponent->SetWorldRotation(LastKnownRotation);
LockOnCam->Activate();
MainCam->Deactivate();
LockOnCam->SetRelativeLocation(FVector(-300, 0, 120));
LockOnCam->SetRelativeRotation(FRotator(-22.5f, 0, 0));
}
else
{
GLog->Log(GetActorLabel());
LockOnCam->Deactivate();
MainCam->Activate();
}
}
开发者ID:DigitalDok,项目名称:MyPortfolioSnippets,代码行数:79,代码来源:MMO_Character.cpp
示例17: GetWorld
void UShardsMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
FHitResult HitResult;
FHitResult ShapeTraceResult;
FCollisionShape shape = FCollisionShape::MakeBox(FVector(0.72f*playerradius, 0.72f*playerradius,10.0f));
FCollisionQueryParams Params;
Params.bFindInitialOverlaps = true;
Params.AddIgnoredActor(UpdatedComponent->GetAttachmentRootActor());
// Telepads don't count.
for (TActorIterator<ATelePad> ActorItr(GetWorld()); ActorItr; ++ActorItr) {
Params.AddIgnoredActor(ActorItr.operator->());
}
// Neither do destructibles.
for (TActorIterator<ADestructibleBox> ActorItr(GetWorld()); ActorItr; ++ActorItr) {
// When they're broken, that is.
if (ActorItr->fadetimer >= 0.0f) {
Params.AddIgnoredActor(ActorItr.operator->());
}
}
if (isclimbing) {
return;
}
TArray<FHitResult> results;
if (forceregiondirection.Z == 0.0f) {
GetWorld()->SweepMultiByChannel(results, UpdatedComponent->GetComponentLocation() - 0.0f*45.0f*FVector::UpVector, UpdatedComponent->GetComponentLocation() - 1000.0f*FVector::UpVector, FQuat::Identity, ECC_Visibility, shape, Params); //100
for (FHitResult r : results) {
if (r.Normal.Z > 0.6f) {
ShapeTraceResult = r;
break;
}
}
if (!ShapeTraceResult.IsValidBlockingHit()) {
GetWorld()->LineTraceSingleByChannel(ShapeTraceResult, UpdatedComponent->GetComponentLocation(), UpdatedComponent->GetComponentLocation() - 1000.0f*FVector::UpVector, ECC_Visibility, Params);
}
}
FVector PlayerCapsuleBottom = UpdatedComponent->GetComponentLocation() - 45.0f * FVector::UpVector; // 50
float RequiredDistance = (onground ? 50.0f*grounddetecttfudgefactor : 10.0f)*FMath::Pow(playerhalfheight / 90.0f,4.0f) + playerhalfheight/2.0f; //50,1
DistanceFromImpact = (PlayerCapsuleBottom - ShapeTraceResult.ImpactPoint).Z;
overground = ShapeTraceResult.IsValidBlockingHit();
FHitResult groundhitresult;
GetWorld()->LineTraceSingleByChannel(groundhitresult, UpdatedComponent->GetComponentLocation(), UpdatedComponent->GetComponentLocation() - 10000.0f*FVector::UpVector, ECC_Visibility, Params);
groundtracehit = groundhitresult.ImpactPoint;
if (!onground) {
offGroundTime += DeltaTime;
}
toosteep = false;
if (enforcementtimer >= 0.0f) {
enforcementtimer += DeltaTime;
toosteep = true;
}
wasonground = onground;
onground = false;
prevgroundvelocity = groundvelocity;
groundvelocity = FVector::ZeroVector;
platformangularfrequency = 0.0f;
platformspindir = 1;
FloorNormal = FVector::ZeroVector;
if ((enforcementtimer < timerlimit && ShapeTraceResult.Normal.Z>0.6f) && DistanceFromImpact < RequiredDistance && !justjumped) { // (PlayerVelocity.Z <= 0.0f || wasonground)
if (ShapeTraceResult.Normal.Z < minnormalz) {
if (enforcementtimer == -1.0f) {
enforcementtimer = 0.0f;
}
} else {
enforcementtimer = -1.0f;
}
FVector pvel;
// Handle moving platforms.
if (ShapeTraceResult.GetActor() != nullptr && ShapeTraceResult.GetComponent() != nullptr && ShapeTraceResult.GetComponent()->IsA(UStaticMeshComponent::StaticClass())) {
// The motion of a point on a rigid body is the combination of its motion about the center of mass...
FVector angvel = FMath::DegreesToRadians((((UStaticMeshComponent*)ShapeTraceResult.GetComponent())->GetPhysicsAngularVelocity()));
FVector rr = GetActorLocation() - (((UStaticMeshComponent*)ShapeTraceResult.GetComponent())->GetComponentLocation());
FVector rvel = FVector::CrossProduct(angvel, rr);
// ...and the motion of the center of mass itself.
FVector cmvel = (((UStaticMeshComponent*)ShapeTraceResult.GetComponent())->GetPhysicsLinearVelocity());
groundvelocity = rvel + cmvel;
platformangularfrequency = -angvel.Z;
}
if ((PlayerVelocity.Z <= groundvelocity.Z || wasonground)) {
onground = true;
offGroundTime = 0.0f;
}
}
//.........这里部分代码省略.........
开发者ID:chris-hamer,项目名称:shards,代码行数:101,代码来源:ShardsMovementComponent.cpp
示例18: ApplyUprightConstraint
void UBuoyancyComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
if (!OceanManager || !UpdatedComponent || !UpdatedPrimitive) return;
if (!UpdatedComponent->IsSimulatingPhysics())
{
FVector waveHeight = OceanManager->GetWaveHeightValue(UpdatedComponent->GetComponentLocation());
UpdatedPrimitive->SetWorldLocation(FVector(UpdatedComponent->GetComponentLocation().X, UpdatedComponent->GetComponentLocation().Y, waveHeight.Z), true);
return;
}
//ApplyUprightConstraint is apparently needed again at first tick for BP-updated components.
//TODO: there has to be a better way than this(?), PostInitialize(?)
if (!_hasTicked)
{
_hasTicked = true;
ApplyUprightConstraint();
}
float TotalPoints = TestPoints.Num();
if (TotalPoints < 1) return;
int PointsUnderWater = 0;
for (int pointIndex = 0; pointIndex < TotalPoints; pointIndex++)
{
if (!TestPoints.IsValidIndex(pointIndex)) return; //Array size changed during runtime
bool isUnderwater = false;
FVector testPoint = TestPoints[pointIndex];
FVector worldTestPoint = UpdatedComponent->GetComponentTransform().TransformPosition(testPoint);
float waveHeight = OceanManager->GetWaveHeightValue(worldTestPoint).Z;
//If test point radius is touching water add buoyancy force
if (waveHeight > (worldTestPoint.Z + _SignedRadius))
{
PointsUnderWater++;
isUnderwater = true;
float DepthMultiplier = (waveHeight - (worldTestPoint.Z + _SignedRadius)) / (TestPointRadius * 2);
DepthMultiplier = FMath::Clamp(DepthMultiplier, 0.f, 1.f);
//If we have a point density override, use the overriden value insted of MeshDensity
float PointDensity = PointDensityOverride.IsValidIndex(pointIndex) ? PointDensityOverride[pointIndex] : MeshDensity;
/**
* --------
* Buoyancy force formula: (Volume(Mass / Density) * Fluid Density * -Gravity) / Total Points * Depth Multiplier
* --------
*/
float BuoyancyForceZ = UpdatedPrimitive->GetMass() / PointDensity * FluidDensity * -GetGravityZ() / TotalPoints * DepthMultiplier;
//Experimental velocity damping using GetUnrealWorldVelocityAtPoint!
FVector DampingForce = -GetVelocityAtPoint(UpdatedPrimitive, worldTestPoint) * VelocityDamper * UpdatedPrimitive->GetMass() * DepthMultiplier;
//Wave push force
if (EnableWaveForces)
{
float waveVelocity = FMath::Clamp(GetVelocityAtPoint(UpdatedPrimitive, worldTestPoint).Z, -20.f, 150.f) * (1 - DepthMultiplier);
DampingForce += FVector(OceanManager->GlobalWaveDirection.X, OceanManager->GlobalWaveDirection.Y, 0) * UpdatedPrimitive->GetMass() * waveVelocity * WaveForceMultiplier / TotalPoints;
}
//Add force for this test point
UpdatedPrimitive->AddForceAtLocation(FVector(DampingForce.X, DampingForce.Y, DampingForce.Z + BuoyancyForceZ), worldTestPoint);
}
if (DrawDebugPoints)
{
FColor DebugColor = FLinearColor(0.8, 0.7, 0.2, 0.8).ToRGBE();
if (isUnderwater) { DebugColor = FLinearColor(0, 0.2, 0.7, 0.8).ToRGBE(); } //Blue color underwater, yellow out of watter
DrawDebugSphere(GetWorld(), worldTestPoint, TestPointRadius, 8, DebugColor);
}
}
//Clamp the velocity to MaxUnderwaterVelocity if there is any point underwater
if (ClampMaxVelocity && PointsUnderWater > 0
&& UpdatedPrimitive->GetPhysicsLinearVelocity().Size() > MaxUnderwaterVelocity)
{
FVector Velocity = UpdatedPrimitive->GetPhysicsLinearVelocity().GetSafeNormal() * MaxUnderwaterVelocity;
UpdatedPrimitive->SetPhysicsLinearVelocity(Velocity);
}
//Update damping based on number of underwater test points
UpdatedPrimitive->SetLinearDamping(_baseLinearDamping + FluidLinearDamping / TotalPoints * PointsUnderWater);
UpdatedPrimitive->SetAngularDamping(_baseAngularDamping + FluidAngularDamping / TotalPoints
|
请发表评论