Home > database >  How to freeze location of a child gameObject relative to the father?
How to freeze location of a child gameObject relative to the father?

Time:10-04

how i want it to be

how it looks now

Hello everyone, i have issue in my Untity project.I want that health bar to not spin after his parent object, you can see it in 1 screenshot. But in reality, because it`s childer object, it rotates after his parent, so it is possible to freeze that spin?

CodePudding user response:

Possible solution is to control healthbar rotation every frame. Write a script which will make your health bar always look to the camera. Use

transform.LookAt(cameraPosition);

or

transform.rotation = Quaternion.LookRotation(directionToCamera);

Also, you can separate your health bar from a character and write simple follow script with delta parameter exposed in inspector

  • Related