itch.io is community of indie game creators and players

Devlogs

Week 4 - Tutorial

UTAS KIT207 Portfolio
A downloadable game

You may also notice that enemies only appear when I click somewhere in the world - this is being done through Raycasting. A Raycast is simply a line which starts from a  given point and continues infinitely in a particular direction (unless a distance limit is specified). This line can intersect any number of objects in the world, and can even store those objects along with the coordinates at which the collision took place. In this case, every time I click, a ray is being cast from the camera's position to where the mouse is positioned inside the world (keeping in mind that the position which the mouse occupies on the screen needs to be translated into a position inside the game world). This ray could potentially intersect any number of objects, but here we only want the very first object which it collides with - which should hopefully be some part of the ground. The coordinates of this collision are then used to create an enemy object at that position.

Leave a comment