相机总是看着目标

时间:2018-11-05 19:41:14

标签: c# unity3d

我对Unity很陌生。我正在尝试制作一个简单的脚本,使相机始终看着场景中的飞船。

我有:

Get-Secret -WebService "https://Stuff/sswebservice.asmx" -Credential $ThycoticCredentials  -SearchTerm "HELLO" -raw | select -ExpandProperty Items

我已经在场景playerShip中命名了目标,但是它给了我一个错误:

Get-Secret -WebService "https://Stuff/sswebservice.asmx" -Credential $ThycoticCredentials  -SearchTerm "HELLO" -raw | select -ExpandProperty Items | ?{$_.fieldname -like 'username'} | select -ExpandProperty value

1 个答案:

答案 0 :(得分:1)

你必须使用:transform.LookAt(playerShip.position);

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LookAt : MonoBehaviour {

    public Transform playerShip;

    // Update is called once per frame
    void Update () {
        transform.LookAt(playerShip.position);
    }
}