Hi guys, please help me understand nested components.
I want to create a character (VRCharacter) with two components created in C++ for left and right hand, of the same type, let it be VRMotionControllerComponent.
In this component I create a mesh and attach a spline (or several splines) to it.
After that I create a blueprint inherited from the character class, I see that in the tree all components are added as intended.
But when I move the mesh in the viewport, the spline stays in place, even though it is a child of the mesh.
Thansk for u time bro, but you have added both components to the actor class. My situation is a little different. I have a VRMotionController component in the actor, and the meshes and spline are already in it. Please look at the screenshots in the first post carefully.
Character -> VRMotionController Component -> Mesh Component
-------------------------------------------> Spline Component
Thanks man! Actually there is no need to use MotionControllerComponent, similar situation if you inherit a class from UChildActorComponent or UActorComponent, no difference.
Made a child actor attached to character mesh.
Child actor is a skeletal mesh with attached spline.
Added in motion and spline follows the mesh in the child actor from within a character no problem.
Thanks for helping me figure it out and spending your time! The thing is, the problem only occurs when you do everything in C++. I have recorded a video where you can see the problem.
It must be motion controller related.
My project was also pure c++ and nothing like that happened during motion.
The hand mesh looks almost like it’s getting a double transform while in motion.
The motion controller itself also has no transform node if you haven’t noticed. Only scale is accessible.
I’ll need to do a test directly with the motion controller.
Also I noticed you are using live coding. Maybe it is interfering with the correct compile. Lot’s of things break with it as many elements do not support proper hot reloading. Try disabling live coding, closing the project and doing a proper recompile.
Ok looking at the example in the engine XRCreativeAvatar.cpp it has the character and it’s controllers and meshes all created inside of the character itself.
The splines and hands follow the controllers in this config.
I’m guessing the SetupAttachment(this) inside of the motioncontroller was the fail point. Maybe it’s not ready during the motion controllers CDO.
Maybe setting an attachment another point of init it might work in InitializeComponent?
Anyway the upper code works ok though it is a little less flexible.
Edit:
after scouring some of the ue source code it seems you can override the OnRegister function and setup the attachments there, but it has it’s pitfalls (you need some extra safeguards) and haven’t tested it out yet in packed projects.
I was able to do what I wanted with the ChildActorComponent. But one problem remains, the motion controllers are now fixed at one point and do not move with the joysticks, any ideas?
For both hands, of course. Triggers work, movements don’t, I think this is due to the way the transformation node works when using ChildActorComponent. Apparently it is overwritten with other values somewhere.