mordentral / VRExpPluginExample

VRE Example Template
https://www.vreue4.com
MIT License
217 stars 84 forks source link

Problem to get `UHandSocketComponent` using the `GetHandSocketComponentFromObject` #18

Closed vahid67 closed 2 years ago

vahid67 commented 2 years ago

Hello, If I attach a hand socket component to another component rather than the root for example a slide component, If I try to get the hand socket component from the owning object of the slide, it can't find the hand socket because the provided function just searches inside directly attached children to the root not all of the children of its children.

For example, I have a gun and it has a slide component (SlideComp) then a hand socket (SlideHandSocket) attached to the slide component, not the root gun, when a hand grips the slide and we try to get the SlideHandSocket by using its owner which is the gun, we can't get access to the SlideHandSocket. Also, we can't use the SlideComp parent which is the hand skeletal mesh at that time.

So the easy fix and actually I tested is this : Just replace AttachChildren = OwningRoot->GetAttachChildren() to OwningRoot->GetChildrenComponents(true, AllChildren);

This can be important if you have animations for multiple components and you don't need to align the hand socket location again for each component.

Thanks for your great work.

mordentral commented 2 years ago

Why would you get it from the owning object of the slide? Its generally intended to be gotten from the gripped object.

IE: Bind to the controllers OnGrip event and break the grip structure and GetHandSocketComponentFromObject from the gripped object.

Your change has potential issues when attaching actors to actors as the hand sockets aren't guaranteed to all be uniquely named then. Although aside from that its not going to hurt much, you generally shouldn't need it.

Unless you mean your slide is purely static mesh just there to visually look like a slide, at that point I could see the use of a bool to allow searching all children maybe, but not as a general global change.

vahid67 commented 2 years ago

Thanks, I found the problem why I could not get the HandSocketComponent from the gripped object. You're right we don't need to read all the components to get the HandSocketComponent. Thanks.