Announcement

Collapse
No announcement yet.

Getting the Size of a Blueprint Object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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().

    Code:
    AActor* const plat = Cast<ASolidBottomPlatformParent>(SolidPlats[i]);
    			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?
    Last edited by The Britain; 11-29-2014, 01:49 PM.

    #2
    Hey,
    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

    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:

    Code:
    FVector* boxExtent; 
    
    AActor* const plat = Cast<ASolidBottomPlatformParent>(SolidPlats[i]);
    			FVector* PlatPosition;
    
    			FVector PlatScale = plat->GetActorBounds(true, PlatPosition, boxExtent);
    boxExtent will contain your information
    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 That should help you understand what's going on!

    Good luck (again)
    Last edited by Nanoxin; 11-29-2014, 03:04 PM.

    Comment


      #3
      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.
      Last edited by The Britain; 11-29-2014, 11:55 PM.

      Comment


        #4
        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: [i] is part of a loop. This is just the index of a TArray I setup to find all of a particular object.

        Code:
        AActor* const plat = Cast<ASolidBottomPlatformParent>(SolidPlats[i]);
        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.
        Last edited by The Britain; 11-30-2014, 12:50 AM.

        Comment

        Working...
        X