// Sets default values AHairSegment::AHairSegment() { PrimaryActorTick.bCanEverTick = false; ProceduralMeshData = NewObject<UProceduralMeshData>(); ProceduralMesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("GeneratedMesh")); RootComponent = ProceduralMesh; ProceduralMesh->SetCollisionProfileName(TEXT("OverlapAll")); OutlineMesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("OutlineMesh")); static ConstructorHelpers::FObjectFinder<UMaterialInterface> BasicMat(TEXT("MaterialInterface'/Game/Materials/M_Basic.M_Basic'")); if (BasicMat.Succeeded()) OutlineMesh->SetMaterial(0, BasicMat.Object); OutlineMesh->SetRenderInMainPass(false); OutlineMesh->SetCastShadow(false); Spline = CreateDefaultSubobject<USplineComponent>(TEXT("Spline")); Spline->SetupAttachment(RootComponent); Spline->ClearSplinePoints(); static ConstructorHelpers::FObjectFinder<UMaterialInterface> TmpMat(TEXT("MaterialInterface'/Game/Materials/M_Test.M_Test'")); if (TmpMat.Succeeded()) Material = TmpMat.Object; if (Material) SetSegmentMaterial(0, Material); }
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)); }
// Sets default values AProjectile::AProjectile() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; CollisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("Collision_Component")); CollisionComp->SetSphereRadius(5.0f); CollisionComp->AttachTo(RootComponent); CollisionComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); CollisionComp->SetCollisionObjectType(ECollisionChannel::ECC_WorldDynamic); SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Sphere_Mesh")); SphereVisual->AttachTo(CollisionComp); static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { SphereVisual->SetStaticMesh(SphereVisualAsset.Object); SphereVisual->SetRelativeLocation(FVector(-7.0f, 0.0f, 0.0f)); SphereVisual->SetWorldScale3D(FVector(0.2f, 0.04f, 0.02f)); SphereVisual->SetCollisionEnabled(ECollisionEnabled::NoCollision); static ConstructorHelpers::FObjectFinder<UMaterial> MaterialAsset(TEXT("/Game/Materials/BulletMat")); if (MaterialAsset.Succeeded()) { SphereVisual->SetMaterial(0, MaterialAsset.Object); } UProjectileMovementComponent* ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile_Movement")); ProjectileMovement->InitialSpeed = 2000.0f; ProjectileMovement->ProjectileGravityScale = 0.0f; } }
// Sets default values AExplodeRay::AExplodeRay() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; // Find assets static ConstructorHelpers::FObjectFinder<UStaticMesh> ofMesh(TEXT("StaticMesh'/Game/StaticMeshes/Shape_Cube.Shape_Cube'")); static ConstructorHelpers::FObjectFinder<UMaterial> ofMat(TEXT("Material'/Game/Materials/M_Ray.M_Ray'")); m_pMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh")); m_pMesh->SetCollisionProfileName(TEXT("NoCollision")); if (ofMesh.Succeeded() && ofMat.Succeeded()) { m_pMesh->SetStaticMesh(ofMesh.Object); m_pMesh->SetRelativeLocation(FVector(0.0f, 0.0f, -50.0f)); m_pParentMat = ofMat.Object; } m_pBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Box")); m_pBox->InitBoxExtent(FVector(50.0f, 50.0f, 50.0f)); m_pBox->SetCollisionProfileName(TEXT("OverlapAll")); m_pBox->SetCollisionResponseToChannel(ECollisionChannel::ECC_GameTraceChannel1, ECollisionResponse::ECR_Ignore); RootComponent = m_pBox; m_pMesh->AttachTo(RootComponent); m_fTime = EXPLODE_RAY_LIFETIME; }
// Sets default values ARifle::ARifle() { // Max ammo in one clip ClipSize = 30; // Ammo per clip/magazine AmmoCount = ClipSize; // Rounds per second SetRPS(10.0f); // Range of rifle SetRange(2000.0f); // Damage values SetPlayerDamage(0.5f); SetEnemyDamage(20.0f); static ConstructorHelpers::FObjectFinder<USkeletalMesh> GunAsset(TEXT("/Game/FPWeapon/Mesh/SK_FPGun.SK_FPGun")); if (GunAsset.Succeeded()) { static ConstructorHelpers::FObjectFinder<UMaterial> MaterialAsset(TEXT("/Game/FPWeapon/Materials/M_FPGun")); if (MaterialAsset.Succeeded()) { SetupWeaponMesh(GunAsset.Object, MaterialAsset.Object, FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, -90.0f, 0.0f)); } SetupArrowComp(FVector(0.0f, 50.0f, 11.0f), FRotator(0.0f, 90.0f, 0.0f)); } }
// Sets default values ACollidingPawn::ACollidingPawn() { // 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; // Tutorial code // Our root component will be a sphere that reats to Physics USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent")); RootComponent = SphereComponent; SphereComponent->InitSphereRadius(40.0f); SphereComponent->SetCollisionProfileName(TEXT("Pawn")); // Creating and correctly Positioning the Mesh component so that it fits the sphere collision UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation")); SphereVisual->AttachTo(RootComponent); static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { SphereVisual->SetStaticMesh(SphereVisualAsset.Object); SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f,-40.0f)); SphereVisual->SetWorldScale3D(FVector(0.8f)); } // Particle system Creation, Positioning (Offset) OurParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MovementParticles")); OurParticleSystem->AttachTo(SphereVisual); OurParticleSystem->bAutoActivate = false; OurParticleSystem->SetRelativeLocation(FVector(-20.0f,0.0f,0.0f)); static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleAsset(TEXT("/Game/StarterContent/Particles/P_Fire.P_Fire")); if (ParticleAsset.Succeeded()) { OurParticleSystem->SetTemplate(ParticleAsset.Object); } // SpringArm creation for a smooth and fast Camera Experience ( We could have just avoided this springArm ) but for the sake of smoothness USpringArmComponent* SpringArm = CreateAbstractDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm")); SpringArm->AttachTo(RootComponent); SpringArm->RelativeRotation = FRotator(-45.0f,0.0f,0.0f); SpringArm->TargetArmLength = 400.0f; SpringArm->bEnableCameraLag = true; SpringArm->CameraLagSpeed = 3.0f; // Easy to create the Camera component and attach it to the built in Socket at the end of springArm UCameraComponent* ActualCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera")); ActualCamera->AttachTo(SpringArm, USpringArmComponent::SocketName); // Take control of the default player AutoPossessPlayer = EAutoReceiveInput::Player0; // creating an instance of our movement component, and telling it to update the root. OurMovementComponent = CreateDefaultSubobject<UCollidingPawnMovementComponent>(TEXT("CustomMovementComponent")); OurMovementComponent->UpdatedComponent = RootComponent; }
// Sets default values ASkateboardPawn::ASkateboardPawn() { // 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; // Makes the first player take control of this pawn automatically AutoPossessPlayer = EAutoReceiveInput::Player0; // Create a dummy root component we can attach things to RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent")); // Create a camera and a visible object UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent")); Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent")); static ConstructorHelpers::FObjectFinder<UStaticMesh>CubeVisualAsset(TEXT("/Game/skateboard")); if (CubeVisualAsset.Succeeded()) { Mesh->SetStaticMesh(CubeVisualAsset.Object); Mesh->SetSimulatePhysics(true); //Mesh->SetMassOverrideInKg("", 100); } // Attach our camera and visible object to our root component. Offset and rotate the camera. Camera->AttachTo(Mesh); Camera->SetRelativeLocation(FVector(-450.0f, 0.0f, 450.0f)); Camera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f)); Camera->SetWorldScale3D(FVector(1, 1, 1)); Mesh->AttachTo(RootComponent); }
// Sets default values AMotherActor::AMotherActor() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; UBoxComponent* Box = CreateDefaultSubobject<UBoxComponent>(TEXT("RootComponent")); RootComponent = Box; Box->InitBoxExtent(FVector(20.0f, 20.0f, 20.0f)); UBoxComponent* Box1 = CreateDefaultSubobject<UBoxComponent>(TEXT("Box")); Box1->InitBoxExtent(FVector(60.0f, 60.0f, 60.0f)); Box1->RelativeLocation = FVector(100.0f, 0.0f, 0.0f); USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere")); SphereComponent->InitSphereRadius(60.0f); SphereComponent->RelativeLocation = FVector(100.0f, 0.0f, 0.0f); UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation")); static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { SphereVisual->SetStaticMesh(SphereVisualAsset.Object); SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -100.0f)); SphereVisual->SetWorldScale3D(FVector(0.8f)); } Box1->AttachTo(RootComponent); SphereVisual->AttachTo(RootComponent); SphereComponent->AttachTo(RootComponent); UChildActorComponent * ChildActor = CreateDefaultSubobject<UChildActorComponent>(TEXT("InventoryCamera")); ChildActor->SetChildActorClass(AOrbitalActor::StaticClass()); ChildActor->CreateChildActor(); FVector position = GetActorLocation(); ChildActor->SetRelativeTransform(FTransform(position)); }
// Sets default values AHeatmapDataCollector::AHeatmapDataCollector(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) { PrimaryActorTick.bCanEverTick = true; FString StringOfCoords = ""; it = 0; Billboard = ObjectInitializer.CreateDefaultSubobject<UBillboardComponent>(this, TEXT("Billboard")); RootComponent = Billboard; static ConstructorHelpers::FObjectFinder<UTexture2D> Spalsh(TEXT("Texture2D'/Engine/EditorResources/S_NavP.S_NavP'")); if (Spalsh.Succeeded()) { Billboard->SetSprite(Spalsh.Object); } TextComponent = ObjectInitializer.CreateDefaultSubobject<UTextRenderComponent>(this, TEXT("TextComponent")); TextComponent->AttachTo(RootComponent); TextComponent->WorldSize = 92; TextComponent->bHiddenInGame = false; PathSpline = ObjectInitializer.CreateDefaultSubobject<USplineComponent>(this, TEXT("PathSplineComponent")); BeamParticle = ObjectInitializer.CreateDefaultSubobject<UParticleSystem>(this, TEXT("beamParticle")); //BeamParticle->bAutoDeactivate = false; }
AParticle::AParticle() : m_bobHeight( 50.f ), m_sphereRadius(0.009f), m_lightIntensity(50.f) { // Must turn on for floating animation PrimaryActorTick.bCanEverTick = false; // Set visual sphere as the root component SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("RootComponent")); RootComponent = SphereVisual; // NOTE - Shape_Sphere.uasset must be located in the following directory at compile time (will be automatically created for projects with starter content) static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); // Otherwise, the Shape_Sphere.uasset file must be physically located in the project's "Content" folder at compile time for it to show up //static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { SphereVisual->SetStaticMesh(SphereVisualAsset.Object); SphereVisual->SetWorldScale3D(FVector(m_sphereRadius)); } // Create and attach point light PointLight1 = CreateDefaultSubobject<UPointLightComponent>(TEXT("PointLight1")); PointLight1->Intensity = m_lightIntensity; PointLight1->bVisible = true; PointLight1->SetupAttachment(SphereVisual); }
VehiclePawnWrapper::VehiclePawnWrapper() { static ConstructorHelpers::FObjectFinder<UParticleSystem> collision_display(TEXT("ParticleSystem'/AirSim/StarterContent/Particles/P_Explosion.P_Explosion'")); if (!collision_display.Succeeded()) collision_display_template = collision_display.Object; else collision_display_template = nullptr; }
UChannelledAbility::UChannelledAbility() : Super() { partclSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("ChannelLineParticleSystem")); static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleSystemClass(TEXT("/Game/TopDown/Particle_Effects/AoE")); if (ParticleSystemClass.Succeeded()) { partclSystem->Template = ParticleSystemClass.Object; partclSystem->bAutoActivate = false; } }
UParametricSurfaceComponent::UParametricSurfaceComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) , MaterialInterface(nullptr) { static ConstructorHelpers::FObjectFinder<UMaterialInterface> MI(TEXT("MaterialInstanceConstant'/Game/Materials/M_Simple_Inst.M_Simple_Inst'")); if (MI.Succeeded()) { MaterialInterface = MI.Object; } }
APickupRocketLauncher::APickupRocketLauncher(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { if (nullptr != StaticMeshComp) { static ConstructorHelpers::FObjectFinder<UStaticMesh> SM(TEXT("StaticMesh'/Game/PrototypeWeap/Prototype_RocketLauncher_Pickup.Prototype_RocketLauncher_Pickup'")); if (SM.Succeeded()) { StaticMeshComp->SetStaticMesh(SM.Object); } } static ConstructorHelpers::FObjectFinder<USoundCue> SC(TEXT("SoundCue'/Game/PrototypeWeap/Sound/RocketLauncher/RL_AmmoPickup_Cue.RL_AmmoPickup_Cue'")); if (SC.Succeeded()) { PickupSoundCue = SC.Object; } WeaponType = AWeaponRocketLauncher::StaticClass(); }
APickupSniperRifle::APickupSniperRifle(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { if (nullptr != StaticMeshComp) { static ConstructorHelpers::FObjectFinder<UStaticMesh> SM(TEXT("StaticMesh'/Game/PrototypeWeap/Prototype_SniperRifle_Pickup.Prototype_SniperRifle_Pickup'")); if (SM.Succeeded()) { StaticMeshComp->SetStaticMesh(SM.Object); } } static ConstructorHelpers::FObjectFinder<USoundCue> SC(TEXT("SoundCue'/Game/PrototypeWeap/Sound/SniperRifle/SR_AmmoPickup01_Cue.SR_AmmoPickup01_Cue'")); //!< 02, 03 ‚à‚ ‚é if (SC.Succeeded()) { PickupSoundCue = SC.Object; } WeaponType = AWeaponSniperRifle::StaticClass(); }
void AIWeapon::SetAssets(const FString& SkeletMeshPath, const FString& ProjectileBPPath, const FString& ParticleSystemPath) { static ConstructorHelpers::FObjectFinder<USkeletalMesh> SkeletalAsset(*SkeletMeshPath); if (SkeletalAsset.Succeeded()) { WeaponSkeletalMeshComp->SetSkeletalMesh(SkeletalAsset.Object); } static ConstructorHelpers::FClassFinder<AActor> ProjectileBlueprint(*ProjectileBPPath); if (ProjectileBlueprint.Succeeded()) { ProjectileClass = ProjectileBlueprint.Class; } static ConstructorHelpers::FObjectFinder<UParticleSystem> FlashAsset(*ParticleSystemPath); if (FlashAsset.Succeeded()) { FlashParticleSystemRaw = FlashAsset.Object; } }
AImpactEffectAssaultRifle::AImpactEffectAssaultRifle() : Super() { static ConstructorHelpers::FObjectFinder<UParticleSystem> PS(TEXT("ParticleSystem'/Game/PrototypeWeap/FX/P_Impact_01.P_Impact_01'")); if (PS.Succeeded()) { ImpactParticle = PS.Object; } static ConstructorHelpers::FObjectFinder<USoundCue> SC(TEXT("SoundCue'/Game/PrototypeWeap/Sound/Rifle/Rifle_BulletImpact_Cue.Rifle_BulletImpact_Cue'")); if (SC.Succeeded()) { ImpactSoundCue = SC.Object; } //static ConstructorHelpers::FObjectFinder<UMaterialInterface> MI(TEXT("")); //if (MI.Succeeded()) //{ // ImpactDecal = MI.Object; //} }
AWeapon::AWeapon() : Super() { partclSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("WeaponParticle")); audioComp = CreateDefaultSubobject<UAudioComponent>(TEXT("WeaponAudio")); SetType(ItemEnumns::Weapon); static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleSystemClass(TEXT("/Game/TopDown/Particle_Effects/Gun_Flash")); if (ParticleSystemClass.Succeeded()) { partclSystem->Template = ParticleSystemClass.Object; partclSystem->bAutoActivate = false; partclSystem->SetActorParameter(FName(TEXT("BeamSource")), this); } }
APlayerHUD::APlayerHUD(const FObjectInitializer& objectInitializer) : Super(objectInitializer) { //Font'/Game/Realm/UI/UIFont.UIFont' static ConstructorHelpers::FObjectFinder<UFont> fontClass(TEXT("/Game/Realm/UI/UIFont")); if (fontClass.Succeeded()) { uiFont = fontClass.Object; } bShowOverlays = true; }
APlayerHUD::APlayerHUD(const FObjectInitializer& objectInitializer) : Super(objectInitializer) { //Font'/Game/Realm/UI/UIFont.UIFont' static ConstructorHelpers::FObjectFinder<UFont> fontClass(TEXT("/Game/Realm/UI/UIFont")); if (fontClass.Succeeded()) { uiFont = fontClass.Object; } bShowOverlays = true; mapPosition = FVector2D(0.8f, 0.7f); mapDimensions = 300.f; }
AMechanism::AMechanism() { PrimaryActorTick.bCanEverTick = true; //skeletal mesh SkeletalMesh = CreateOptionalDefaultSubobject<USkeletalMeshComponent>(TEXT("SkeletalComponent")); if (SkeletalMesh) { SkeletalMesh->AlwaysLoadOnClient = true; SkeletalMesh->AlwaysLoadOnServer = true; SkeletalMesh->bOwnerNoSee = false; SkeletalMesh->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::AlwaysTickPose; SkeletalMesh->bCastDynamicShadow = true; SkeletalMesh->bAffectDynamicIndirectLighting = true; SkeletalMesh->PrimaryComponentTick.TickGroup = TG_PrePhysics; SkeletalMesh->bChartDistanceFactor = true; SkeletalMesh->AttachParent = RootComponent; static FName CollisionProfileName(TEXT("OverlapAll")); SkeletalMesh->SetCollisionProfileName(CollisionProfileName); SkeletalMesh->bGenerateOverlapEvents = true; SkeletalMesh->bCanEverAffectNavigation = false; SkeletalMesh->SetRelativeLocation(FVector(0, 0, 0)); SkeletalMesh->CastShadow = false; } //Public properties CanActivate = CanDisactivate = true; DisableAtEndAction = false; NumberOfActions = 1; TimeInIntermittence = 1.0f; TimeToStartIntermittence = 5.0f; ColorDisabled = FLinearColor(0.0f, 0.0f, 0.0f, 1.0f); ColorEnabled = FLinearColor(0.0f, 0.9490f, 1.0f, 1.0f); intermitedOn = true; m_target = ColorEnabled; m_origin = ColorDisabled; //Private properties m_elapsedIntermitence = 0.0f; m_elapsedStartIntermitence = TimeToStartIntermittence; MechanismMaterial = ((UPrimitiveComponent*)GetRootComponent())->CreateAndSetMaterialInstanceDynamic(0); UMaterial* mat = nullptr; static ConstructorHelpers::FObjectFinder<UMaterial> MatFinder(TEXT("Material'/Game/Models/Button/Button.Button'")); if (MatFinder.Succeeded()) { mat = MatFinder.Object; MechanismMaterial = UMaterialInstanceDynamic::Create(mat, GetWorld()); } m_isPushed = false; }
ARangePowerup::ARangePowerup() { static ConstructorHelpers::FObjectFinder<UStaticMesh> ofMesh(TEXT("StaticMesh'/Game/StaticMeshes/explode_powerup.explode_powerup'")); m_pMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh")); m_pMesh->SetCollisionProfileName(TEXT("NoCollision")); if (ofMesh.Succeeded()) { m_pMesh->SetStaticMesh(ofMesh.Object); m_pMesh->SetWorldScale3D(FVector(0.5f, 0.5f, 0.5f)); } m_pMesh->AttachTo(RootComponent); }
// Sets default values APawnCharacter::APawnCharacter() { // Stats moveSpeed = 300.0f; dodgeSpeed = 800.0f; // 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; // Our root component will be a sphere that reacts to physics USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent")); RootComponent = SphereComponent; SphereComponent->InitSphereRadius(40.0f); SphereComponent->SetCollisionProfileName(TEXT("Pawn")); // Create and position a mesh component so we can see where our sphere is UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation")); SphereVisual->AttachTo(RootComponent); static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { SphereVisual->SetStaticMesh(SphereVisualAsset.Object); SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -40.0f)); SphereVisual->SetWorldScale3D(FVector(0.8f)); } // Use a spring arm to give the camera smooth, natural-feeling motion. USpringArmComponent* SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm")); SpringArm->AttachTo(RootComponent); SpringArm->RelativeRotation = FRotator(-75.f, 0.f, 0.f); SpringArm->TargetArmLength = 800.0f; SpringArm->bEnableCameraLag = true; SpringArm->CameraLagSpeed = 5.0f; // Create a camera and attach to our spring arm UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera")); Camera->AttachTo(SpringArm, USpringArmComponent::SocketName); // Take control of the default player AutoPossessPlayer = EAutoReceiveInput::Player0; // Create an instance of our movement component, and tell it to update the root. OurMovementComponent = CreateDefaultSubobject<UPawnCharacterMovementComponent>(TEXT("CustomMovementComponent")); OurMovementComponent->UpdatedComponent = RootComponent; OurMovementComponent->setMoveSpeed(moveSpeed); }
// Sets default values AAltar::AAltar() { PrimaryActorTick.bCanEverTick = true; this->SetActorEnableCollision(true); GiveKey = true; AltarColor = FLinearColor(0.0f, 0.0f, 1.0f); DisableColor = FLinearColor(0.0f, 0.0f, 0.0f, 0.0f); AltarMaterial = ((UPrimitiveComponent*)GetRootComponent())->CreateAndSetMaterialInstanceDynamic(0); UMaterial* mat = nullptr; static ConstructorHelpers::FObjectFinder<UMaterial> MatFinder(TEXT("Material'/Game/Models/Altar/Altar_mat.Altar_mat'")); if (MatFinder.Succeeded()) { mat = MatFinder.Object; AltarMaterial = UMaterialInstanceDynamic::Create(mat, GetWorld()); } m_colorControl = false; }
ATP_TopDownCharacter::ATP_TopDownCharacter() { // Set size for player capsule GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f); // Don't rotate character to camera direction bUseControllerRotationPitch = false; bUseControllerRotationYaw = false; bUseControllerRotationRoll = false; // Configure character movement GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction GetCharacterMovement()->RotationRate = FRotator(0.f, 640.f, 0.f); GetCharacterMovement()->bConstrainToPlane = true; GetCharacterMovement()->bSnapToPlaneAtStart = true; // Create a camera boom... CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom")); CameraBoom->SetupAttachment(RootComponent); CameraBoom->bAbsoluteRotation = true; // Don't want arm to rotate when character does CameraBoom->TargetArmLength = 800.f; CameraBoom->RelativeRotation = FRotator(-60.f, 0.f, 0.f); CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level // Create a camera... TopDownCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("TopDownCamera")); TopDownCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm // Create a decal in the world to show the cursor's location CursorToWorld = CreateDefaultSubobject<UDecalComponent>("CursorToWorld"); CursorToWorld->SetupAttachment(RootComponent); static ConstructorHelpers::FObjectFinder<UMaterial> DecalMaterialAsset(TEXT("Material'/Game/TopDownCPP/Blueprints/M_Cursor_Decal.M_Cursor_Decal'")); if (DecalMaterialAsset.Succeeded()) { CursorToWorld->SetDecalMaterial(DecalMaterialAsset.Object); } CursorToWorld->DecalSize = FVector(16.0f, 32.0f, 32.0f); CursorToWorld->SetRelativeRotation(FRotator(90.0f, 0.0f, 0.0f).Quaternion()); // Activate ticking in order to update the cursor every frame. PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; }
// Sets default values ATorus::ATorus() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; m_pMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh")); static ConstructorHelpers::FObjectFinder<UStaticMesh> ofMesh(TEXT("StaticMesh'/Game/StaticMeshes/torus.torus'")); if (ofMesh.Succeeded()) { m_pMesh->SetStaticMesh(ofMesh.Object); m_pMesh->SetCollisionProfileName(TEXT("NoCollision")); } RootComponent = m_pMesh; m_fRotation = 0.0f; }
// Sets default values APlanet::APlanet() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; // Create and position a mesh component so we can see where our sphere is ourVisualComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SphereVisualRepresentation")); RootComponent = ourVisualComponent; static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { ourVisualComponent->SetStaticMesh(SphereVisualAsset.Object); } distanceFromSun = 0.0f; enterHeightOffset = -10000.0f; rotationSpeed = 1/FMath::FRandRange(0.15f, 0.5f); runningTime = FMath::FRandRange(0.0f, 2.0f*PI) * rotationSpeed; }
// Sets default values APawnWithCamera::APawnWithCamera() { // 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; // Our root component will be a sphere that reacts to physics USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent")); RootComponent = SphereComponent; SphereComponent->InitSphereRadius(40.0f); SphereComponent->SetCollisionProfileName(TEXT("Pawn")); // Create and position a mesh component so we can see where our sphere is UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation")); SphereVisual->AttachTo(RootComponent); static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); if (SphereVisualAsset.Succeeded()) { SphereVisual->SetStaticMesh(SphereVisualAsset.Object); SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -40.0f)); SphereVisual->SetWorldScale3D(FVector(0.8f)); } //Create our camera sprinf OurCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm")); OurCameraSpringArm->AttachTo(RootComponent); OurCameraSpringArm->SetRelativeLocationAndRotation(FVector(4.0f, 0.0f, 30.0f), FRotator(-60.0f, 0.0f, 0.0f)); OurCameraSpringArm->TargetArmLength = 300.f; OurCameraSpringArm->bEnableCameraLag = true; OurCameraSpringArm->CameraLagSpeed = 3.0f; OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("GameCamera")); OurCamera->AttachTo(OurCameraSpringArm, USpringArmComponent::SocketName); OurMovementComponent = CreateDefaultSubobject<UCollidingPawnMovementComponent>(TEXT("CustomMovementComponent")); OurMovementComponent->UpdatedComponent = RootComponent; //Take control of the default Player AutoPossessPlayer = EAutoReceiveInput::Player0; speenIncrease = 2.0f; speed = 100.f; }
// Sets default values ABatteryPickup::ABatteryPickup() { // Activamos las físicas GetMesh()->SetSimulatePhysics(true); BatteryPower = 150.0f; static ConstructorHelpers::FObjectFinder<UParticleSystem> Template (TEXT("ParticleSystem'/Game/ExampleContent/Effects/ParticleSystems/P_electricity_arc.P_electricity_arc'")); if (Template.Succeeded()) { ParticleSystemTemplate = Template.Object; } else { UE_LOG(LogTemp, Warning, TEXT("'P_electricity_arc' not found")); } }
AMobilePlatform::AMobilePlatform() { PrimaryActorTick.bCanEverTick = true; OurVisibleComponent->bGenerateOverlapEvents = true; this->SetActorEnableCollision(true); RootComponent->SetMobility(EComponentMobility::Movable); OurVisibleComponent->SetMobility(EComponentMobility::Movable); OurVisibleComponent->CastShadow = false; //setting RightDistance = 100.f; LeftDistance = 100.f; RightDelay = 1.f; LeftDelay = 1.f; Speed = 100.f; InitialDelay = 1.f; Enabled = true; ColorDisabled = FLinearColor(0.0f, 0.0f, 0.0f, 1.0f); ColorEnabled = FLinearColor(0.0f, 0.9490f, 1.0f, 1.0f); TimeInIntermittence = 1.0f; //private variables m_timer = 0; m_state = INITIAL_DELAY; m_currentDistance = 0; m_maxActions = 1; m_actions = 0; m_disableAtEndAction = m_isPlayerOn = false; intermitedOn = true; m_target = ColorEnabled; m_origin = ColorDisabled; m_controlOff = false; MobilePlatformMaterial = ((UPrimitiveComponent*)GetRootComponent())->CreateAndSetMaterialInstanceDynamic(0); UMaterial* mat = nullptr; static ConstructorHelpers::FObjectFinder<UMaterial> MatFinder(TEXT("Material'/Game/Models/Plataforma_MOVIL/Plataforma_movil.Plataforma_movil'")); if (MatFinder.Succeeded()) { mat = MatFinder.Object; MobilePlatformMaterial = UMaterialInstanceDynamic::Create(mat, GetWorld()); } }