【发布时间】:2020-09-28 04:37:18
【问题描述】:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnPoint : MonoBehaviour
{
void Start()
{
print(this.transform.position);
print(GameObject.Find("GameManager").GetComponent<GameManager>().player.transform.position);
GameObject.Find("GameManager").GetComponent<GameManager>().player.transform.position = this.transform.position;
}
}
此脚本位于我关卡中的游戏对象上。当打印返回生成点正确时,它会在关卡加载时运行。但是,玩家对象不会改变位置,它会停留在同一个位置。当场景发生变化时,第二个打印也可以正确返回玩家当前的位置。
我以前从未遇到过任何问题。我唯一能想到的是播放器在创建时设置为 DontDestroyOnLoad,但这应该不会影响它吧?
【问题讨论】:
-
印刷品不会留下来。它只是用来测试值是否正确
-
还有什么设置的位置吗?
-
哦,等等,您可能正在做某事。播放器控制器可能会干扰生成更改。等我放学回来一定要检查一下