Hi, relative newbie here looking for help after a day’s digging around forums and YouTube videos!
I’m trying to draw a line between two 3d actors that is displayed using a cinecamera sequence.
As its for a diagram-style sequence, I’d like to use a UI widget, so that the line remains the same width and doesn’t show any perspective when one object is in the distance.
I’ve built a widget blueprint that uses an On Paint override and added it to the level blueprint, but whatever I do, I can’t get the line into the right place. I think the Project World to Screen function is using the wrong player controller location.
Here’s what it looks like in 3rd person play
This is the widget blueprint:
https://pasteboard.co/tcm7KKUgorEt.png
And this is the level Blueprint:
https://pasteboard.co/j1rNgeEIE5Wp.png
I know I’m also going to have to work out a way of positioning the playercontroller by the camera - that’s the next hurdle! Unless anyone knows how to feed camera positions into the project world to screen function.
Any ideas what I’m doing wrong?
HI @thewisebunny11 ,
Try using Project World Location to Widget Position instead of Project World to Screen(with Player Viewport Relative set to true)
Project World to Screen only gives you the location in screen pixels, which can get misaligned if the resolution changes or there’s scaling.
On the other hand, Project World Location to Widget Position calculates the position taking the viewport and the UI into account, so the line stays correctly aligned with the 3D objects regardless of resolution.
Hope this help
1 Like
Thanks for that! Typically, I just stumbled on exactly the same thing. I hadn’t checked my emails to see that you posted the solution, and started wondering if it was viewport resolution that was causing the issue. Sure enough, running in PIE and resizing the window showed the cause. As an added bonus, your solution also works with cine cameras and sequences out of the box, so no messing around with moving player controllers!
I’ll add some screenshots later to help anyone else that is having similar issues.
Thanks again!
Rog
1 Like
For anyone trying to do the same thing, here’s a video showing two actors tied by a line, viewed from a cinecamera: https://f.io/brOT3oSn
To make:
-
in content browser, right click and select user interface>widget blueprint
-
Give it a name e.g. WBP_LineHUD
-
In BP’s Designer panel, add a canvas if one’s not already there. Scale it to your usual screen size
-
In BP’s event graph details panel, under functions, click Override>On Paint
-
Also in details panel, create two variables and set them to actor types. Call them something like Actor_A and Actor_B. In their details panels, set them both to Instance Editiable and Expose on Spawn.
-
In the On Paint graph, build this:
-
Open the level Blue Print and add this:
I hope this helps someone! I could have done with it a few days ago!
1 Like