Search Unity

Physics of a rigidbody on a horse

Discussion in 'Scripting' started by steddyman, Aug 12, 2009.

  1. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Is there any way in Unity of having a rigidbody such as a ragdoll character sit on a horse model under the influence of gravity such that if the horse accelerated the ragdoll would be affected by the force, and move back in the seat.

    I would then want to apply force to the ragdoll under the players control to keep him on the horse.

    Thanks
    Steddy
     
  2. mayekol

    mayekol

    Joined:
    Oct 23, 2007
    Posts:
    115
    Have you looked into trying the joints CharacterJoint or SpringJoint? They could be used to connect your player with the horse, that way they should stay connected, while still being affected by the movement of the horse.
     
  3. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Thanks for the response.

    I really want the person to be able to fall off the horse, so not sure that would be appropriate. I want the player to control their balance in the seat using the mouse.

    So really I want the person object to sit on the horse object upright, and if the horse moves for it to impart force onto the person object, which must then be corrected by the user.
     
  4. mayekol

    mayekol

    Joined:
    Oct 23, 2007
    Posts:
    115
    Well you can set the breakForce and breakTorque for a joint based on the force if you wanted the player to be able to fall off the horse (which breaks the joint if a large enough force is applied).

    Otherwise perhaps you could take a reading of the horses velocity (and any additional bouncing movement you wanted to add) and apply that force to the player every couple of fixed updates?

    Some very small values for AddExplosionForce may also be an approach for adding bouncing to the player.
     
  5. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Thanks

    I'll try it with apply forces manually in a fixed update.

    Steddy