Skip to content
Snippets Groups Projects
Commit 782f4985 authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

get interaction ray to render by calling RegisterComponent()

parent f55f5561
No related branches found
No related tags found
1 merge request!2Feature/update to new VRPawn structure and adding an interaction ray that is also available in shipping builds
No preview for this file type
No preview for this file type
...@@ -12,16 +12,18 @@ ...@@ -12,16 +12,18 @@
UVRWidgetInteractionComponent::UVRWidgetInteractionComponent() { UVRWidgetInteractionComponent::UVRWidgetInteractionComponent() {
InteractionRay = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Interaction Ray")); InteractionRay = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Interaction Ray"));
auto MeshAsset = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("/WidgetInteraction/Ray_Mesh"));
//this ray model as a inlayed cross with flipped normals so it can be seen as a cross in desktop mode where the right hand is attached to the head
static ConstructorHelpers::FObjectFinder<UStaticMesh> MeshAsset(TEXT("/WidgetInteraction/Ray_Mesh"));
if (MeshAsset.Object != nullptr) if (MeshAsset.Object != nullptr)
{ {
InteractionRay->SetStaticMesh(MeshAsset.Object); InteractionRay->SetStaticMesh(MeshAsset.Object);
InteractionRay->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
//InteractionRay->SetRelativeRotation(FRotator(0, 90, 0));
} }
bShowDebug = false;
} }
void UVRWidgetInteractionComponent::Init() void UVRWidgetInteractionComponent::Init(USceneComponent * parent)
{ {
SetVisibility(true); SetVisibility(true);
InteractionDistance = 1000000.0f; InteractionDistance = 1000000.0f;
...@@ -32,10 +34,16 @@ void UVRWidgetInteractionComponent::Init() ...@@ -32,10 +34,16 @@ void UVRWidgetInteractionComponent::Init()
input_cmp->BindAction<FFireDelegate>("Fire", IE_Released, this, &UVRWidgetInteractionComponent::OnFire, false); input_cmp->BindAction<FFireDelegate>("Fire", IE_Released, this, &UVRWidgetInteractionComponent::OnFire, false);
RegisterComponent(); RegisterComponent();
InteractionRay->RegisterComponent();
if (parent != nullptr) {
InteractionRay->AttachToComponent(parent, FAttachmentTransformRules::KeepRelativeTransform);
this->AttachToComponent(parent, FAttachmentTransformRules::KeepRelativeTransform);
}
} }
void UVRWidgetInteractionComponent::SetVisibility(bool visible) { void UVRWidgetInteractionComponent::SetVisibility(bool visible) {
bShowDebug = visible; InteractionRay->SetVisibility(visible);
} }
void UVRWidgetInteractionComponent::OnFire(bool val) void UVRWidgetInteractionComponent::OnFire(bool val)
......
...@@ -65,8 +65,7 @@ UVRWidgetInteractionComponent* FWidgetInteractionModule::GetWidgetInteractionCom ...@@ -65,8 +65,7 @@ UVRWidgetInteractionComponent* FWidgetInteractionModule::GetWidgetInteractionCom
void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer) void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer)
{ {
widget_interaction_cmp_ = NewObject<UVRWidgetInteractionComponent>(outer, UVRWidgetInteractionComponent::StaticClass()); widget_interaction_cmp_ = NewObject<UVRWidgetInteractionComponent>(outer, UVRWidgetInteractionComponent::StaticClass());
widget_interaction_cmp_->AttachToComponent(parent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false)); widget_interaction_cmp_->Init(parent);
widget_interaction_cmp_->Init();
} }
#undef LOCTEXT_NAMESPACE #undef LOCTEXT_NAMESPACE
......
...@@ -18,7 +18,7 @@ class WIDGETINTERACTION_API UVRWidgetInteractionComponent : public UWidgetIntera ...@@ -18,7 +18,7 @@ class WIDGETINTERACTION_API UVRWidgetInteractionComponent : public UWidgetIntera
public: public:
UVRWidgetInteractionComponent(); UVRWidgetInteractionComponent();
void Init(); void Init(USceneComponent * parent);
void SetVisibility(bool visible); void SetVisibility(bool visible);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment