Damage Popup

Gugbert

New member
I didn't find a word in the documentation about the damage popup stuff, so I did some trial and error and examined the code.
What i did:
- add a DamagePopupManager script to the 'Game' gameObject
- created a prefab consisting of a Canvas and a UI-Text object, added DamagePopup script to the canvas object
- set the DamagePopupManager ID in the 'Health' component

Basically it works, but the damage pops up always in the center of the screen whatever offset I use in the DamagePopup component.
Am I on the wrong track with this setup, or is there an easy change to make it work?
 

Attachments

  • DamagePopup1.JPG
    DamagePopup1.JPG
    161.4 KB · Views: 29
  • DamagePopup2.JPG
    DamagePopup2.JPG
    99.2 KB · Views: 28
Can you put a debug statement in the Update function of the DamagePopupBase class to log m_Position, m_Offset, and the transform position?
 
Thank you for the quick response.
The values seem reasonable. Resolution is set to 1980x1080.
The position is the exact position of the character taking the damage.
 

Attachments

  • DamagePopup3b.JPG
    DamagePopup3b.JPG
    66 KB · Views: 8
I am not sure. Seems that the calculation of the position is correct, but rendering happens before the transform is re-positioned, so it takes the original transform into account (middle of the screen). I will ask Justin.
 
What I just noticed is the following. Before the new position is calculated the position is always the center of the screen. But the DamagePopup never resets the transform. So there has to be another script that resets the transform every frame. And this happens after the new position has been calculated, so it will always appear in the middle of the screen. So, you should check what other script could cause this.
 
I noticed that, too. But I didn't find a clue, what causes the reset.
This is an almost clean project, only UCC 2.4.5, UIS 1.2.6 and the integration package 2.0.7 ( latest )
But there is nothing additional accessing the Damage Popup object in any way.
 
The damage popup is not part of the character controller, tagging @Sangemdoko to see if it is designed to be able to work with it.
 
The scripts are part of the UCC. This scenario can be setup with the UCC only.
Edit: I'm going to setup a clean UCC only project later.
 
Last edited:
So I setup this scenario UCC only with minimal steps, only two characters, one sword and the DamagePopup prefab, same result.
As said I had no documentation and I'm not sure if my setup is the intended one.
 
Hi Gugbert,
I was the one that wrote this feature. It's very simple in what it can achieve. It was a feature I added while working on the Adventure kit and thought it would be a nice addition to base UCC.

The way it works is that each DamagePopup prefab is a Rectranform, not a canvas.

So you have a screen space Canvas with the DamagePopupManager on it. And the DamagePopup rectTransforms spawn as children and move during update.

So here is an example of the DamagepopupManager:
1644853157213.png

And here is an example of a DamagePopUp prefab
1644853214090.png

A cool thing about this feature is that you create a custom DamagePopup class to override the Open(damageData) function which allow you to display thing differently depending on the contents of the damageData. For example damageData could be custom class or you can pass in data within the damageData.UserData property. I plan on doing something around those lines to add random luck critical hits in the Adventure Kit damage procressor, which display a bigger damage popup.

If you have any feedback on this feature it is very welcomed. I'll add it in the documentation once I believe it is closer to its final form.
 
Hi Sangemdoko, thank you, I got this to work in less than 5 minutes with the instructions above.
Problem solved :)

Feedback:
The offset seems to be added in global space, while this is not a big thing if your offset has only a Y component, but if you have an X offset, display position depends on the side you are attacking.
 
I was also able to get the Damage Popup working as well but I was wondering about getting the headshot indicator to display with this. How can I do this?
 
Unfortunatly those two features do not work together by default. it must be done using custom code.
In UCC V3 I'll see if I can improve damage indicators to make it more extensible.

Sorry for the inconvinience.
 
Top