- Home /
Two vector3's interacting to make a postive number from two negatives.
I have a button that is attached to my maincamera as a child object so that they will both move together. I instantiate the camera
void Start () {
print("GUIController.Start() start");
Mcamera = Instantiate(Resources.Load("Prefabs/MainCamera")) as GameObject;
//CameraLeft();
LoadText();
LoadButtons();
}
and give it this position
static Vector3 cameraMoveLeft = new Vector3(-3.5f, 0, -10);
then I instantiate the button
void InventButton(){
inventButton = Instantiate(Resources.Load("Prefabs/InventoryButton")) as GameObject;
inventButton.transform.parent = Mcamera.transform;
inventButton.transform.position = inventButtonPos;
}
and give it this position
Vector3 inventButtonPos = new Vector3(4, -4, -3);
In my scene the inventory button has a position of 7. I know that as far as doing math goes its supposed to be doing this. I however need it to not do this in any way, I want the button to be at -3 then move with the camera from then on.
Answer by whydoidoit · Feb 25, 2014 at 03:37 AM
So either you need to make the camera its parent or you need a script that moves the button every LateUpdate to follow the camera's position (adding its offset).
Your answer
Follow this Question
Related Questions
How can i change a childs local position with a variable? 1 Answer
Convert type UnityEngine.Vector3' to float' Error 1 Answer
Camera Lerp from A to B, and back 2 Answers
Object not centering with screen.width/2 0 Answers
Multiple Cars not working 1 Answer