Hi,
I’m using a 3d widget with a cylindrical geomerty mode (the widget is bend to match a cylinder) in a VR scene. In order to interact with the widget, I’ve got a widget interaction component. I want to set a mesh to illustrate this interaction (a cylinder), but cannot get the impact point in world scale between the interaction component and the widget. Also I’ve tried using a linetrace but it gives me a parallelepipedic collision (so the location matches at the right/left bounds of the widget, but I have an offset going bigger to the middle.
Do anyone know a way to get this location - or to get a correct hit result ?
Thanks a lot !
have you found a solution to your problem?
No. I tried some maths to add to the impact location from center to side of the widget, but it takes the whole canvas as a base (and not only the visible part of the widget).
So I’ve no idea yet…
Checkout UWidgetComponent
. It has a function called GetCylinderHitLocation
, this did the trick for me. I used a line trace and passed the hit location and the trace direction to the function. It then returns a tuple containing the hit location in world space (key) and the hit location in widget space (value).
Here’s my code:
if (auto WidgetComp = Cast<UWidgetComponent>(HitResult.GetComponent()))
{
auto CylinderHitLocation = WidgetComp->GetCylinderHitLocation(
HitResult.Location, GetForwardVector());
// do something using CylinderHitLocation.Key;
}
Any idea how to use this in blueprint?
hmm the function is not exposed to blueprints unfortunately…
easiest way would probably be to write a c++ wrapper function that you expose to blueprint, but if you don’t want to lay your hands on c++ at all this is not an option…
you could try to rewrite the function using blueprints but i’m not sure it’s possible, also it would take way more time i think