This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
dragengine:modules:dragonscript:locomotion [2017/02/22 15:32] – [Player Input Tracker] dragonlord | dragengine:modules:dragonscript:locomotion [2019/05/08 17:30] – dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
[[: | [[: | ||
Line 153: | Line 154: | ||
< | < | ||
- | // set up locomotion body tilt for an actor using the weighted method | + | func void init() |
- | locomotion.setTiltMode( Locomotion.TILT_WEIGHTED ) | + | |
- | + | locomotion.setTiltMode( Locomotion.TILT_WEIGHTED ) | |
- | // create collision filter shared by all tests | + | |
- | var LayerMask category = LayerMask.new() | + | // create collision filter shared by all tests |
- | category.setBit( GameState.CL_AI ) // we are an collider for doing actor ai | + | var LayerMask category = LayerMask.new() |
- | + | category.setBit( GameState.CL_AI ) // we are an collider for doing actor ai | |
- | var LayerMask filter = LayerMask.new() | + | |
- | filter.setBit( GameState.CL_GEOMETRY ) // we can hit geometry like the ground | + | var LayerMask filter = LayerMask.new() |
- | filter.setBit( GameState.CL_AI ) // we can hit other actor ai colliders | + | filter.setBit( GameState.CL_GEOMETRY ) // we can hit geometry like the ground |
- | + | filter.setBit( GameState.CL_AI ) // we can hit other actor ai colliders | |
- | var CollisionFilter collisionFilter = CollisionFilter.new( category, filter ) | + | |
- | + | var CollisionFilter collisionFilter = CollisionFilter.new( category, filter ) | |
- | // set collision test. the test points are located above the ground since otherwise tilting up can not | + | |
- | // be detected. as a rule of thumb the test distance should be two times the start height. for each | + | // set collision test. the test points are located above the ground since otherwise tilting up can not |
- | // test a ray test is used. this is the fastest solution and works well for most situations. | + | // be detected. as a rule of thumb the test distance should be two times the start height. for each |
- | var float offset = 0.5 // height above ground to start testing | + | // test a ray test is used. this is the fastest solution and works well for most situations. |
- | var Vector testDistance = Vector.new( 0.0, -offset * 2.0, 0.0 ) // distance to test downwards | + | var float offset = 0.5 // height above ground to start testing |
- | + | var Vector testDistance = Vector.new( 0.0, -offset * 2.0, 0.0 ) // distance to test downwards | |
- | locomotion.setCCTTiltFrontLeft( ColliderCollisionTest.new( touchSensor, | + | |
- | collisionFilter, | + | locomotion.setCCTTiltFrontLeft( ColliderCollisionTest.new( touchSensor, |
- | + | collisionFilter, | |
- | locomotion.setCCTTiltFrontRight( ColliderCollisionTest.new( touchSensor, | + | locomotion.setCCTTiltFrontRight( ColliderCollisionTest.new( touchSensor, |
- | collisionFilter, | + | collisionFilter, |
- | + | locomotion.setCCTTiltBackLeft( ColliderCollisionTest.new( touchSensor, | |
- | locomotion.setCCTTiltBackLeft( ColliderCollisionTest.new( touchSensor, | + | collisionFilter, |
- | collisionFilter, | + | locomotion.setCCTTiltBackRight( ColliderCollisionTest.new( touchSensor, |
- | + | collisionFilter, | |
- | locomotion.setCCTTiltBackRight( ColliderCollisionTest.new( touchSensor, | + | |
- | collisionFilter, | + | // add mappings so our animator uses the calculated values |
- | + | locomotion.addControllerMaping( controllerTiltOffset, | |
- | // add mappings so our animator uses the calculated values | + | locomotion.addControllerMaping( controllerTiltUpDown, |
- | locomotion.addControllerMaping( controllerTiltOffset, | + | locomotion.addControllerMaping( controllerTiltLeftRight, |
- | locomotion.addControllerMaping( controllerTiltUpDown, | + | end |
- | locomotion.addControllerMaping( controllerTiltLeftRight, | + | |
// tilt is enabled so during Element.postThink the tilt is updated automatically and the result | // tilt is enabled so during Element.postThink the tilt is updated automatically and the result | ||
// applied to animator instance controllers | // applied to animator instance controllers | ||
- | locomotion.updatePostLocomotion( | + | func void postThink( float elapsedFrameTime ) |
+ | | ||
+ | end | ||
</ | </ | ||