【发布时间】:2019-06-12 20:41:41
【问题描述】:
我试过这段代码,但它不能正常工作。 编辑:LookAt 使 GameObject 不可见
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyPoint : MonoBehaviour {
public float offset;
public Transform target;
private void Update()
{
Vector2 difference = target.position - transform.position;
float rotZ = Mathf.Atan(difference.y) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
}
}
【问题讨论】:
-
LookAt makes the GameObject invisible...你是什么意思?它只旋转对象......它是否可能由于背面剔除而变得“不可见”? -
.@DanHasAPan
EnemyPoint附加到什么样的对象上?另外,你能编辑这个问题并在LookAt“使游戏对象不可见”的地方包含你正在使用的代码吗?