【发布时间】:2017-05-06 13:15:05
【问题描述】:
当我的播放器被破坏时,我想将相机(它是播放器的子对象)带回层次结构。但我不知道如何获得层次结构的变换。
private void OnCollisionEnter(Collision col)
{
if (col.gameObject.CompareTag("Player")) // player collision with the obstacle
{
ReplaceCamera(); // Take the camera away from the player
Destroy(col.gameObject); // Destroy the player
}
}
void ReplaceCamera()
{
Camera.main.transform.SetParent(?); // Set the camera as a child of the hierarchy
}
我只是不知道要为我的 ReplaceCamera 方法传递什么参数。
【问题讨论】: