User Tools

Site Tools


en:tutorials:physics:z_order_of_objects_with_joints

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 an example 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

This should help you ensure the drawing order of the objects with joints.

en/tutorials/physics/z_order_of_objects_with_joints.txt · Last modified: 2024/05/07 08:39 (6 months ago) by wise_tamarin