【问题标题】:my c# unity script(tank game) and transform.LookAt我的 C# unity 脚本(坦克游戏)和 transform.LookAt
【发布时间】:2023-02-10 23:26:48
【问题描述】:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankScopeScript : MonoBehaviour
{
    public float speed;
    private float waitTime;
    public float startWaitTime;
    public Transform[] moveSpots;
    private int randomSpot;


    void Start()
    {
        randomSpot = Random.Range(0, moveSpots.Length);
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = Vector3.MoveTowards(transform.position, moveSpots[randomSpot].position, speed * Time.deltaTime);

        if (Vector3.Distance(transform.position, moveSpots[randomSpot].position) < 0.2f)
        {
            if (waitTime <= 0)
            {
                randomSpot = Random.Range(0, moveSpots.Length);
                waitTime = startWaitTime;



                
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
        }
    }
}

想使用 transform.LookAt(randomSpot) 但我不能...使用 int 进行转换时出错,请帮助我... 我试图随机创建公共转换;并赋值randomSpot,但是,又报错

【问题讨论】:

    标签: c# unity3d


    【解决方案1】:

    你能准确发送错误信息吗

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 2017-01-26
      • 1970-01-01
      相关资源
      最近更新 更多