我是Unity的初学者,在移动场景时让我的播放器旋转保持不变一直有些麻烦。当我切换场景时,玩家的旋转与我运行游戏之前在场景编辑器中的旋转相同。
这是我的代码,可以节省玩家从一个场景中的轮换时间
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GlobalRotation : MonoBehaviour {
public static float xrotation, yrotation, zrotation;
void Update () {
xrotation = transform.rotation.x;
yrotation = transform.rotation.y;
zrotation = transform.rotation.z;
}
}
这是我的代码,用于在玩家进入另一个场景时更新他们的旋转方式
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FixedRotation : MonoBehaviour {
void Start () {
transform.Rotate(GlobalRotation.xrotation, GlobalRotation.yrotation,
GlobalRotation.zrotation);
}
}