Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(5 edits) (+2)

Bullet logic & lowpoly robot design


Hey, Domen here. My task was to create at least a reasonable bullet logic which is "kinda" realistic. For starters lets define what a bullet is. For the first N metres (or any other unit) the bullet reacts and is defined as a raycast from an origin point to a direction – in most cases a gun barrel or the middle of the screen (crosshair position). If nothing is hit then proceed with so called partly raycasts – cast a short raycast and if nothing happens move the origin of the previous ray to an end position of that ray.

Here is an ugly paint sketch:


(standard bullet logic)

This got me quite a satisfying result but I wasn't happy with it. Bullet isn't only a ray, it has a volume and there is also gravity that affects the movement of the bullet.

(implementation of basic raycasting system)

The next thing was to implement basic gravity impact to the bullet. I also moved every physics call to the FixedUpdate() so the Unity physics has the time to refresh itself. I also added a simple TTL (Time to live) system, so the bullet "dies" at about 25 raycasts.


(gravity affected bullet)


Here is an example of an instant raycast (black ray) and the partly raycasts (red) which are affected by the gravity, kinda heavy bullet eh? The next stop was implementing the volume of the bullet, which is a simple raycast towards every directon. We can now change the gravity affection, bullet spread, bullet time to live and bullet speed, which is nice if we want to implement some sort of mortars, snipers, or weak pistols. Aaaaand the final result:


Our 3D artist also recorded the workflow of creating a lowpoly robot in Blender. Enjoy!



http://floatlands.net