I’m following the intro to programming video tutorial series, and as far as I can tell I have followed the instructions exactly. Unfortunately, when I drag the battery blueprint into the scene, it stays locked in at the origin and it’s transform cannot be modified.
I searched and there were a few other questions about this and people say you can’t modify something that’s at the root of blueprint. The videos however show this very thing being done.
Not sure what I’m doing wrong. Any suggestions?
EDIT: I think I’ve figured out the issue (still no solution however). The transform component of the blueprint only shows option for static/movable but not the floats for position/rotation/scale are missing. I’ve updated the pic below to reflect this.
//Pickup.cpp
APickup::APickup(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
//make the pickup active when it is created
m_bIsActive = true;
//create the root sphere component to handle collision
BaseCollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("BaseSphereComponent") );
//set the SphereComponent as the root component
RootComponent = BaseCollisionComponent;
//create the static mesh component
PickupMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickupMesh") );
//Turn on physics for the static mesh
PickupMesh->SetSimulatePhysics(true);
//Attach the static mesh component to the root component
PickupMesh->AttachTo(RootComponent);
}
//Because this is a blueprint native event, the engine will check for an implementation in blueprint first,
//if nothing is found in blueprint, it will come here. This is why the name is different,
//even though it is the same function
void APickup::OnPickedUp_Implementation()
{
//No current default behavior
}
//Battery.cpp
ABatteryPickup::ABatteryPickup(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
//base power level of the battery
m_powerLevel = 150.f;
}
void ABatteryPickup::OnPickedUp_Implementation()
{
//we will need to call the base implementation first
Super::OnPickedUp_Implementation();
//destroy the battery
Destroy();
}
Ok, are you able to move it through blueprint? Ie Try using ‘Set Actor Location’ node in its ‘Begin Play’ event and set it to a known location. Does it move when the game starts?
Also check the construction script if you have one. An error in there could make some blueprints immovable. Another thing to check for objects with physics simulation is to make sure they are not intersecting with geometry when placed on the map (its not important).
And how about rotation or scaling? Are you able t do those once you place and instance on the map?
PS: I dont think you will need DefaultSceneRoot wthin the components. Delete that one.
If none of this works, please let know how you created this blueprint setp-by-setp so taht I can try to reproduce it and see what is going on.
I tried everything you suggested, to no avail. I think I’ve figured out the issue (still no solution however). The transform component of the blueprint only shows option for static/movable but not the floats for position/rotation/scale are missing. I’ve updated the pic above to reflect this.
To create the blueprint I right click → select blueprint → select my base class (the actor class for the base pickup, the pickup class for the battery). Nothing out of the ordinary as far as I can tell.
Can you post the full component setup for both your BP classes (Pickup and Battery). Make sure you select the ‘Root’ so that I can see how its properties are setup
This is weird. Normally if the root was movable, it should get a Cross icon by its left (in the hierarchy panel). But in your case, even though ‘Movable’ shows active under ‘Transform’, that icon is missing.
I will do more checks once I get some free time.
In the meantime, you could try ditching C++ and doing everything with BP (only for these 2 classes and for prototyping). Once everything works and to your liking, port it to C++.
I manually set the Mobility for the two components (in Pickup base class) and so far I can move any derived class (whether from C++ or blueprint) after placing it in the map.