Projectiles

posted in trill41 for project ABx
Published July 28, 2019
Advertisement

Projectiles

Unfortunately Bows and Spears already existed in ancient Greece, so I had to implement something that feels like a projectile. Projectiles are fast moving Actors heading towards a target. If they hit the target it damages the target. Like in other online RPGs a projectile can not hit the wrong target, it either hits the desired target or it misses it. Projectiles have some special problems.

Problems

  1. They are fast moving,
  2. they fly,
  3. the target can be obstructed.

Fast moving

The game may not check if the projectile collides with the target, because it runs only 20 game updates per second, and that is by far too low. The projectile will just fly through the target and the game won't even notice. So it must approximate if the projectile would hit the target.

For now I solved this as follows. If the distance to the target is increasing, check if it's lower than a threshold, which also considers the moving speed. Also projectiles may move with a different speed.

Flying

All actors stick to the ground, except projectiles, so they need some special treatment. Unlike other actors, projectiles also move along the Y axis.

Obstacles

If the target is behind an obstacle, the projectile can not hit it. This applies also for the terrain, e.g. when the target hides behind a hill. The Terrain is not a regular game object and is not considered in a Raycast query. But there are Terrain patches, which are regular game objects, and therefore are in an octand of the octree, so a Raycast query will return Terrain patches.

In the picture bellow we can see that Bob can shoot at Alice, but he will not hit her, because Terrain Patch 2 in in the way.

projectile.thumb.png.29ab191c4b247c3947c1aec074527a33.png

Unlike other game objects, a Terrain patch can not use its bounding box, because it would be too big, see bellow. Terrain patches must use the height values of the terrain to check if the ray collides.

tpbb.thumb.png.436e09e3620e709b571eb7c628a8b0bf.png

Game mechanic considerations

If you ever threw an ashtray after a fly you know that hitting a moving target is really hard. So the player will need some assistance from the game to make it easier, or nobody would ever use projectiles. In this game a projectile will always hit the target, even when the target is moving. A target can dodge when the target is changing the move direction after the projectile started.

Area of Effect

As the name implies, this is a place which has an effect on the actors inside. The screenshot bellow shows such an area of effect, it's some toxic mushrooms that damages and poisons actors in it.

toxic_mushrooms.thumb.jpg.288d1bcc2a74194f49b7b67c26791e10.jpg

Other use cases are Traps, effects that are spawend by skills, e.g. skills that make damage in a certain range over time, etc.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement