How to attach a sphere to an object at a constant relative position, but so that it can be influenced by external physics rotations?
Hi! What the title says, but its not so simple. Basically i have a Player parent object, consisting of 2 main child parts: Body and Legs. Body child and its children are animated and controlled through script and that works fine and since i need the body to be upright, i had it parented to the Player object which is a rigidbody and has frozen X and Z rotations. Legs are connected to the Player by a configurable joint so i cant avoid having rigidbodies on both Legs and Player. The joint is needed so the legs would orient according to the terrain by physics, not rotating the Player (and Body) that needs to be upright.
Now comes the problematic part. I'd like to use the spheres as sorts of all-direction wheels and move the player (who is a kind of a mech) by adding force to them, but i cant seem to connect them in a way that lets spheres keep the fixed position relative to the Legs while simultaneously being able to rotate about themselves by physics in all directions. Configurable joints wont work in this case as the motion becomes too jittery and the position/rotation isnt exactly fixed to a spot despite me setting it so in the inspector. its more like "attached with a spring" even though all spring motion values are zero. more the joints, worse the jitter and more offset.
The only way i got the legs in the right position relative to the terrain and player with the spheres attached is by making the spheres children without rigidbodies or joints, just colliders with a zero friction physic material. but, the spheres arent influenced by physics that way and if i add a rigidbody component they just fall off.
Its not exactly necessary for me to apply forces directly to the spheres, but they should at least be influenced by terrain material (friction), so that rotation speed and orientation match the Player movement on terrain.
Additional info, not sure if related: No rigidbodies are kinematic, but have varying mass values. The Player is the parent of this whole object hierarchy and it rotates horizontally (around Y axis) by a script for a smooth and instant upper body control by touch/mouse, even though it has a rigidbody (with locked X and Z rotations so it is upright, which i also set in LateUpdate because it gets offset from physics interactions after a while). i could attach the script for horiz control to the Body part and animate localRotation if this is an issue, but id rather not because this way Player always faces where the Body faces and i can exchange parts of player through script easily like this.
Any help is appreciated. Thanks for reading through the novel ;)