Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Cast the Ray
- local hHitObject, nHitDist, nHitSurfaceID, x, y, z, i, j, k = scene.getFirstHitColliderEx ( application.getCurrentUserScene ( ), pX, pY, pZ, 0, -1, 0, 2)
- -- If it hits, rotate based on the surfact below.
- if ( hHitObject )
- then
- local X, Y, Z = object.getRotation ( hObject, object.kLocalSpace )
- local eul_x = math.asin ( i )
- local eul_z = math.asin ( k )
- object.rotateTo ( hObject, -eul_z, this.nAngleY (), -eul_x, object.kGlobalSpace, 0.8)
- log.message ( "RAY HIT! Rotation of Car = "..-eul_z.." "..this.nAngleY ( ).." "..-eul_x )
- else
- -- Otherwise stay level
- object.setRotation ( hObject, 0, this.nAngleY ( ), 0, object.kGlobalSpace )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement