示例#1
0
// 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
APawnWithCamera::APawnWithCamera()
{
    
    //To create "Voyager" and for it to have collision, we must make a camera inside of a sphere
    //This way we can zip about the universe and not collide with planets/the sun
    PrimaryActorTick.bCanEverTick = true;
    
    // Our root component will be a sphere that reacts to physics
    USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
    RootComponent = SphereComponent;
    SphereComponent->InitSphereRadius(100.0f);
    SphereComponent->SetCollisionProfileName(TEXT("Pawn"));
    
    OurCameraSpringArm=CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
    OurCameraSpringArm->AttachTo(RootComponent);
    OurCameraSpringArm->RelativeRotation = FRotator(-10.0f, 0.0f, 0.0f);
    OurCameraSpringArm->TargetArmLength = 0.0f;
    OurCameraSpringArm->bEnableCameraLag = false;
    OurCameraSpringArm->CameraLagSpeed = 0.0f;
        
    //Create camera and attach spring arm
    OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("GameCamera"));
    OurCamera->AttachTo(OurCameraSpringArm, USpringArmComponent::SocketName);
    
    // Create an instance of our movement component, and tell it to update our root component.
    OurMovementComponent = CreateDefaultSubobject<UVoyagerPawnMovementComponent>(TEXT("CustomMovementComponent"));
    OurMovementComponent->UpdatedComponent = RootComponent;
    
    //Take control of the default Player
    AutoPossessPlayer = EAutoReceiveInput::Player0;
    
    //Set bearing mode time to 2 (default) it is editable from the editor
    BearingTime = 2.0f;
    SphereVisualLocation = (FVector(0.0f, 0.0f, -40.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
AFoodItem::AFoodItem()
{
 	// 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;

	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("root"));
	visibleComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ingredient mesh"));
	USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Collision"));
	SphereComponent->AttachTo(visibleComp);
	SphereComponent->SetSphereRadius(50.0f);

	RootComponent->SetNetAddressable();
	RootComponent->SetIsReplicated(true);

}
示例#5
0
// 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
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;
}
示例#7
0
// Sets default values
AVoyager::AVoyager()
{
 	// 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"));

	sunReference = 0;
	hasSpawnedPlanets = false;
	numberOfSpawnedPlanets = 0;

	inBearingMode = false;
	bearingModeRotationTime = 0.0f;
	desiredBearingDistanceFromSun = 0.0f;
	desiredBearingRotation = FRotator::ZeroRotator;
	initialBearingRotation = FRotator::ZeroRotator;

  // Use a spring arm to give the camera smooth, natural-feeling motion.
  OurCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm"));
  OurCameraSpringArm->AttachTo(RootComponent);
  OurCameraSpringArm->RelativeRotation = FRotator(-45.f, 0.f, 0.f);
  OurCameraSpringArm->TargetArmLength = 0.0f;
  OurCameraSpringArm->bEnableCameraLag = false;
  OurCameraSpringArm->CameraLagSpeed = 0.0f;

  // Create a camera and attach to our spring arm
  OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera"));
  OurCamera->AttachTo(OurCameraSpringArm, USpringArmComponent::SocketName);

  // Create an instance of our movement component, and tell it to update the root.
  OurMovementComponent = CreateDefaultSubobject<UVoyagerMovementComponent>(TEXT("CustomMovementComponent"));
  OurMovementComponent->UpdatedComponent = RootComponent;

  // Take control of the default player
  AutoPossessPlayer = EAutoReceiveInput::Player0;

}
示例#8
0
// Sets default values
AKrofna_CPP::AKrofna_CPP()
{
 	// 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;
	UStaticMeshComponent *Krofna = CreateDefaultSubobject<UStaticMeshComponent,UStaticMeshComponent>(TEXT("krofnica"));
	URotatingMovementComponent *Rotacija = CreateDefaultSubobject<URotatingMovementComponent, URotatingMovementComponent>(TEXT("rotaciona komponenta"));
	UPointLightComponent *Svetlo1 = CreateDefaultSubobject <UPointLightComponent, UPointLightComponent>(TEXT("Svetlo1"));
	UPointLightComponent *Svetlo2 = CreateDefaultSubobject <UPointLightComponent, UPointLightComponent>(TEXT("Svetlo2"));
	USphereComponent *Kolizija = CreateDefaultSubobject <USphereComponent, USphereComponent>(TEXT("Kolizija"));
	Kolizija->SetSphereRadius(65.f);
	Kolizija->Activate(true);
	Kolizija->bGenerateOverlapEvents = true;
	Kolizija->SetRelativeLocation(FVector(0,0,18.f));
	this->RootComponent = Krofna;
	Kolizija->AttachTo(RootComponent);
	Svetlo1->AttachTo(RootComponent);
	Svetlo2->AttachTo(RootComponent);
	Svetlo1->SetRelativeLocation(FVector(0, 0, 65));
	Svetlo2->SetRelativeLocation(FVector(0, 0, -45));
	Svetlo1->SetLightColor(FLinearColor(0.65f, 1.f, 0.875f));
	Svetlo2->SetLightColor(FLinearColor(0.45f, 1.f, 0.82f));
	this->DisableComponentsSimulatePhysics();
	Krofna->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
	static ConstructorHelpers::FObjectFinder<UStaticMesh> Krofna_SM(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Torus.Shape_Torus'"));
	Krofna->SetStaticMesh(Krofna_SM.Object);


	static ConstructorHelpers::FObjectFinder<UMaterial> Krofna_M(TEXT("Material'/Game/StarterContent/Materials/M_Metal_Gold.M_Metal_Gold'"));
	Krofna->SetMaterial(0, Krofna_M.Object);

	Rotacija->SetActive(true);
	Rotacija->RotationRate = FRotator(120,120,120);

	this->SetActorEnableCollision(true);
	OnActorBeginOverlap.AddDynamic(this, &AKrofna_CPP::OnBeginOverlap);

	
}