acegiak

raycast ignoring static bodies

Jun 14th, 2013
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1.     protected boolean castTopoint(Vector2 start, Vector2 end, float distance ){
  2.         this.rayCastDistance = 1f;
  3.         this.gameScreen.rays.add(new Rectangle(start.x,start.y,end.x,end.y));
  4.         if(start.dst(end) == 0f){
  5.             return false;
  6.         }
  7.         if(this.body != null){
  8.             body.getWorld().rayCast(this, start, end);
  9.         }
  10.         return this.rayCastDistance >= distance;
  11.        
  12.     }
  13.    
  14.     @Override
  15.     public float reportRayFixture(Fixture fixture, Vector2 point,
  16.             Vector2 normal, float fraction) {
  17.         this.rayCastDistance = fraction;
  18.  
  19.         return 0;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment