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


C++ GetRootComponent函数代码示例

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


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

示例1:

// Sets default values
AZombieCharacter::AZombieCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	//Initializing stats and components.

	AudioComponent = CreateDefaultSubobject<UAudioComponent>(FName("Audio"));
	AudioComponent->AttachTo(GetRootComponent());


	ParticleSystemComponent = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("ParticleComp"));
	ParticleSystemComponent->bAutoActivate = false;

	ParticleSystemComponent->AttachTo(GetRootComponent());
	

	//Combat stats
	MinHealth = 100.f;
	MaxHealth = 300.f;

	MinSpeed = 150.f;
	MaxSpeed = 250.f;

	MinDamage = 5.f;
	MaxDamage = 15.f;

	DotTickInSeconds = 1.f;
	SlowPercentage = 0.5f;
	SlowEffectDuration = 3.f;
	Damage = 15.f;

	MeleeDistanceThreshold = 150.f;
}
开发者ID:AbDoMoHaMmEd,项目名称:PortfolioSnippets,代码行数:35,代码来源:ZombieCharacter.cpp

示例2: GetRootComponent

void ANimModCharacter::UpdateRunSounds(bool bNewRunning)
{
	if (bNewRunning)
	{
		if (!RunLoopAC && RunLoopSound)
		{
			RunLoopAC = UGameplayStatics::PlaySoundAttached(RunLoopSound, GetRootComponent());
			if (RunLoopAC)
			{
				RunLoopAC->bAutoDestroy = false;
			}

		}
		else if (RunLoopAC)
		{
			RunLoopAC->Play();
		}
	}
	else
	{
		if (RunLoopAC)
		{
			RunLoopAC->Stop();
		}

		if (RunStopSound)
		{
			UGameplayStatics::PlaySoundAttached(RunStopSound, GetRootComponent());
		}
	}
}
开发者ID:Nimgoble,项目名称:NimMod,代码行数:31,代码来源:NimModCharacter.cpp

示例3: GetRootComponent

