Hey I’m having issues with an identifier not being defined…
This is in the header file…
{
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;
// Don’t rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input…
GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f); // …at this rotation rate
GetCharacterMovement()->JumpZVelocity = 600.f;
GetCharacterMovement()->AirControl = 0.2f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT(“CameraBoom”));
CameraBoom->AttachTo(RootComponent);
CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT(“FollowCamera”));
FollowCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Create the collection sphere
CollectionSphere = CreateDefaultSubobject<USphereComponent>(TEXT(“CollectionSphere”));
CollectionSphere = AttachTo(RootComponent);
CollectionSphere->SetSphereRadius(200.f);
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C++)
//set a base power level for the character
InitialPower = 2000.f;
CharacterPower = InitialPower;
}
This is the source file, the issue is with the CollectionSphere identifier, now I thought it could be something I didn’t include but I don’t know.
SolidSk
(SolidSk)
May 27, 2020, 9:00pm
2
Did you include:
#include "Components/SphereComponent.h"
What is the error message?
It’s saying the variable is “undeclared,” I’m going to scrap the script and start over. How exactly do I import a prewritten script into VS?
You are confusing 2 different parts of code.
You need to declare in your .h file
USphereComponent CollectionSphere; *
The FORCEINLINE is totally separate, it is a public function call so that other actors or objects that have reference to that class/actor can directly call those 3 functions as get functions to get the camera/boom/collectionsphere object;
anonymous_user_d0719dbe1:
You are confusing 2 different parts of code.
You need to declare in your .h file
USphereComponent CollectionSphere; *
The FORCEINLINE is totally separate, it is a public function call so that other actors or objects that have reference to that class/actor can directly call those 3 functions as get functions to get the camera/boom/collectionsphere object;
That first part of the code is in the header file. Ok so FORCEINLINE should be replaced with what?
If the error is that specific line in the .h file then its either is complaining about the class USphereComponent or its complaining about CollectionSphere.
comment the line that wont compile out if you don’t need it right now and see if it compiles.
But you are either missing a include header/forward delcation for USphereComponent or you dont have CollectionSphere declared in the same .h file.
Posting the actual compile error message would help.
Or the entire .h file as well.
In the .h file is the *USphereComponent CollectionSphere; **declaration above or below the FORCEINLINE statement?