Here’s what I need to obtain, well being bars that keep completely above the models, no matter the place the unit strikes or the place the digicam is: https://www.youtube.com/dwell/fZSaPDz-GJc?si=B868wwF5KAPCuEtw&t=3305
I’ve tried all form of issues, each having my canvas in world-space and screen-space.
In world-space I can’t get my canvas to correctly keep in place above the unit, whereas at all times dealing with the digicam.
rework.rotation = Quaternion.LookRotation(rework.place - Digital camera.primary.rework.place);
I additionally tried with out – Digital camera.primary.rework.place and likewise with + as a substitute, nothing has the specified outcome and I am unable to fairly wrap my mind round how all of this works.
One other factor I attempted is that this, each with and with out the y freeze.
Vector3 ahead = _cam.rework.ahead;
ahead.y = 0;
ahead.Normalize();
healthbarCanvas.rework.ahead = ahead;
This makes the sides of my well being bar go up/down because the digicam strikes, it does not keep horizontal prefer it ought to.
In display screen house I acquired fairly shut, however it’s nonetheless transferring a bit once I’m transferring my digicam and the well being bar additionally will get larger/smaller as I zoom in/out.
public override void OnLateUpdateView()
{
Vector3 offset = new Vector3(0, 3.5f, 0);
Vector3 worldPos = rework.place + offset;
Vector3 screenPos = _cam.WorldToScreenPoint(worldPos);
healthbar.rework.place = screenPos;
}
I’ve tried a number of variations, like freezing the y rotation, freezing the z rotation, however nothing works precisely as I would like it to work.
I need well being bars that keep precisely above my unit because it strikes round in 3D house, no matter digicam place, angle or zoom. Precisely just like the well being bars in League of Legends above the champions and minions work.
As steered I attempted:
rework.rotation = Quaternion.LookRotation(digicam.ahead, digicam.up);
Which ends up in this:
From far:
Somebody within the Unity Discord steered utilizing an Ortographic digicam as a substitute, which does resolve this concern completely.
Is it attainable with a Perspective digicam?