我正在尝试为我正在开发的游戏制作一个统一的半程序生成地图。在游戏中,当玩家向它们移动时,方形平台会在各个方向生成(北、南、东、西、西北、东北、西南、东南)。这些平台包含一个平坦的地形作为地面(所以我可以在它们上面绘制纹理等等)。为了给游戏带来一些多样性,我打算在这些平台生成时为它们选择随机旋转(90、180 和 270 度)。问题是,默认情况下,地形的轴心点不在它的中心,这会导致非常尴尬的结果,在这种情况下是破坏性的结果。我试图将它作为一个空的游戏对象,中心有一个枢轴,但我得到了相同的结果。有谁知道克服这个问题的方法?我知道这不是一个编码问题,但它 一个技术性的。我四处搜索,常见的解决方案是将它设为空,但正如我所说,它在这种情况下不起作用,除非我遗漏了一些东西。与往常一样,提前感谢您的耐心和关注。瑞皮雷斯
注意:这是我的旋转脚本,以防我可以通过修改它来实现:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AutoRotate : MonoBehaviour
{
Quaternion rot1;
private int a;
private void Awake()
{
a = Random.Range(0, 4);
rot1 = transform.rotation;
}
// Start is called before the first frame update
void Start()
{
switch(a)
{
case 0: transform.rotation = rot1;
Debug.Log("case 0");
break;
case 1: rot1 = Quaternion.AngleAxis(90, Vector3.up);
transform.rotation = rot1;
Debug.Log("case 1");
break;
case 2: rot1 = Quaternion.AngleAxis(180, Vector3.up);
transform.rotation = rot1;
Debug.Log("case 2");
break;
case 3:
rot1 = Quaternion.AngleAxis(270, Vector3.up);
transform.rotation = rot1;
Debug.Log("case 3");
break;
}
}
}