Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. -- Cast the Ray
  2. local hHitObject, nHitDist, nHitSurfaceID, x, y, z, i, j, k = scene.getFirstHitColliderEx ( application.getCurrentUserScene ( ), pX, pY, pZ, 0, -1, 0, 2)
  3. -- If it hits, rotate based on the surfact below.
  4. if ( hHitObject )
  5.     then
  6.         local X, Y, Z  = object.getRotation ( hObject, object.kLocalSpace )
  7.             local eul_x = math.asin ( i )
  8.             local eul_z = math.asin ( k )    
  9.             object.rotateTo ( hObject, -eul_z, this.nAngleY (), -eul_x, object.kGlobalSpace, 0.8)
  10.             log.message ( "RAY HIT! Rotation of Car = "..-eul_z.." "..this.nAngleY ( ).." "..-eul_x )      
  11. else
  12. -- Otherwise stay level
  13.     object.setRotation ( hObject, 0, this.nAngleY ( ), 0, object.kGlobalSpace )
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement