ios - How to use an SCNTransformConstraint to restrict the Z value of a node? -


i can't seem figure out how constrain z-value of node using scntransformconstraint. here's have far.

        let constraint = scntransformconstraint(inworldspace: true, withblock:{             node, matrix in              var newmatrix = matrix             let currentnode = node scnnode             if (currentnode.presentationnode().position.z > 0.0) {                 newmatrix.m43 = 0.0             }              return newmatrix         })      ship.constraints = [constraint] 

with above constraint, ship doesn't move when apply force physicsbody. appreciated.

yeah. 1 stumped me bit, too.

the issue matrix. according the developer documentation concerning scnmatrix4 (matrix) argument:

if node affected in-progress animation, value reflects visible state of node during animation (rather target state visible when animation completes).

instead of this:

var newmatrix = matrix 

you want:

var newmatrix = node.transform 

which appears current transform applied node.

i know old question, near top of search results scntransformconstraint. hey, better late never, right?


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -