Search Unity

Question Joint Motor ( more than one axis )

Discussion in 'Physics for ECS' started by MidnightCow, Dec 27, 2022.

  1. MidnightCow

    MidnightCow

    Joined:
    Jun 2, 2017
    Posts:
    30
    I've been trying out joint motors which i was really excited about - the only problem is that it only seems possible to drive on a single axis..

    I've tested by creating a RotationMotor constraint with ConstrainedAxes set to true on all three axis, and the MaxImpulse set to infinity on all three axis, but this appears to not work at all.. The built in helpers PhysicsJoint.CreateRotationalMotor and Constraint.MotorTwist only create a motor on the x axis..

    Has anybody messed with these at all and had any success?

    Ideally i'd like to recreate the X+YZ or Slerp Drive functionality of the ConfigurableJoint, which allows setting a target angle ( on all 3 axis ) that the joint would drive towards ( essentially the classic active ragdoll setup ).
     
    MagiJedi likes this.
  2. MagiJedi

    MagiJedi

    Joined:
    Apr 17, 2020
    Posts:
    32
    Would be really nice to hear about this. Not having a Configurable Joint + (X/Y/Z/Slerp) Drive analogue is a real detriment to creating an Entities-based VR action game.

    Can anyone from Unity comment on this and give us some idea of where this sort of functionality is on the roadmap, so to speak?

    And if I'm missing something, I'd appreciate any pointers. Thanks!
     
    Last edited: Jan 24, 2023
  3. JMPM-UNITY

    JMPM-UNITY

    Unity Technologies

    Joined:
    Jun 16, 2021
    Posts:
    94
    Hey, @MidnightCow and @MagiJedi I have forwarded your queries to the developers of the joint motor. Thank you.
     
    MagiJedi likes this.
  4. schembri-unity

    schembri-unity

    Unity Technologies

    Joined:
    Jul 8, 2020
    Posts:
    14
    Hello. Currently, motors are only supported on a single axis, however, this axis can be oriented in any way. The Physics Demos have examples of this (Assets/Demos/4. Joints/4c. Motors/): https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/PhysicsSamples

    We are constantly improving the Unity.Physics workflow and experience. Which version of Unity.Physics are you using? How are you authoring this motor? I’m interested to learn more about your specific use-case.

    It might be possible to stack individual constraints to create the motor behaviour you want, however, it is also possible (depending on the configuration) that these constraints will fight each other during Solve.

    More detailed information on supported motor authoring can be found in the documentation: https://docs.unity3d.com/Packages/c...al/motor-components.html#the-rotational-motor
     
    MagiJedi likes this.
  5. MagiJedi

    MagiJedi

    Joined:
    Apr 17, 2020
    Posts:
    32
    @schembri-unity

    Thanks for taking the time to reply. In particular, it's precisely the single-axis limitation that is the problem. A use case you could consider is animating an active ragdoll (or even just a more realistic "dead" one). Think shoulder joints, wrist joints, etc...

    I appreciate the links to the documentation, but the part where it discusses this isn't as clear as I'd like it. Can an example or more detailed guidance be provided? Or better yet (and presumably longer-term), add a sample whose purpose is explicitly to mimic a more realistic ragdoll? If I recall correctly, the ragdoll example provided in the Samples is limited to one axis.

    Jumping back to the documentation, it states:
    • Do not stack different motors inside one GameObject component since the baking pipeline may not recognize the setting. For example, if making a motorized Hinge Joint, do not enable both Use Spring and Use Motor. If you want to create multiple motors on one GameObject, you will need to add a new component for each. Note that stacking joints/motors may lead to constraints fighting each other during solve and yield unstable simulation.
    So does this mean that to mimic a wrist, for example, we would need three individual gameobjects/entities in the same location, all hinge-jointed to the same parent & child physics object (forearm & hand, for example), each with their own independent constraints and motors? And presumably jointed to each other as well? This is the kind of guidance or example I think would be wonderful.

    Thanks again for your help!
     
    Last edited: Jan 24, 2023
  6. schembri-unity

    schembri-unity

    Unity Technologies

    Joined:
    Jul 8, 2020
    Posts:
    14
    To make something like a wrist you can use the PhysicsJoint.CreateRagdoll method which combines swing and twist axes. Alternatively, Unity Physics does support authoring via the Character Joint (or Configurable) to bake ragdoll joints. So you shouldn't have to stack 3 individual GameObjects for a wrist-like joint. However, motorized constraints with this configuration hasn’t been sufficiently tested. This is why the documentation warns about this not being supported and suggests stacking joints. I haven’t tried it myself but if you want a motorized CreateRagdoll PhysicsJoint, you could modify the constraints to use a motorized constraint rather than a non-motorized one. This might bring you closer to the behaviour you are looking for in the short-term.

    Ragdoll authoring is definitely something we will improve for future releases. The documentation will also be updated to help with this.
     
    MagiJedi likes this.
  7. MidnightCow

    MidnightCow

    Joined:
    Jun 2, 2017
    Posts:
    30
    @schembri-unity

    Hi sorry i didn't see these replies until now.. Essentially if we could recreate the behavior of ConfigurableJoint's Drive mode that would be the ideal case, for active ragdolls and similar setups - it's a really useful component.

    I spent a good amount of time testing with the new motorized constraint and it's nice to have but doesn't seem to be usable on more than a single axis. Because it will only motorize the x axis what i ended up testing with was three joints ( stacked on each body-body pair ), each with a RotationMotor constraint but with the primary axis of each joints bodyframe pointing to x/y/z respectively. But as suggested it basically fights with itself..

    From memory it might actually have worked for a single parent/child setup such as arm/forearm but when adding an additional joint to the chain for example a hand it has problems. It might also have worked with RotationMotor joints only on two axis, but this isn't really what i need ( as i'm driving the rotations of ragdolls based on animation data ie active ragdolls which really requires all three - like what config joint's Drive settings allow )..

    So i think conceptually, what's needed is for the RotationMotor to drive towards and solve all three axis simultaneously ( again, just like config joint's Drive mode ), within a single constraint so that it's stable.

    Hope that kindof makes sense.
     
  8. MagiJedi

    MagiJedi

    Joined:
    Apr 17, 2020
    Posts:
    32
    @schembri-unity

    The next leap in VR/AR gaming will require a robust solution for active ragdolls. I'm not sure what other priorities the physics team has on their plate, but I would highly encourage increasing the prioritization for this kind of functionality/tooling. ECS is an absolute pleasure to work with, and really the future of Unity for any serious large-scale project, but the lack of a configurable joint analogue is a serious roadblock to delivering on the kinds of experiences needed to truly push VR/AR gaming into the mainstream.

    I've discussed this topic with other developers working with physics-based combat, and many see it as a foregone conclusion that no attention will be paid to this topic as far as ECS goes for a while. I'm hoping this thread can serve as a catalyst to assuage such concerns. It would be great to see some real communication and guidance coming from Unity in terms of a timetable or roadmap on when we can start to see traction on this matter.

    Thanks again for your time!