Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Size and distance relationship


I have the UMG widget target indicator,

I need to change its size depending on the distance to the object (something like height and distance relationship)

Widget should always be the same size as the object.

How can I do that ? What is the formula for this ?


alt text

Product Version: UE 4.8
targetindicator.png (141.3 kB)
more ▼

asked Aug 05 '15 at 09:40 AM in C++ Programming

avatar image

222 22 27 45

avatar image Xenome Aug 05 '15 at 09:56 AM

This could potentially be very easy, because the LOD system knows the percentage of the screen that a mesh is currently filling. Now, I have no idea how or if you can hijack this somehow, so I'm just throwing it in here as a possible area to research. If it's accessible data, it could be a very clean solution.

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

The way to do this is to calculate the bounds of the object. Then project those bounds into screen space. Then draw the overlay based upon the projected bounds.

more ▼

answered Aug 05 '15 at 08:20 PM

avatar image

joeGraf STAFF
1.5k 35 12 68

(comments are locked)
10|2000 characters needed characters left

I found a simple formula for this. In NativeTick:

     float distance = (Player->GetTargetLocation() - Box->GetActorLocation()).Size();
     if (distance > 800) // the distance at which the stop resize
         scaleRatio = 1 / distance * 1000;
     OnscreenMarker->SetRenderScale(FVector2D(scaleRatio, scaleRatio));

alt text

sc.png (173.9 kB)
more ▼

answered Aug 06 '15 at 09:40 AM

avatar image

222 22 27 45

avatar image joeGraf STAFF Aug 06 '15 at 12:52 PM

That won't handle different aspect ratios or different fov settings. To handle it in those cases you have to project the box into screen space. Secondly, the size function is the 3d size so long boxes extruded away from view will have too large of a scaled overlay

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question