Exemple #1
0
// Sets default values
ACPP_VRPawn::ACPP_VRPawn()
{
	// 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;

	VROriginComp = CreateDefaultSubobject<USceneComponent>(TEXT("VRCameraOrigin"));
	VROriginComp->bAbsoluteLocation = true;
	RootComponent = VROriginComp;
	//VROriginComp->SetupAttachment(RootComponent);

	//setup camera
	Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
	Camera->bAbsoluteLocation = false;
	Camera->SetupAttachment(VROriginComp);

	//setup left hand
	LeftHand = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftHand"));
	LeftHand->Hand = EControllerHand::Left;
	LeftHand->SetupAttachment(VROriginComp);
	LHandMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("LeftHandMesh"));
	LHandMesh->SetupAttachment(LeftHand);
	LHandCollision = CreateDefaultSubobject<USphereComponent>(TEXT("LeftHandCollision"));
	LHandCollision->SetupAttachment(LeftHand);

	LPhysHandle = CreateDefaultSubobject<UPhysicsHandleComponent>(TEXT("LeftHandPhysics"));

	//setup right hand
	RightHand = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightHand"));
	RightHand->Hand = EControllerHand::Right;
	RightHand->SetupAttachment(VROriginComp);
	RHandMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("RightHandMesh"));
	RHandMesh->SetupAttachment(RightHand);
	RHandCollision = CreateDefaultSubobject<USphereComponent>(TEXT("RightHandCollision"));
	RHandCollision->SetupAttachment(RightHand);

	RPhysHandle = CreateDefaultSubobject<UPhysicsHandleComponent>(TEXT("RightHandPhysics"));

	//initialize hand grab states
	bRIsGrabbing = bLIsGrabbing = false;
	RGrabLocation = LGrabLocation = FVector(0);
	RInitialHandRotation = LInitialHandRotation = FRotator(0);
	RInitialItemRotation = LInitialItemRotation = FRotator(0);



	//setup particle system
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName(TEXT("ParticleSystem'/Game/ParticleSystems/PS_TeleportBeamTrace.PS_TeleportBeamTrace'"));
	ParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("ParticleSystem"));
	if (ArbitraryParticleName.Succeeded())
	{
		ParticleSystem->Template = ArbitraryParticleName.Object;
	}
	ParticleSystem->bAutoActivate = false;
	ParticleSystem->SetHiddenInGame(false);
	ParticleSystem->SetupAttachment(VROriginComp);


	//enable position tracking
	bPositionalHeadTracking = true;
}
AWizardsCharacter::AWizardsCharacter()
{
	bReplicates = true;
	//Tick for mana regen
	PrimaryActorTick.bCanEverTick = true;
	//Set Health and Mana
	Health = 100.0;
	maxHealth = 100.0;
	Mana = 100.0;
	maxMana = 100.0;
	//Spell Stuff for Testing
	//SList.spellCost = 10.0;

	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName(TEXT("ParticleSystem'/Game/StarterContent/Particles/P_Sparks.P_Sparks'"));
	//SList.myParticle = ArbitraryParticleName.Object;
	//SList.test = &ArbitraryParticleName;
	currSpell = 0;
	//For the record, this probably isn't the best way to get particles for the spells but it works
	//A better method, implemented at a later and unknown date, would be to hold this array in its own class
	//that is called once and never destroyed
	//Projectiles
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName0(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Fire_Projectile.P_Fire_Projectile'"));
	particleList.Add(ArbitraryParticleName0.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName1(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Lightning_Projectile.P_Lightning_Projectile'"));
	particleList.Add(ArbitraryParticleName1.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName2(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Water_Projectile.P_Water_Projectile'"));
	particleList.Add(ArbitraryParticleName2.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName3(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Ice_Projectile.P_Ice_Projectile'"));
	particleList.Add(ArbitraryParticleName3.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName4(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Earth_Projectile.P_Earth_Projectile'"));
	particleList.Add(ArbitraryParticleName4.Object);
	//Now for all of the EXPLOSIONS
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName5(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Fire_Blast.P_Fire_Blast'"));
	particleList.Add(ArbitraryParticleName5.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName6(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Lightning_Blast.P_Lightning_Blast'"));
	particleList.Add(ArbitraryParticleName6.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName7(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Water_Blast.P_Water_Blast'"));
	particleList.Add(ArbitraryParticleName7.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName8(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Ice_Blast.P_Ice_Blast'"));
	particleList.Add(ArbitraryParticleName8.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName9(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Earth_Blast.P_Earth_Blast'"));
	particleList.Add(ArbitraryParticleName9.Object);
	//Next up is cones
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName10(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Fire_Cone.P_Fire_Cone'"));
	particleList.Add(ArbitraryParticleName10.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName11(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Lightning_Cone.P_Lightning_Cone'"));
	particleList.Add(ArbitraryParticleName11.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName12(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Water_Cone.P_Water_Cone'"));
	particleList.Add(ArbitraryParticleName12.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName13(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Ice_Cone.P_Ice_Cone'"));
	particleList.Add(ArbitraryParticleName13.Object);
	ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName14(TEXT("ParticleSystem'/Game/FirstPerson/Particles/P_Earth_Cone.P_Earth_Cone'"));
	particleList.Add(ArbitraryParticleName14.Object);


	//spell test;
	//SList.Add(test);
	//SList[currSpell].spellCost = 10.0;
	//SList[currSpell].theWizard = this;
	//SList[currSpell].canBounce = true;
	//ConstructorHelpers::FObjectFinder<UParticleSystem> ArbitraryParticleName8(TEXT("ParticleSystem'/Game/StarterContent/Particles/P_Sparks.P_Sparks'"));
	//SList[currSpell].myParticle = ArbitraryParticleName8.Object;
	//SList.test = &ArbitraryParticleName;
	//SList.particleLocation = FName(TEXT("ParticleSystem'/Game/StarterContent/Particles/P_Sparks.P_Sparks'"));

	// Set size for collision capsule
	GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

	// set our turn rates for input
	BaseTurnRate = 45.f;
	BaseLookUpRate = 45.f;

	// Create a CameraComponent	
	FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
	FirstPersonCameraComponent->AttachParent = GetCapsuleComponent();
	FirstPersonCameraComponent->RelativeLocation = FVector(0, 0, 64.f); // Position the camera
	FirstPersonCameraComponent->bUsePawnControlRotation = true;

	// Default offset from the character location for projectiles to spawn
	GunOffset = FVector(100.0f, 30.0f, 10.0f);

	// Create a mesh component that will be used when being viewed from a '1st person' view (when controlling this pawn)
	Mesh1P = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("CharacterMesh1P"));
	Mesh1P->SetOnlyOwnerSee(true);			// only the owning player will see this mesh
	Mesh1P->AttachParent = FirstPersonCameraComponent;
	Mesh1P->RelativeLocation = FVector(0.f, 0.f, -150.f);
	Mesh1P->bCastDynamicShadow = false;
	Mesh1P->CastShadow = false;

	// Note: The ProjectileClass and the skeletal mesh/anim blueprints for Mesh1P are set in the
	// derived blueprint asset named MyCharacter (to avoid direct content references in C++)
}