diff --git a/Content/Ray_Material.uasset b/Content/Ray_Material.uasset index 9a2ca1570d5f6f11102c828b041f74a4c1d00b51..4ae373bdf3e090fe996f4c48f4ccfc8ec9555b65 100644 Binary files a/Content/Ray_Material.uasset and b/Content/Ray_Material.uasset differ diff --git a/Content/Ray_Mesh.uasset b/Content/Ray_Mesh.uasset index 594e564fcd76aac35ef8ccac010a813ef6c9ba28..77e19c730861e7a568503abac21893633ea697f9 100644 Binary files a/Content/Ray_Mesh.uasset and b/Content/Ray_Mesh.uasset differ diff --git a/Source/WidgetInteraction/Private/VRWidgetInteractionComponent.cpp b/Source/WidgetInteraction/Private/VRWidgetInteractionComponent.cpp index 54a083659aef59a37620ef6b3af75498d31698db..60ec4ee67cf1a387038965357f619cca1375adbe 100644 --- a/Source/WidgetInteraction/Private/VRWidgetInteractionComponent.cpp +++ b/Source/WidgetInteraction/Private/VRWidgetInteractionComponent.cpp @@ -12,16 +12,18 @@ UVRWidgetInteractionComponent::UVRWidgetInteractionComponent() { 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) { 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); InteractionDistance = 1000000.0f; @@ -32,10 +34,16 @@ void UVRWidgetInteractionComponent::Init() input_cmp->BindAction<FFireDelegate>("Fire", IE_Released, this, &UVRWidgetInteractionComponent::OnFire, false); RegisterComponent(); + InteractionRay->RegisterComponent(); + + if (parent != nullptr) { + InteractionRay->AttachToComponent(parent, FAttachmentTransformRules::KeepRelativeTransform); + this->AttachToComponent(parent, FAttachmentTransformRules::KeepRelativeTransform); + } } void UVRWidgetInteractionComponent::SetVisibility(bool visible) { - bShowDebug = visible; + InteractionRay->SetVisibility(visible); } void UVRWidgetInteractionComponent::OnFire(bool val) diff --git a/Source/WidgetInteraction/Private/WidgetInteraction.cpp b/Source/WidgetInteraction/Private/WidgetInteraction.cpp index f2923cb605affcd938eb9c7f143d554c3398fa1b..1b7b6985c9efb15418a902b8ef068fdd51fab9b8 100644 --- a/Source/WidgetInteraction/Private/WidgetInteraction.cpp +++ b/Source/WidgetInteraction/Private/WidgetInteraction.cpp @@ -65,8 +65,7 @@ UVRWidgetInteractionComponent* FWidgetInteractionModule::GetWidgetInteractionCom void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer) { widget_interaction_cmp_ = NewObject<UVRWidgetInteractionComponent>(outer, UVRWidgetInteractionComponent::StaticClass()); - widget_interaction_cmp_->AttachToComponent(parent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false)); - widget_interaction_cmp_->Init(); + widget_interaction_cmp_->Init(parent); } #undef LOCTEXT_NAMESPACE diff --git a/Source/WidgetInteraction/Public/VRWidgetInteractionComponent.h b/Source/WidgetInteraction/Public/VRWidgetInteractionComponent.h index 74f939500172db1a373ce408605f79fff09c6583..e2f0f4ef9aeb40266a8bbb6cf02a828b7aebc452 100644 --- a/Source/WidgetInteraction/Public/VRWidgetInteractionComponent.h +++ b/Source/WidgetInteraction/Public/VRWidgetInteractionComponent.h @@ -18,7 +18,7 @@ class WIDGETINTERACTION_API UVRWidgetInteractionComponent : public UWidgetIntera public: UVRWidgetInteractionComponent(); - void Init(); + void Init(USceneComponent * parent); void SetVisibility(bool visible);