Tuesday, October 15, 2013

Corona raycasting

Working on Corona and Lua for first time, and taking on a new type of a game is proving to be challenging, and at the same time rewarding. In the game, there is emphasis on connecting objects with a straight line, without any obstacles in-between. The technique used to determine there is nothing in between is called Ray Casting.

The information about API is here: http://docs.coronalabs.com/daily/api/library/physics/rayCast.html, but it does not quite describe how useful the API is. My previous attempt at solving the problem was to use collision detection by drawing a line between two objects, which was a wrong approach, but it seemed like a good solution at the time, because other parts of the game use collision detection.

Ray casting returns all the objects which are on the line from x1,y1 to x2,y2. I almost want to call it line of sight, however line of sight is more of a cone than a single ray.

No comments:

Post a Comment