Staff Conversation: Ray Casting In Corona SDK

Staff Conversation: Ray Casting In Corona SDK

In this second edition of our new weekly Staff Conversations segment, Corona Labs Core Engineer, Albert Yale talks about ray casting and how it can be used to probe the properties of a world and how it can be used to make game AI smarter. Albert also tells us what we need to know to implement the new Corona physics.rayCast method in games starting with Corona SDK Daily Build 1080.

If you missed the very first Staff Conversations video, be sure to watch David Rangel talk about Corona SDK Starter and the upcoming enhancements to Corona SDK Pro.

We hope you enjoy the new segments. If you have topic suggestions for upcoming Staff Conversations, be sure to leave them in the Corona Geek forum.

Thanks for watching!

Listen and Rate

Charles McKeever
[email protected]

Charles McKeever is a life long computer geek who enjoys exploring technologies to understand how they work, how they can be smashed together, and how they can be used to fuel entrepreneurial endeavors.

7 Comments
  • Jacques
    Posted at 23:59h, 16 April

    Just have to see this is a life-saver for me! As well as the upcoming graphics 2 which i hope will come out soon. My new game War of the Zombie relies heavily on detecting possible bullet collisions before a marine fires the actual shot and before the player actually gets to witness it.

    So if i understand correctly, with raycast, I can NOW fire out an invisible line to check if a potential bullet would hit a building or tree or a zombie directly and then stop the marine from firing if the bullet wouldn’t reach the zombie? As right now i have to fire off an invisible physics object (fake sensor bullet if you like) and only if the zombie object is hit and nothing else will the player see the action (which is naturally a waste of cpu).

    If my assumption is correct how much different in terms of speed and CPU usage would a raycast line take compared to firing off a ‘sensor’ physics object? If its gonna be way better then you guys have done an awesome job bring in raycasting.

    Lastly, how easy would it be (or i should say memory/cpu intensive) would it be to use the raycast for casting shadows in corona?

    • Albert
      Posted at 10:47h, 17 April

      @Jacques: Ray casting is less expensive than sensors, and is generally easier to manage.

      The impact on performance varies greatly with the type of game.

      A simple way to use ray casting for shadows is to find the ground position under a character and place a shadow blob texture at that position.

      btw, take a look at physics.reflectRay() in the latest daily build (1087). It’s pretty fun to play with.

  • Jacques
    Posted at 02:17h, 17 April

    Apologies for the double post previously (perhaps you can indicate whether a post has been received?).
    Anyway, just want to let you guys know that the new raycast api is awesome! Works perfectly for War of the Zombie, and is definitely a game-changer!
    Not sure how much raycasting collision detection alleviates memory/cpu over ‘sensor’ physics objects collision detection but everything is running sweet!

  • Chris Leyton
    Posted at 02:51h, 17 April

    Hey Charles – great to see these, I think it helps to add a further layer of explanation to new features beyond what’s contained in the docs. Hoping you follow a similar concept for further additional features that are added to Corona.

    In terms of new topics, I’d like to see you focus on advanced topics – we all know Corona is simple to use, anybody can pick it up, etc…

    But I think to continue giving credit to Corona as a serious framework we need to see the more tricker topics handled – things like AI implementations, game logic, etc… Generally pushing the Corona limits. Hoping we’ll see lots on Graphics 2.0 when it’s released.

    • Jacques
      Posted at 03:14h, 17 April

      I totally agree about the AI and game logic implementation, 75% of my code is AI and game logic.

    • Charles McKeever
      Posted at 08:59h, 18 April

      I agree Chris. We will work on adding more technical session to the list.

Post A Comment