Here’s what it looks like when I constructed them by default:
And here’s what it should look like in the editor when I changed the mesh’s scale size to 0.5 for each axis. Note that I did this in “Simulate” mode in the UE4 Editor.
I don’t know how to scale down the mesh, or scale up the USphereComponent by 50% of its original scale value.
This is how it looks in my code:
Obstacle.cpp
// Sets default values
AObstacle::AObstacle(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass<UMovementComponent>(TEXT("ObstacleBasicMovement")))
{
// 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;
this->TimerCountdown = this->TimerInitialValue = 3;
//Uniform scale
FVector Scale = FVector(1.0f);
//Setting basic mesh and collider
this->SphereCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereCollider"));
//this->SphereCollider->SetRelativeScale3D(Scale * 2.0f);
this->SphereCollider->SetWorldScale3D(Scale * 1.5f);
this->SphereCollider->SetRelativeLocation(FVector::ZeroVector);
this->SphereCollider->SetCollisionProfileName(TEXT("Pawn"));
this->SphereCollider->SetSimulatePhysics(true);
this->SphereCollider->SetSphereRadius(38.5f);
this->SetRootComponent(this->SphereCollider);
static ConstructorHelpers::FObjectFinder<UStaticMesh> BodyMeshObject(TEXT("StaticMesh'/Game/Meshes/Sphere_Mesh.Sphere_Mesh'"));
if (BodyMeshObject.Succeeded()){
this->BodyMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("BodyMesh"));
this->BodyMesh->SetStaticMesh(BodyMeshObject.Object);
this->BodyMesh->SetRelativeLocation(FVector::ZeroVector);
this->BodyMesh->AttachTo(this->SphereCollider);
}
//Other properties
this->Acceleration = FVector::ZeroVector;
this->Velocity = FVector::ZeroVector;
}
I had tried to use SetRelativeScale3D()
and SetWorldScale3D()
, but it doesn’t seem to scale my components, even when restarting UE4.
What am I doing wrong? Thanks in advance.