- Home /
Canvas in World Space
Hi everyone,
I have an enemy (thank you asset store) that has a healthbar. Every enemy has his own canvas where the bar will appear on. If the enemy is alive, he will be looking at me and the canvas will always be facing me. BUT when the enemy dies I don't want him to rotate around on the floor, so I stop the LookAt function which will cause the canvas to stop facing the camera. The canvas is a child of the enemy.
How can I get my canvas to always be facing the camera , till it gets destroyd?
I think that stacking Canvasses and having one per enemy is not a good idea.
You should have one Canvas and have it interact with all enemies.
The point here is that the Canvas links in to everything with the Event System so there is no need to have it as a child.
As an example, I have multiple Aircraft Carriers of which the player ship is teleported to at the start or on respawn. The Active carrier pokes the (single) Canvas and takes control of the Launch button. Pushing the button with launch the ship from that one carrier alone. The theory goes here that you can only be docked at one at a time so they can share a button.
Of course, Im not sure what your situation is here but if you can achieve something similar it will be to your advantage and save a lot of processing.
Answer by M-Hanssen · Aug 18, 2016 at 10:55 AM
Call the LookAt method on the canvas only and not the entire enemy
if I put it on the canvas only, it will also rotate the player
Your answer
Follow this Question
Related Questions
I cannot see button on camera preview 1 Answer
How to instantiate a prefab between Canvas and a Button? 0 Answers
Raycast from 2D canvas object to world space 1 Answer
How to make a Panel (Or Scrollbar) Appear on Button Click 0 Answers
Issues with world space canvas for different resolutions. Any Workaround ? 0 Answers