Announcement

Collapse
No announcement yet.

Get Actors in Selection Box Problem

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

    Get Actors in Selection Box Problem

    Hi!
    I created a RTS selection rectangle and the unit selection doesn't work perfectly..
    This is the selection BP:
    Click image for larger version

Name:	337bd04803995664fd5a4f8e6b964ae6.png
Views:	1
Size:	146.9 KB
ID:	1141894

    And this is the result with the problem: (if it moves slowly, click on the 3 dots icon in the right side and change it to MP4)
    http://gyazo.com/969b579c43a9867ca2035f1925ff6767

    As you can see, when the selection box is too small, the actor is still unmarked even if the selection box exactly on the actor.
    So how can I fix this?

    Thanks!
    Yoni.

    #2
    Someone help please? :\

    Comment


      #3
      Uncheck "Actor Must be Fully Enclosed"?

      Comment


        #4
        Originally posted by Wolfsblut View Post
        Uncheck "Actor Must be Fully Enclosed"?
        I tryed it and it still doesn't work perfectly..
        http://gyazo.com/3d5b4937bc0bf0e658e75107948c7604

        Another problem that comes with it:
        http://gyazo.com/9e61c4a531a7c029dc1bc67254901393
        Last edited by YoniBE; 12-18-2014, 02:16 AM.

        Comment


          #5
          This node was contributed by rama, maybe he can help.

          Check this out first... https://answers.unrealengine.com/que...esnt-work.html

          Comment


            #6
            I was having some problems with the selection box as well but managed to find and solve the issue. Here are some things to note:


            -The "GetActorsInSelectionRectangle()" method needs to be invoked within the HUD:rawHUD() method. If you dig into the C++ code implementation, there is this code:
            Code:
            FBox2D ActorBox2D(0);
            for (uint8 BoundsPointItr = 0; BoundsPointItr < 8; BoundsPointItr++)
            {
               // Project vert into screen space.
               const FVector ProjectedWorldLocation = Project(BoxCenter + (BoundsPointMapping[BoundsPointItr] * BoxExtents)); //<---Look in here!
               // Add to 2D bounding box
               ActorBox2D += FVector2D(ProjectedWorldLocation.X, ProjectedWorldLocation.Y);
            }
            There is some internal validation checking which happens when you project an object. It checks to see if a Canvas object is not null. The only time the canvas object is not null is when you're using the DrawHUD() method. So! That certainly puts some limitations on when and where you can call the method!


            -The class can also use class filters, if you set any. If you don't set any or use a very broad filter, you're going to get a lot of hit results which you then have to filter manually. Internally, the class just takes all objects in the game world, unprojects them into screen space, and then does a 2D bounding box collision test against the actors bounding area. SO! If your actor doesn't actually HAVE a bounding area, a bounding box can't be derived and you won't ever get any hit results! Make sure your bounding area exists and is where it should be (hint: turn on the bounding area visibility for testing/debugging).

            -Last resort: You can always set a breakpoint in the C++ code and step into the selection box code. Does the world contain the object you're trying to select? Did you accidentally filter it out before you do the selection results? Does the object have a bounding area? Do you have a canvas? Does the selection box actually overlap the unprojected bounding box?

            -If things are still super crazy and the unprojection is still wrong, you want to verify that you're actually unprojecting with the correct camera! A camera has an internal View Projection matrix (stored within the UCanvas object [Canvas.h, line 210]) which it uses to unproject things from 3D space into 2D space. If you've got two cameras in different positions, and you're sending your selection rectangle drawn in your current camera to an inactive camera, the deprojection is going to be wrong and you're going to be selecting objects which aren't in your current view or selection box. I don't know how you'd accidentally do this, but its possible.

            Comment

            Working...
            X