• entries
    116
  • comments
    119
  • views
    104890

Collisions and weapons

Sign in to follow this  

1636 views

Hi,
After quite some time, here comes a new video showing a very early sample of collisions and weapons. What you can see in the video is the player shooting missiles bursts. An enemy spaceship is destroyed by one and others are colliding with a building.

The collisions: in Blender, I define a bounding sphere using a spherical "empty" that allows to specify the location and size of the volume. If there is none defined, a default one is created in the exported file. The game code is meant to accept a hierarchy of bounding spheres but it is not needed right now so the implementation is not complete. Various collision checks are done:
- players / [enemy shots, objects of the visible sectors, objects generated by the layers (trees and rocks in the video)]
- players' shots / [objects of the visible sectors, objects generated by the layers]
- enemies' shots / [objects of the visible sectors, objects generated by the layers]
Enemies / objects collisions are not tested as they will be constrained by fixed paths. It will be easy to add if needed later.
I separated the shots objects to ease the updates and limit the collisions checks to do.

The weapons: for now, only simple missiles are present. They are created at a specific location of the parent object and in a defined direction. After that, they will travel in the same direction. Weapons are described in a separated file with: type, fire rate, burst rate, number of shots per burst, maximum ammo and object ID (it defines the geometry, the collision damages, speed, ...). I have then the following organization to describe an object "template":
- an object (let's say a spaceship) has one or more weapons groups
- a weapons group has one or more weapon instances
- a weapon instance has the matrix for relative position/orientation of the weapon on the object and is referencing a weapon (the one from the weapons file)
- a weapon has the type, fire rate, burst rate, ... and is referencing an object (what the shots will be like)
In the level I can now have:
- an object instance (the player's spaceship) that is referencing an object (the spaceship) and that has weapons states
- a weapon state has the current ammo count, the fire timer, the burst timer, the group active state and is referencing the weapon instance

With this, it is really easy to share descriptions of weapons between objects, it avoids too much duplication of data and is easy to customize. I can have weapons groups with different weapon types, the same weapon at different locations on the parent object, it is ready for new weapons pickup (that is in fact a simple weapons group activation), ... In the video, I did only one weapon group with four times the same weapon around the player.

Next things to do: disable the shots when they are going out of the world boundaries (or after some time), make the enemies use the weapons, other types of weapons like guided missiles, lasers. Mines are already available: I just have to set the shot object speed to zero and I can define a large "empty" in Blender to get something like proximity mines for free.
Thanks for reading.

Sign in to follow this  


2 Comments


Recommended Comments

It sounds like you have a good handle on the weapon solution. The demo is looking pretty good. I love how the ships' shadows flow across the terrain. Nice work.

- Eck

Share this comment


Link to comment

Thanks. I hope the weapons system is versatile enough for what I planned. The challenge will be the laser type but I have something in mind to get it fitted in the system.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now