User Tools

Site Tools


en:tutorials:physics:creating_an_insect_object

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:tutorials:physics:creating_an_insect_object [2024/05/07 22:12 (5 months ago)] – Fixed config + migrated to "new" animation system iarwainen:tutorials:physics:creating_an_insect_object [2024/05/08 00:09 (5 months ago)] (current) – Typo fix iarwain
Line 11: Line 11:
 <code ini> <code ini>
 [Physics] [Physics]
-Gravity             = (0.0, 1000.0, 0.0)   +Gravity         = (0, 1000)   
 </code> </code>
  
Line 19: Line 19:
 [InsectObject] [InsectObject]
 AnimationSet    = InsectAnimationSet AnimationSet    = InsectAnimationSet
-Position        = (400, 300, -0.1) 
 Body            = InsectBody Body            = InsectBody
 ChildList       = InsectWeightObject ChildList       = InsectWeightObject
Line 27: Line 26:
 </code> </code>
  
-Next the animation so that the insect beats his wings over and over:+Next the animation so that the insect beats its wings over and over:
  
 <code ini> <code ini>
 [InsectAnimationSet] [InsectAnimationSet]
 Texture         = insect-drone.png Texture         = insect-drone.png
-FrameSize       = (157, 122, 0)+FrameSize       = (157, 122)
 KeyDuration     = 0.01 KeyDuration     = 0.01
 StartAnim       = Fly StartAnim       = Fly
Line 66: Line 65:
 [InsectWeightObject] [InsectWeightObject]
 Body            = InsectWeightBody Body            = InsectWeightBody
-Position        = (-20, 80) 
  
 [InsectWeightBody] [InsectWeightBody]
Line 84: Line 82:
 [InsectBodyRevoluteJoint] [InsectBodyRevoluteJoint]
 Type            = revolute Type            = revolute
-ParentAnchor    = (055+ParentAnchor    = (78.5200;Keep the anchor a good distance below the insect object 
-ChildAnchor     = (0, -10)+ChildAnchor     = (0, 0)
 </code> </code>
  
 Notice the weight body is dynamic so it will be affected by gravity. The physics will be pushing down on the weight, but the speed movements of the insect will compensate and create more randomness to the movement. The revolute joint will keep the weighted object at the bottom, eventually straightening the insect if it is upside down.  Notice the weight body is dynamic so it will be affected by gravity. The physics will be pushing down on the weight, but the speed movements of the insect will compensate and create more randomness to the movement. The revolute joint will keep the weighted object at the bottom, eventually straightening the insect if it is upside down. 
- 
-With the joint, it has been set so that the weight object can pass thought the insect using //Collide = false// if they collide.  
  
 If the insect flies off the screen, we may never see it again. So perhaps a border around the screen is in order. That will keep the insect on the screen: If the insect flies off the screen, we may never see it again. So perhaps a border around the screen is in order. That will keep the insect on the screen:
Line 97: Line 93:
 [Border] [Border]
 Body            = BorderBody Body            = BorderBody
-Position        = (00)+Position        = (-400-300;top-left of the border area
  
 [BorderBody] [BorderBody]
Line 146: Line 142:
 [InsectBodyPart] [InsectBodyPart]
 Type            = box Type            = box
-TopLeft         = (-78.5-31) +TopLeft         = (0, 31) 
-BottomRight     = (78.561)+BottomRight     = (157122)
 SelfFlags       = insect SelfFlags       = insect
 CheckMask       = border CheckMask       = border
Line 153: Line 149:
 Friction        = 0.9 Friction        = 0.9
 Density         = 1.0 Density         = 1.0
 +Solid           = true
 </code> </code>
  
-{{ tutorials:animation:insect.gif |}} +And run that up. The insect should be fluttering nicely around the place. You can run with ''ShowDebug = true'' in the ''[Physics]'' section, and can check how the weight object is interacting with the insect object
  
-And run that up. The insect should be fluttering nicely around the place.+{{ tutorials:animation:insect.gif?|}} {{ :tutorials:animation:screenshot_2024-05-08_115748.png?450   |}}
en/tutorials/physics/creating_an_insect_object.1715145177.txt.gz · Last modified: 2024/05/07 22:12 (5 months ago) by iarwain