• entries
    42
  • comments
    139
  • views
    50842

Unity Combat Text, Hits, Misses, Crits, Lasers, and Cannons

Sign in to follow this  
Eck

1474 views

Personal Update:


So last week was my phone screening for an Educational Game Development job. I haven't interviewed in over 8 years, but I passed the screen and my face-to-face is this Tuesday. Early in the week I focused on learning some HTML5 Canvas since that's the technology they're probably going to use. I also worked on the business side of things doing research on setting up my own website and coming up with a name and some ideas for graphics that I'm not ashamed of. Hopefully by next week I'll be able to show them to you.

And Friday the wife and I took our daughter and the neighbor's kid to the zoo for some members only fun. It was a little too hot, but that didn't stop us from having a great time. What's this have to do with game development? Nothin'!

Dev Update:


I made lots of little updates, clean ups, and polish for what I had. I cleaned up my Combat Text system, plugged in a different font, and wired up animations for Hits, Misses, and Critical hits. Hits are red and float down and right. Misses are yellow and float up and left. While crits are red, curve right and up, then do a little pulse and stay on the screen a little longer.

I made a new weapon type "cannon" which shoots projectiles. My laser weapons shoot a continuous beam and plays a looping sound as it fires. The damage is after the firiing sequence is complete. The cannon shoots three three times with a delay between shots playing a shoot sound effect. If the bullets hit, they play a hit sound effect, applies the damage, and disappear immediately. If they miss, they'll travel through the ship and disappear after a short time.

Now that text supports different animations, I made my turn-based battle system start randomizing what happens. For the video, I made the laser and cannon use the same weapon stats. The weapon stats drive a few different things: max range, number of shots, damage, hit chance, etc. I hooked up the stats of the Cannon to both the laser and cannon visuals. So for this video, they both have 3 shots which do 3 damage each, I upped the crit chance to 15% (doubles the damage) so it would happen a little more often for the video and the hit chance is 60%. The battle system rolls up the results when "attack" is pressed. So all three shots are calculated then the AttackResult is handed off to the weapon systems to play out their effects.

[media]
[/media]

Next week, I'll be prepping for my interview more, and trying to get my new web-site up and going. I have no idea how long these things are going to take so I'm going to keep this week's promise of features to a minimum. Once I get the website going, I'll be focusing on cleaning up my Combat Text code, adding a few more features, and document the ins and outs of how to use and extend it.

I probably won't get all of this done this week, but for the new features, I'd like similar damage types to pool up into one object. So if all three shots hit, the animation would start over and show 9 damage (instead of 3). I'm going to try to support both world space and screen space canvases. And I'd like to get nameplates working as well.

Hopefully in a week or two, my Combat Text module will be up on the Asset store. \o/ If you guys have any features you'd like to see, feel free to leave a comment below. smile.png

Tips from your Uncle Eck:


Apparently, there's a limitation in Unity's sound playback. If your sound effects don't begin and end in complete silence, you'll get a staticy pop or other strange side-effects. I wasted an hour or two trying to figure out what I Was doing wrong to find out that it wasn't really my fault. Eventually my googling led me to a post that revealed this truth to me. I opened up Audacity and generated 0.025 seconds of silence and the popping went away.

There are a few tricks to firing a physical projectile from a gun. When the bullet is physical, it will collide with the model itself so you can spawn it outside the barrel and keep it physical, or turn the collision into a trigger so that it doesn't interact with the phsyics system. Both have some issues. If you keep the bullet physical, let's say your ship has a surrounding energy shield... Now your bullet is going to bounce right off your own shield (or a different part of your fancy looking model). On the other hand, if you make the collider a trigger only, you lose out on some of the physics collision system details. Ultimately I decided to make my bullets trigger only and ignore any part of the firing ship.

And to embed the video into your journal link (instead of just posting a link to it) don't use the youtu.be link that the video manager gives you. Otherwise it won't work!
https:
- Don't use this guy.
https:
- Use this guy.


Sound Credits:


Cannon Shoot - http://soundbible.com/1804-M4A1-Single.html

Cannon Hit - http://soundbible.com/107-Bomb-Explosion-1.html

Laser - http://www.trekcore.com/audio/ - TOS Ship Phaser 2
Sign in to follow this  


3 Comments


Recommended Comments

You could also try messing with layers for your bullets, and tune it so that the each faction has it's own bullet layer, that can only hit the enemy layer.  That has some side effects though that may not be worth the pain.

(I did this for a tower defense game, but that obviously works better there)

 

I haven't looked if there is a way to dynamically change the layer an object is on, but that might also work, you could move the shooting ship to a layer that doesn't interact with bullets, then move it back after the attack is finished.  (Or just turn off the shooter's collider, that's probably simpler, and less pain.)

Share this comment


Link to comment

The different layers might work for me. I'm not sure if I want friendly fire or not. If not, I may look more deeply into that idea.

 

Yeah, turning off "the" collider won't work for me. Right now my ships are composed up of several different cubes each with their own collider. Plus I hope to support shields that cover different arcs which would have their own colliders. I could turn off all the colliders for the firing ship, and then turn them back on, but that seems like more hassle than I want to deal with.

 

Thanks for the ideas! :)

Share this comment


Link to comment

Oh, weird, thought popped into my head, rather than turning off the collider for the ship, just turn off the collider for the bullet.  You could have a trigger volume on the root of the ship, and then listen for an OnLeave message and turn the collider on.

 

Though I recall that I had some oddball issues with OnLeave not always firing 100% in older versions of Unity.

 

(And I wouldn't get hung up on it anyway, sometimes my brain just gets hung up on a problem and works on it in it's spare time without telling me.)

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