Getting the Size of a Blueprint Object

I have a paper2D object that I need to get the widthx of. I figured out through implementation that scale, wasn’t what I wanted.

I tried GetActorBounds, but my Actor does not have access to GetBoxExtent(), which is the last argument of GetActorBounds().

AActor* const plat = Cast<ASolidBottomPlatformParent>(SolidPlats*);
			FVector PlatPosition = plat->GetActorLocation();
			FVector PlatScale = plat->GetActorBounds(true, PlatPosition, plat->GetBoxExtent());

“AActor has no member GetBoxExtent.”

How do I go about getting the X with and Z height of my object?

I’m not 100% sure, but I guess you’ll have to get a reference to the UBoxComponent ( I assume you are using one, as you try to use GetBoxExtent ) and then call GetBoxExtent on that specific object.
Might be incorrect though…
Good luck :slight_smile:

EDIT: What I wrote was an alternative way to get the Actor’s bounds(by getting the box’ extent directly). When using GetActorBounds() you have to pass a reference to a FVector object, that will contain the information, just like this:

FVector* boxExtent; 

AActor* const plat = Cast<ASolidBottomPlatformParent>(SolidPlats*);
			FVector* PlatPosition;

			FVector PlatScale = plat->GetActorBounds(true, PlatPosition, boxExtent);

boxExtent will contain your information :slight_smile:
boxExtent->X for example will hold the x-axis-extent (as far as I know?)
The same goes for PlatPosition, it will hold the position of the actor. You don’t know the Actor’s location and extent before calling the function, so it returns it via reference. You might want to take a look at some c++ tutorials regarding references in function calls :slight_smile: That should help you understand what’s going on!

Good luck (again) :slight_smile:

I’m working with paper2d, so the only root component is a 2D sprite with collision. I will keep playing around and post a solution when I find one. Thanks for the help.

Alright, I figured it out. This will draw a line across the top of an actor (I am assuming is a box). Anyone looking for an answer to this should be able to adapt it.

Take note: * is part of a loop. This is just the index of a TArray I setup to find all of a particular object.

AActor* const plat = Cast<ASolidBottomPlatformParent>(SolidPlats*);
FVector PlatPosition = plat->GetActorLocation();
FBox PlatBox = plat->GetComponentsBoundingBox();
FVector PlatSize = PlatBox.GetSize();

//We divide by 2 because PlatSize will return the whole size, and we want from the origin.
//Origin is assumed to be center, otherwise you will need to get the origin.
float FarRight =  PlatPosition.X + (PlatSize.X / 2);
float FarLeft = PlatPosition.X - (PlatSize.X / 2);
float TopOfPlat = PlatPosition.Z + (PlatSize.Z / 2);

FVector debuglinestart = FVector(FarRight, 1, TopOfPlat);
FVector debuglineend = FVector(FarLeft, 1, TopOfPlat);

DrawDebugLine(GetWorld(), debuglinestart, debuglineend, FColor::Red);

I broke this up into a million little variables for purpose of demonstration. I am sure it can be condensed, however, someone looking at this might be searching for one bit or another.