User Tools

Site Tools


en:tutorials:physics:z_order_of_objects_with_joints

This is an old revision of the document!


Z-Order of Objects with Joints

This is a very small tutorial, and the main point is going to be this:

Joints use ParentAnchor and ChildAnchor for connecting, however the z coordinate of the Position property is super important for getting the z order of your objects right.

I could leave it there, but I'll show code to illustrate:

[Robot]
Graphic        = RobotGraphic
Position       = (0, 0, 0) ;robot sits at dead centre and 0 z-index
ChildList      = LeftWheel
ChildJointList = WeldLeftWheelJoint
Body           = RobotBody

[RobotGraphic]
Texture = robot-inside.png
Pivot   = center

[RobotBody]
Dynamic  = true
PartList = RobotBodyPart 

[RobotBodyPart]
Type = box
Solid = true

Then for the wheel that attaches to the robot:

[WheelGraphic]
Texture = wheel.png
Pivot   = center

[LeftWheel]
Graphic  = WheelGraphic
Position = (0, 0, -0.5) ; Here's the point. Make the wheel sit on top of the robot.
Body     = LeftWheelBody

[WeldLeftWheelJoint]
Type		= weld
ParentAnchor	= (-50, 40, 0)
ChildAnchor	= (10, 10, 0) ; weld here, but don't bother with the z coord.
Collide		= false

[LeftWheelBody]
Mass     = 10
Density  = 0.5
Dynamic  = true
PartList = LeftWheelBodyPart

[LeftWheelBodyPart]
Type  = box
Solid = true

That should help you ensure the order that joints are drawn.

en/tutorials/physics/z_order_of_objects_with_joints.1598015150.txt.gz · Last modified: 2020/08/21 06:05 (4 years ago) by sausage