void AActor::EditorApplyScale( const FVector& DeltaScale, const FVector* PivotLocation, bool bAltDown, bool bShiftDown, bool bCtrlDown )
{
	if( RootComponent != NULL )
	{
		const FVector CurrentScale = GetRootComponent()->RelativeScale3D;

		// @todo: Remove this hack once we have decided on the scaling method to use.
		if( AActor::bUsePercentageBasedScaling )
		{
			GetRootComponent()->SetRelativeScale3D(CurrentScale + DeltaScale * CurrentScale);

			if (PivotLocation)
			{
				FVector Loc = GetActorLocation();
				Loc -= *PivotLocation;
				Loc += DeltaScale * Loc;
				Loc += *PivotLocation;
				GetRootComponent()->SetWorldLocation(Loc);
			}
		}
		else
		{
			GetRootComponent()->SetRelativeScale3D(CurrentScale + DeltaScale * CurrentScale.GetSignVector());
		}
	}
	else
	{
		UE_LOG(LogActor, Warning, TEXT("WARNING: EditorApplyTranslation %s has no root component"), *GetName() );
	}

	FEditorSupportDelegates::UpdateUI.Broadcast();
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:32,代码来源:ActorEditor.cpp

示例4: GetRandomSpawnLocation

void ABxtAsteroidSpawner::SpawnAsteroid()
{
	FActorSpawnParameters spawnParams;
	spawnParams.Owner = this;
	spawnParams.bDeferConstruction = true;

	const FVector spawnLocation = GetRandomSpawnLocation();
	const FRotator spawnRotation = FRotator::ZeroRotator;

	auto asteroid = GetWorld()->SpawnActor<ABxtAsteroid>(
		AsteroidClass, spawnLocation, spawnRotation, spawnParams
	);

	if (asteroid)
	{
		asteroid->SetInitialSpeed(AsteroidSpeed);
		asteroid->SetDirection(GetRandomSpawnDirection());

		// preserve original root component scale
		const FVector spawnScale = 
			GetRootComponent() ? GetRootComponent()->RelativeScale3D : FVector(1.0f, 1.0f, 1.0f);

		asteroid->FinishSpawning(FTransform(spawnRotation, spawnLocation, spawnScale), true);
	}
}
开发者ID:enlight,项目名称:boxteroids,代码行数:25,代码来源:BxtAsteroidSpawner.cpp

示例5: MeshFinder

AStick::AStick(){
  RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
  Stick = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("OurVisibleComponent"));
  Stick->SetMobility(EComponentMobility::Movable);
  Stick->CastShadow = false;
  Stick->AttachTo(RootComponent);
  UStaticMesh *mesh = nullptr;
  static ConstructorHelpers::FObjectFinder<UStaticMesh> MeshFinder(TEXT("StaticMesh'/Game/Models/Baculo/baculo_model.baculo_model'"));
  if (MeshFinder.Succeeded()){
    mesh = MeshFinder.Object;
    Stick->SetStaticMesh(mesh);
  }
  Stick->SetWorldScale3D(FVector(0.75, 0.75, 0.75));
  StickMaterial = ((UPrimitiveComponent*)GetRootComponent())->CreateAndSetMaterialInstanceDynamic(0);
  UMaterial* mat = nullptr;
  static ConstructorHelpers::FObjectFinder<UMaterial> MatFinder(TEXT("Material'/Game/Models/Baculo/baculo_diffuse.baculo_diffuse'"));
  if (MatFinder.Succeeded()){
    mat = MatFinder.Object;
    StickMaterial = UMaterialInstanceDynamic::Create(mat, GetWorld());
  }

  EffectsMaterial = ((UPrimitiveComponent*)GetRootComponent())->CreateAndSetMaterialInstanceDynamic(1);
  mat = nullptr;
  static ConstructorHelpers::FObjectFinder<UMaterial> MatFinderEffects(TEXT("Material'/Game/Models/Baculo/baculoBloom_material.baculoBloom_material'"));
  if (MatFinderEffects.Succeeded()){
    mat = MatFinderEffects.Object;
    EffectsMaterial = UMaterialInstanceDynamic::Create(mat, GetWorld());
  }

  BBMaterial = CreateDefaultSubobject<UMaterialBillboardComponent>(TEXT("BB"));
  BBMaterial->AttachTo(RootComponent);
  BBMaterial->SetMobility(EComponentMobility::Movable);
  BBMaterial->CastShadow = false;
  BBMaterial->SetRelativeLocation(FVector(0, 0, 70));
}
开发者ID:alfreSosa,项目名称:PC-TowardsTheLight,代码行数:35,代码来源:Stick.cpp

示例6: SetRootComponent

// Sets default values
ASmokePawn::ASmokePawn()
{
	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	AIControllerClass = ASmokeAIController::StaticClass();
	collision = CreateDefaultSubobject<USphereComponent>(TEXT("SmokeCollision"));
	SetRootComponent(collision);
	collision->SetSimulatePhysics(true);
	collision->SetEnableGravity(false);
	collision->SetCollisionProfileName(FName("Pawn"));
	collision->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
	smokeParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("SmokeParticle"));
	smokeParticleSystem->AttachTo(GetRootComponent());

	ConstructorHelpers::FObjectFinder<UParticleSystem> particleAsset(TEXT("/Game/Particles/P_Smoke_AI"));
	smokeParticleSystem->SetTemplate(particleAsset.Object);

	movement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("SmokeMovement"));
	movement->SetUpdatedComponent(GetRootComponent());
	movement->MaxSpeed = 100.0f;
	movement->Acceleration = 100.0f;
	movement->Deceleration = 0.0;
	ConstructorHelpers::FObjectFinder<UBehaviorTree> behaviorAsset(TEXT("/Game/AI/SmokeBrain"));
	behavior = behaviorAsset.Object;
}
开发者ID:pokelege,项目名称:ProjectTap_Code,代码行数:26,代码来源:SmokePawn.cpp

示例7: TempRot

void AActor::EditorApplyMirror(const FVector& MirrorScale, const FVector& PivotLocation)
{
	const FRotationMatrix TempRot( GetActorRotation() );
	const FVector New0( TempRot.GetScaledAxis( EAxis::X ) * MirrorScale );
	const FVector New1( TempRot.GetScaledAxis( EAxis::Y ) * MirrorScale );
	const FVector New2( TempRot.GetScaledAxis( EAxis::Z ) * MirrorScale );
	// Revert the handedness of the rotation, but make up for it in the scaling.
	// Arbitrarily choose the X axis to remain fixed.
	const FMatrix NewRot( -New0, New1, New2, FVector::ZeroVector );

	if( RootComponent != NULL )
	{
		GetRootComponent()->SetRelativeRotation( NewRot.Rotator() );
		FVector Loc = GetActorLocation();
		Loc -= PivotLocation;
		Loc *= MirrorScale;
		Loc += PivotLocation;
		GetRootComponent()->SetRelativeLocation( Loc );

		FVector Scale3D = GetRootComponent()->RelativeScale3D;
		Scale3D.X = -Scale3D.X;
		GetRootComponent()->SetRelativeScale3D(Scale3D);
	}
	else
	{
		UE_LOG(LogActor, Warning, TEXT("WARNING: EditorApplyMirror %s has no root component"), *GetName() );
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:28,代码来源:ActorEditor.cpp

示例8: FMessageLog

/**
 * Function that gets called from within Map_Check to allow this actor to check itself
 * for any potential errors and register them with map check dialog.
 */
void AVolume::CheckForErrors()
{
	Super::CheckForErrors();

	// The default physics volume can have zero area; it's extents aren't used, only the physics properties
	if (IsA(ADefaultPhysicsVolume::StaticClass()))
	{
		return;
	}

	if (GetRootComponent() == NULL)
	{
		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
		FMessageLog("MapCheck").Warning()
			->AddToken(FUObjectToken::Create(this))
			->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_VolumeActorCollisionComponentNULL", "{ActorName} : Volume actor has NULL collision component - please delete" ), Arguments) ))
			->AddToken(FMapErrorToken::Create(FMapErrors::VolumeActorCollisionComponentNULL));
	}
	else
	{
		if (GetRootComponent()->Bounds.SphereRadius <= SMALL_NUMBER)
		{
			FFormatNamedArguments Arguments;
			Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
			FMessageLog("MapCheck").Warning()
				->AddToken(FUObjectToken::Create(this))
				->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_VolumeActorZeroRadius", "{ActorName} : Volume actor has a collision component with 0 radius - please delete" ), Arguments) ));
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:35,代码来源:ErrorChecking.cpp

示例9: FMessageLog

void AActor::CheckForErrors()
{
	if ( GetClass()->HasAnyClassFlags(CLASS_Deprecated) )
	{
		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
		FMessageLog("MapCheck").Warning()
			->AddToken(FUObjectToken::Create(this))
			->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_ActorIsObselete_Deprecated", "{ActorName} : Obsolete and must be removed! (Class is deprecated)" ), Arguments) ))
			->AddToken(FMapErrorToken::Create(FMapErrors::ActorIsObselete));
		return;
	}
	if ( GetClass()->HasAnyClassFlags(CLASS_Abstract) )
	{
		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
		FMessageLog("MapCheck").Warning()
			->AddToken(FUObjectToken::Create(this))
			->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_ActorIsObselete_Abstract", "{ActorName} : Obsolete and must be removed! (Class is abstract)" ), Arguments) ))
			->AddToken(FMapErrorToken::Create(FMapErrors::ActorIsObselete));
		return;
	}

	UPrimitiveComponent* PrimComp = Cast<UPrimitiveComponent>(RootComponent);
	if( PrimComp && (PrimComp->Mobility != EComponentMobility::Movable) && PrimComp->BodyInstance.bSimulatePhysics)
	{
		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
		FMessageLog("MapCheck").Warning()
			->AddToken(FUObjectToken::Create(this))
			->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_StaticPhysNone", "{ActorName} : Static object with bSimulatePhysics set to true" ), Arguments) ))
			->AddToken(FMapErrorToken::Create(FMapErrors::StaticPhysNone));
	}

	if( RootComponent && FMath::IsNearlyZero( GetRootComponent()->RelativeScale3D.X * GetRootComponent()->RelativeScale3D.Y * GetRootComponent()->RelativeScale3D.Z ) )
	{
		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
		FMessageLog("MapCheck").Error()
			->AddToken(FUObjectToken::Create(this))
			->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_InvalidDrawscale", "{ActorName} : Invalid DrawScale/DrawScale3D" ), Arguments) ))
			->AddToken(FMapErrorToken::Create(FMapErrors::InvalidDrawscale));
	}

	// Route error checking to components.
	TInlineComponentArray<UActorComponent*> Components;
	GetComponents(Components);

	for ( int32 ComponentIndex = 0 ; ComponentIndex < Components.Num() ; ++ComponentIndex )
	{
		UActorComponent* ActorComponent = Components[ ComponentIndex ];
		if (ActorComponent->IsRegistered())
		{
			ActorComponent->CheckForErrors();
		}
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:57,代码来源:ActorEditor.cpp

示例10: GetRootComponent

FVector APawn::GetVelocity() const
{
	if(GetRootComponent() && GetRootComponent()->IsSimulatingPhysics())
	{
		return GetRootComponent()->GetComponentVelocity();
	}

	const UPawnMovementComponent* MovementComponent = GetMovementComponent();
	return MovementComponent ? MovementComponent->Velocity : FVector::ZeroVector;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:10,代码来源:Pawn.cpp

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

示例12:

// Sets default values
AAICharacter::AAICharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	BoxComp = CreateDefaultSubobject<UBoxComponent>(FName("BoxComp"));
	BoxComp->AttachTo(GetRootComponent());

	AudioComp = CreateDefaultSubobject<UAudioComponent>(FName("AudioComp"));
	AudioComp->AttachTo(GetRootComponent());

}
开发者ID:TW18-GY,项目名称:UE4-Game-Systems,代码行数:13,代码来源:AICharacter.cpp

示例13: GetMovementComponent

class APhysicsVolume* APawn::GetPawnPhysicsVolume() const
{
	const UPawnMovementComponent* MovementComponent = GetMovementComponent();
	if (MovementComponent)
	{
		return MovementComponent->GetPhysicsVolume();
	}
	else if (GetRootComponent())
	{
		return GetRootComponent()->GetPhysicsVolume();
	}
	return GetWorld()->GetDefaultPhysicsVolume();
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:13,代码来源:Pawn.cpp

示例14: GetCombinedScale

void ALeapMotionHandActor::UpdateBones(float DeltaSeconds)
{
	if (BoneActors.Num() == 0) { return; }

	float CombinedScale = GetCombinedScale();

	FLeapMotionDevice* Device = FLeapMotionControllerPlugin::GetLeapDeviceSafe();
	if (Device && Device->IsConnected())
	{
		int BoneArrayIndex = 0;
		for (ELeapBone LeapBone = bShowArm ? ELeapBone::Forearm : ELeapBone::Palm; LeapBone <= ELeapBone::Finger4Tip; ((int8&)LeapBone)++)
		{
			FVector TargetPosition;
			FRotator TargetOrientation;

			bool Success = Device->GetBonePostionAndOrientation(HandId, LeapBone, TargetPosition, TargetOrientation);

			if (Success)
			{
				// Offset target position & rotation by the SpawnReference actor's transform
				FQuat RefQuat = GetRootComponent()->GetComponentRotation().Quaternion();
				TargetPosition = RefQuat * TargetPosition * CombinedScale + GetRootComponent()->GetComponentLocation();
				TargetOrientation = (RefQuat * TargetOrientation.Quaternion()).Rotator();

				// Get current position & rotation
				ALeapMotionBoneActor* BoneActor = BoneActors[BoneArrayIndex++];

				UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(BoneActor->GetRootComponent());
				if (PrimitiveComponent && PrimitiveComponent->IsSimulatingPhysics())
				{
					FVector CurrentPositon = PrimitiveComponent->GetComponentLocation();
					FRotator CurrentRotation = PrimitiveComponent->GetComponentRotation();

					// Compute linear velocity
					FVector LinearVelocity = (TargetPosition - CurrentPositon) / DeltaSeconds;

					// Compute angular velocity
					FVector Axis;
					float Angle;
					ConvertDeltaRotationsToAxisAngle(CurrentRotation, TargetOrientation, Axis, Angle);
					if (Angle > PI) { Angle -= 2 * PI; }
					FVector AngularVelcity = Axis * (Angle / DeltaSeconds);

					// Apply velocities
					PrimitiveComponent->SetPhysicsLinearVelocity(LinearVelocity);
					PrimitiveComponent->SetAllPhysicsAngularVelocity(AngularVelcity * 180.0f / PI);
				}
			}
		}
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:51,代码来源:LeapMotionHandActor.cpp

示例15: Super

// Sets default values
ASCharacter::ASCharacter(const class FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	UCharacterMovementComponent* MoveComp = GetCharacterMovement();
	// Adjust jump to make it less floaty
	MoveComp->GravityScale = 1.5f;
	MoveComp->JumpZVelocity = 620;
	MoveComp->bCanWalkOffLedgesWhenCrouching = true;
	MoveComp->MaxWalkSpeedCrouched = 200;

	/* Ignore this channel or it will absorb the trace impacts instead of the skeletal mesh */
	GetCapsuleComponent()->SetCollisionResponseToChannel(COLLISION_WEAPON, ECR_Ignore);

	// Enable crouching
	MoveComp->GetNavAgentPropertiesRef().bCanCrouch = true;

	CameraBoomComp = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
	CameraBoomComp->SocketOffset = FVector(0, 35, 0);
	CameraBoomComp->TargetOffset = FVector(0, 0, 55);
	CameraBoomComp->bUsePawnControlRotation = true;
	CameraBoomComp->AttachParent = GetRootComponent();

	CameraComp = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("Camera"));
	CameraComp->AttachParent = CameraBoomComp;

	CarriedObjectComp = ObjectInitializer.CreateDefaultSubobject<USCarryObjectComponent>(this, TEXT("CarriedObjectComp"));
	CarriedObjectComp->AttachParent = GetRootComponent();

	MaxUseDistance = 500;
	DropWeaponMaxDistance = 100;
	bHasNewFocus = true;
	TargetingSpeedModifier = 0.5f;
	SprintingSpeedModifier = 2.5f;

	Health = 100;

	IncrementHungerAmount = 5.0f;
	IncrementHungerInterval = 5.0f;
	CriticalHungerThreshold = 90;
	HungerDamagePerInterval = 1.0f;
	MaxHunger = 100;
	Hunger = 0;

	/* Names as specified in the character skeleton */
	WeaponAttachPoint = TEXT("WeaponSocket");
	PelvisAttachPoint = TEXT("PelvisSocket");
	SpineAttachPoint = TEXT("SpineSocket");
}
开发者ID:Raynaron,项目名称:EpicSurvivalGameSeries,代码行数:52,代码来源:SCharacter.cpp


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