Jump to content
  • Advertisement
  • entries
    59
  • comments
    86
  • views
    40764

Bullet logic & creation of a lowpoly robot

Sign in to follow this  
Ph4nt0m

2385 views

[color=rgb(62,62,62)][font=Merriweather]

[font=arial]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. [/font][font=arial]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.[/font]

[/font][/color]
[color=rgb(62,62,62)][font=Merriweather]

[font=arial]Here is an ugly paint sketch:[/font]

[/font][/color]

bullet-logic-standard-floatlands.png
[font=arial](standard bullet logic)[/font]

[color=rgb(62,62,62)][font=Merriweather]

[font=arial]

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.

[/font][/font][/color]

basic-raycast-lowpoly-floatlands.png
[font=arial](implementation of basic raycasting system)[/font]

[font=arial]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.[/font]

gravity-affected-bullet-floatlands.png
[font=arial](Gravity affected bullet)[/font]

[font=arial]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:[/font]

drone-attack-lowpoly-floatlands.png

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

[font=arial]

http://floatlands.net/

[/font]

Sign in to follow this  


2 Comments


Recommended Comments

Why raycast in every direction for volume as opposed to using a spherecast?  I would think the spherecast would be more performant, since you only have to do one check, but would be interested to see if that held true or not.

 

(Also, I'm guessing you tried the standard rigid body for bullets and found them lacking, you don't mention it, but it's not surprising, since that seems to be a common issue with Unity's physics)

Share this comment


Link to comment

We agree, it was just the first iteration of programming this and the programmer expanded it since then. I'll post an update regarding bullets soon.

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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!