LECTURE:
During today's lecture, we touched a topic about raycasting. I found the topic to be very interesting as it made me understand how somethings, within the games industry, were made. Examples include how crosshairs would change color when you aim at an enemy, how most RTSs (Real Time Strategy Games such as World of Warcraft or the Wargame series) can understand and detect how a player has selected a unit or a group of units to move into a spot. The answer is by using raycasts.
During this lecture, we didn't fully cover raycasts, but we went over on how they work and the logic behind it. A ray consist of a World Space origin, and a direction. It might sound simple, but how do we get the position of a mouse in world space? Well, we have to convert them, like how you would convert fractions when you want to add them together (not really like adding fractions together)
You have 4 different types of spaces:
Object Space - where models are stored in relative to the local point (0,0,0), in most cases, this would be the model's feet
World Space - where your objects are, in relative to the world space origin (0,0,0)
View space
Projection Space - applies either a "Perspective" or "Orthographic" projection to flatten a 3D position onto a 2D screen
The difference between the first two spaces and view space is that the view matrix doesn't transform the cameras position or rotation, however, it moves and rotates the scene by the opposite of the camera, somewhat similar to reciprocation. If you were to move the x axis by 10, the view matrix will move (-10, 0, 0).
To get raycasts to work, you need to get one single projection, which is called the World View Projection. In order to get this WVP, we need to multiply 3 matrices together. If we were to multiply two matrices together, we preserve both transforms.
(WVP = World Matrix * View Matrix * Projection Matrix)
The last part might seem a bit too advances (as warned by the lecturer), but all we need to know after the lecture was how raycasts work, or rather, the logic on how they work. The problem with raycasts is that you would lose some data about the model you're clicking at, as you're essentially turning that 3D object, into a 2D object onto the screen ultimately losing the Z axis information.
SETBACKS:
From the milestone I set myself for last week, I have encountered quite a few setbacks concerning the turrets. I tried making a turret, where it would look at the enemy entering its range, and shooting at it as it passes by. I underestimated this and found that I haven't got my turrets to work. It wouldn't look at the enemies as it passed by the turret, and it wouldn't shoot at the enemy, instead, it would shoot up at the sky. I tried taking a look at some tutorials online, but most of them included mathematical functions which I'm not familiar to, in coding terms to be precise.
ACHIEVEMENTS:
In every grey cloud, there is always a silver lining somewhere. The silver lining for this week is that I have managed to get a map, the enemy waypoint system to work, one type of enemy, and a player! Currently, I have managed to get the enemies to move along a waypoint system throughout their path, and a player object where you can shoot and build turrets with.
MILESTONES:
The milestone for next week are:
To find someway to implement a raycasting system into the game, where the player would click on a node and a turret would be built wherever the player clicked
To fix the turrets
To add some more enemies and some effects into the game
To make the game more challenging and fun to play
During today's lecture, we touched a topic about raycasting. I found the topic to be very interesting as it made me understand how somethings, within the games industry, were made. Examples include how crosshairs would change color when you aim at an enemy, how most RTSs (Real Time Strategy Games such as World of Warcraft or the Wargame series) can understand and detect how a player has selected a unit or a group of units to move into a spot. The answer is by using raycasts.
During this lecture, we didn't fully cover raycasts, but we went over on how they work and the logic behind it. A ray consist of a World Space origin, and a direction. It might sound simple, but how do we get the position of a mouse in world space? Well, we have to convert them, like how you would convert fractions when you want to add them together (not really like adding fractions together)
You have 4 different types of spaces:
Object Space - where models are stored in relative to the local point (0,0,0), in most cases, this would be the model's feet
World Space - where your objects are, in relative to the world space origin (0,0,0)
View space
Projection Space - applies either a "Perspective" or "Orthographic" projection to flatten a 3D position onto a 2D screen
The difference between the first two spaces and view space is that the view matrix doesn't transform the cameras position or rotation, however, it moves and rotates the scene by the opposite of the camera, somewhat similar to reciprocation. If you were to move the x axis by 10, the view matrix will move (-10, 0, 0).
To get raycasts to work, you need to get one single projection, which is called the World View Projection. In order to get this WVP, we need to multiply 3 matrices together. If we were to multiply two matrices together, we preserve both transforms.
(WVP = World Matrix * View Matrix * Projection Matrix)
The last part might seem a bit too advances (as warned by the lecturer), but all we need to know after the lecture was how raycasts work, or rather, the logic on how they work. The problem with raycasts is that you would lose some data about the model you're clicking at, as you're essentially turning that 3D object, into a 2D object onto the screen ultimately losing the Z axis information.
SETBACKS:
From the milestone I set myself for last week, I have encountered quite a few setbacks concerning the turrets. I tried making a turret, where it would look at the enemy entering its range, and shooting at it as it passes by. I underestimated this and found that I haven't got my turrets to work. It wouldn't look at the enemies as it passed by the turret, and it wouldn't shoot at the enemy, instead, it would shoot up at the sky. I tried taking a look at some tutorials online, but most of them included mathematical functions which I'm not familiar to, in coding terms to be precise.
ACHIEVEMENTS:
In every grey cloud, there is always a silver lining somewhere. The silver lining for this week is that I have managed to get a map, the enemy waypoint system to work, one type of enemy, and a player! Currently, I have managed to get the enemies to move along a waypoint system throughout their path, and a player object where you can shoot and build turrets with.
MILESTONES:
The milestone for next week are:
To find someway to implement a raycasting system into the game, where the player would click on a node and a turret would be built wherever the player clicked
To fix the turrets
To add some more enemies and some effects into the game
To make the game more challenging and fun to play
No comments:
Post a Comment