I want to stop moving to right for object when it hit or touch the red line of the widget. Any idea how to achieve it? I can stop object movement when it touches the screen border so that while moving with WASD, my object could not get out of screen. thanks!
Widgets that are drawn to the viewport do not have any presence in the world. Therefore physical objects cannot detect them.
I guess one workaround would be to have a box collision component fixed to the right side of the camera with plenty of depth. Position the box so it roughly matches the area of the viewport covered by the widget. If the object overlaps with the box component, stop the movement.
Hope this suggestion helps.
About the workaround, there are some other functionalities I have done such as camera doing 360 degree rotation or up down rotation around object. I was wondering if it really solves the problem by putting collision. I am checking if edge points of box are out of camera’s field of view angle and if so I was stopping the movement of camera.
I was testing with value of camera’s field of view angle but the problem is since widget is scaling according to screen size, for other resolution, box movement does not stop perfectly always.
I will try your workaround for sure. Thanks!
I made an equation based on the width of the screen size which gives me certain FOV value (by trial and error) which i used later. I found out for 1280, FOV should be 0.17, for 1920 and 3840, they should be 0.25 and 0.5. Then I made a quadratic function from those points, so it can give me other FOV value on other screen size. It does not feel 100% perfect but so far it works more or less okey.