Skip to content

Replace anchorPoint with Joints #613

Closed

Description

@parasyte

anchorPoint is too basic. It's difficult to use for attachments like Spine, or physics objects like rag dolls, cars, rope bridges, chains, ...

A joint provides three pieces of information:

  1. The anchor point on body A
  2. The anchor point on body B
  3. The type of joint (weld, axel, slide, etc)

The joint is its own class, and it references the bodies (and their anchor points) and type of joint. The joint class could also have its own physics properties, like strength (the amount of force required to turn an axel, or bend a weld...)

me.Body references a list of joints.

I can envision a rag doll created with me.Container, and all of its children (renderables for the body parts) are attached to one another using axel (rotary) joints. Seems like a pretty simple way to use it.

Activity

  1. added this to the milestone on Dec 3, 2014
  2. obiot commented on Dec 5, 2014

    @obiot
    Member

    i'm not familiar with joints, so excuse my question, but would this be used to defined how shapes are attached to a body, or how shapes are related to each other ? also would this apply to how we use anchorpoint today for the position of renderable compared to a object body ?

  3. parasyte commented on Dec 6, 2014

    @parasyte
    CollaboratorAuthor

    I'll refer you to the Chipmunk documentation for an explanation of joint in Chipmunk terms: http://chipmunk-physics.net/release/ChipmunkLatest-Docs/#cpConstraint-Shapes

    For a more general explanation, this is how bodies can be connected to one another. A really simple example is a 2D car. It contains three bodies:

    1. The car chassis, which can be car-shaped, or even just a simple rectangle.
    2. The front wheel.
    3. The rear wheel.

    And this car also contains two joints:

    1. The axel that connects the front wheel to the chassis.
    2. The axel that connects the rear wheel to the chassis.

    The axel joint allows the bodies to rotate in relation to one another. A weld is a "strong" attachment that prevents bodies from moving in relation to one another (a lot like how anchorPoint works today). A slide joint allows bodies to slide a minimum and maximum distance from one another, etc.

    My hope is that we can use these joints to customize how renderables attach to entities and so on. They will be a lot more customizable than anchorPoint is today, because a joint needs TWO anchorPoints; one on each body. Whereas anchorPoint today is a unit value relative to Entity, and it's implied to always be the upper-left corner of the renderable.

    Does this make sense?

  4. locked and limited conversation to collaborators on Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions