📜  在对象 Unity 中实例化对象 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:26.852000             🧑  作者: Mango

代码示例3
// Makes the camera follow this object by
// making it a child of this transform.
 
// Get the transform of the camera
var cameraTransform = Camera.main.transform;    
 
// make it a child of the current object
cameraTransform.parent = transform;
 
// place it behind the current object
cameraTransform.localPosition = -Vector3.forward * 5;
 
// make it point towards the object
cameraTransform.LookAt(transform);