Unity-Why can not change the view of main Camera into a position of the GameObject?
Unity-Why can not change the view of main Camera into a position of the GameObject?
A:For change the position of main camera. You should
(1)select the main camera with Camera class
using the following code:
Camera cam=Camera.main;
(2)change the position.
Notice that when you change the localPosition (position which is relative to the parent GameObject)
You should add it to fix the position.
Here is my code:
cam = Camera.main;
offset=Unitychan_GameObject.transform.localPosition+UnitychanFace_GameObject.transform.localPosition+this.transform.localPosition;
cam.transform.localPosition = UnitychanEyes_GameObject.transform.localPosition + offset;
P.S.
localPosition is a Position which is relative to parent GameObject.
Comments
Post a Comment