Advertisement
djhonga2001

Raycast example = Mafins

Oct 25th, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // The type can be:
  2. // Everything = -1
  3. // Peds = 12
  4. // Objects = 16
  5.  
  6. int type = -1; // Everything
  7.  
  8. _CAST_RAY_POINT_TO_POINT(source.x, source.y, source.z, target.x, target.y, target.z, type, 0, 7)); // the target would usually be a long distance from the source in the direction you want
  9.  
  10. int hitsomething = 0;
  11. int entityhandle = 0;
  12. Vector3 hitCoords, surfaceNormal;
  13.  
  14. int result = _GET_RAYCAST_RESULT(handle, &hitsomething, &hitCoords, &surfaceNormal, &entityhandle);
  15.  
  16. if(hitsomething != 0) // only execute if ray successfully hit something
  17. {
  18.  
  19. if(DOES_ENTITY_EXIST(entityhandle)) // if the ray hit an entity
  20. {
  21. // any entity type checks here
  22. // code here
  23. // use entityhandle
  24. }
  25. else // if the ray hit anything other than an entity
  26. {
  27. // code here
  28. // use hitCoords
  29. }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement