playMaker

Author Topic: Creating a Damage Indicator.  (Read 5850 times)

Red

  • Hero Member
  • *****
  • Posts: 563
Creating a Damage Indicator.
« on: March 01, 2013, 01:25:04 PM »
So, the system i had set up would use a spawned game-object with a 3d text on it that would be fed the proper numerical value as a string so that it would give the player an indication of how much damage each particular weapon deals per shot (or explosion, casting, etc.)

Thing is, it got to the point where it was being buried under the effects. works fine for things like a handgun but for a grenade or claymore mine, it's being lost. I was looking at how to change the colour but that still didn't help because the particles for the effects were still rendering above the damage indicator.

as such, i think i'm going to have to re-node the entire thing and start from scratch.

So, i was looking at using the GUI system to help me with that. I've made a working health bar but to be honest i'm not really a fan of that kind of approach (since i feel it adds to some of the tension not knowing specifically how healthy/damaged an enemy is) and having it be displayed and following the enemy is working.

thing is, i've come up against a couple issues which i would like to have some feedback on how to address (and also to help clean up how it's done... spawning X damage indicator objects is a little more intensive than just having a gui system set up for this.)

first would be as follows... How can i make it so that i can change the colour of the gui text? so, this way i can give the player an indicator as to whether they've done regular damage (yellow) or crit-damage (red.) Also, it'd help open the door for when the player recieves healing (same principle/approach but using green instead.)

secondly... How would you animate it? i would like to get an effect similar to how WoW does it (where the text will float upwards and then after a set period, fade away.) The main thing i've been facing is that if i were to use a single GUI object or something like that, it's one object and though i can see how i'd animate it, it would only be one instance of damage and i'm not sure how to really approach it to get all manner of gui text objects doing it.

Thirdly... any cues on how to use something other than the standard text font? Don't get me wrong, the font that's in there currently does work well enough but later on down the road in the development process i'm going to likely want to change the font to something that fits a little better into the visual aesthetic.

So, any and all feedback will certainly be appreciated.

Oh, and to really kick it into third-gear, if there was a way to maybe make the font size reflected to show the general proximity to the screen... so, an enemy that's further away would have a smaller text than an enemy that would be closer.

i do realize this might be a very complicated thing but if we can crack it i'll post screens of how it was achieved so anyone that might face a similar issue can find the solution.
« Last Edit: March 01, 2013, 01:27:56 PM by Red »

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: Creating a Damage Indicator.
« Reply #1 on: March 01, 2013, 01:40:19 PM »
In short (at least unity 3.5) I dont think you can, you would have to change the font colour (would change all text that uses that font) may be different in the new UI if you are using unity 4.

otherwise NGUI might be your answer, you can have your text damage numbers set to different layers and would imagine (I plan to do this myself) that using a 3d camera with ngui you can spawn the text at any position in the world and it will render on top of everything. bad thing if you are shooting around walls and don't want to see the text.

just the limitations of crappy unity UI, PS. with ngui you can set the colour of the text from its script and more so I believe you can set parts of texts colour with html though I have never tried this

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Creating a Damage Indicator.
« Reply #2 on: March 01, 2013, 02:00:08 PM »
hrmm... I was hoping to avoid third-party plug-ins but since they have an evaluation version i think i'm going to have to bite the bullet and try it.

that being said, given that the new UI system for unity 4 is around the corner, i'd be remiss if i purchased it and a month or two down the road the new UI is rolled out to essentially make nGui obsolete.

Though, i guess i'll check out their package (the evaluation version) and see how that goes... besides, i still have a couple months left before i'm ready to release and i guess it is impractical to hedge my bets on the unity devs releasing the expanded GUI system in order to stave off having to have this done.

That being said, if anyone knows of a way to address this natively, please put forward your suggestions... I'm sure i'm not the only one out there that doesn't have nGui (well, not the full version anyway.)

... that said, i might have to see about figuring it out anyway... I keep hearing rave reviews about it and since PM can support it, i'd be interested in seeing just how close PM and nGui are capable of being.

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: Creating a Damage Indicator.
« Reply #3 on: March 01, 2013, 02:29:53 PM »
I felt the same, in the way I wanted to keep the project costs as low as possible.

Using the UI events to PM script over in the nGui thread and the get and set properties I have been able to make great UI's at very little performance cost.

Thus for myself its defo worth the money, it is 1000x better than the current unity UI, though with this in mind the new unity UI looks to address lots of the problems it has, but I am controlling all animations through PM and triggering them with the event to PM scripts.

The only odd thing I have found out with nGui is their automatic height and manual height, get a grip with this (found on the UI root when you create a new UI within nGui) first and it will save you many issues in the future, its fantastic if you know the res your game will be, however I have set it up so the user manually sets this at the beginning to ensure that nothing overlaps or gets cut off.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Creating a Damage Indicator.
« Reply #4 on: March 01, 2013, 03:30:29 PM »
Aaah, yeah... though i'm not planning a mobile roll-out for the game (some of the shaders i'm going to be using are very much mobile-unfriendly since they are using multiple passes and that really drives up the processor cost from what i've been told... not an issue for most desktop systems but it is for mobile apparently) the whole resolution thing might be tricky since i'm going to (aside from webplayer demos) have to take into consideration that the user will be able to determine the resolution (that whole "choose your screen size and performance" option that most Unity builds give you.) Though i'm also looking into if i can add in a "change resolution" option in the options menu, it's still a factor i'll have to consider.

So, given that, would you be willing to show how you may have addressed that? I understand that that might be more an NGui thing than a Playmaker thing (or am i mistaken? don't know... still too new to NGui to know this.) but if you've found a way to address this, sharing your knowledge would be greatly, greatly appreciated.

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: Creating a Damage Indicator.
« Reply #5 on: March 01, 2013, 03:55:40 PM »
Its partially PM but mostly nGui,

I created a nGui slider that sends PM a value (0-1)
multiply this value by the difference between max and min resolution (in my case 760)

added the min resolution to the above number (my case 320)

so 0=320 and 1 = 1080

and then set the manual height based on this number (set property)

I have 2 images, 1 anchored to the left and one anchored to the right

when the screen height changes it moves them further apart or closer together (basically this is just setting the aspect ratio of the screen)

I do this on the first play of the game as mobile resolutions wont change.

This is slightly different for PC and the UI is not as such of a problem with PC's as they have far bigger display area (less ppi) and is easier to say smaller text due to this.

As stated above the manual height is basicly setting the aspect ratio, if its wide screen then the UI anchored to the sides will move further appart, with PC dev I would probably of just designed my UI with the minimal aspect ratio in mind (EG. 1:1 set the unity game window to a 1:1 aspect ratio and make your UI that way as you have far more space to work with on a monitor than a mobile screen)

my way works for me and I find it hard to explain (probably because I dont fully understand how it works too much) if you have found the above confusing would suggest reading up on the feature and playing around with it to see exactly what it does.

here are some screenshots of the setup
« Last Edit: March 01, 2013, 04:01:19 PM by Sjones »