- Home /
Block child canvas position when moving parent
Since the game I'm working in will have multiple playable characters (you can switch character when you want), I needed to make a canvas, with the health and resources bars, for each character prefab.
The problem is that, since I actually move the parent object's transform with my PlayerContoller script, the canvas and all UI elements I have on it moves as well.
I tried setting the RectTransform of the canvas equal to an empty gameObject's RectTransform which is located inside the canvas for the general UI, through a script that simply assigns on Update() the specific UI canvas RectTransform equal to the one from the empty gameObject.
It worked, but I would like to know if there is a better solution for this.
Your answer
Follow this Question
Related Questions
Making canvas a child of another gameObject 2 Answers
Transform to RectTransform Conversion 1 Answer
Converting to "Rect Transform" permanently deleted part of my project 0 Answers
Setting parent of instantiated sprite 2 Answers
Better way to make big 2D Game. UI Canvas, Transform calculation, animation 0 Answers