- Home /
Adding an object to a character
So I have a juice bar and an avatar, and I know how to attach them via hierarchy but I want it so the juice bar stays while the avatar can move around freely. If you know how to do this please respond it’ll help me out a lot
Answer by Skaster87 · Oct 15, 2017 at 05:32 AM
You don’t want the juice bar to be a child object of the avatar, that will seperate movement. Child objects are subject to the movement of their parent objects.
But the game I upload the avatar to needs it to be attached or it won’t show up .___.
Detach them once they're already in the scene and in the hierarchy. Then you can use the detached object to create a new juicebar prefab.
Let me say it again, the bar needs to be attached to the character hierarchy in order for it to show up in game, I’m wondering if there is anything that can attach the object to the character so that the object stands still and the character moves freely
Attach a script to the juice bar game component and set the transform in the update function.
I.e.
void Update(){ Transform.position = Vector3(0,0,0); }
for the record, if you want to make something parented just say:
transform.parent=othergameobject.transform;
if you want to remove your object from parenting you say:
transform.parent=null;
if you wish to move something independently from it's parent and still keep the parent you can move a either a vector3 variable or empty gameobject around every frame and just move the child to it every frame and repeat the process for rotatian. @Skaster87 is correct. Your situation does not seem to necessitate the silliness im talking about but it works.
Your answer
Follow this Question
Related Questions
How can use the field of view of camera for this object? 0 Answers
Pooling GameObjects with TextMesh ? 0 Answers
Making character respond to traffic light 2 Answers
How to get a dialog box on selecting a 3d object ? 0 Answers
How add and mark next object? 0 Answers