m0_62832730 2022-08-08 10:29 采纳率: 50%
浏览 63
已结题

Unity报错问题求帮助

使用unity编辑的代码,报错了不知道怎么调整QAQ

问题相关代码如下:

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

public class PCA_ShouGenerator : MonoBehaviour
{
    public Transform glassPanels;
    public float movementSpeed;
    Private Vector3 targetPosition;
    Private Vector3 glassPanelOpenPosition;
    Private int phase;
    Private bool actionStarted;
    Private bool actionCompleted;

    void Start()
    {
        phase = 1;
        actionStarted = false;
        actionCompleted = false;

        targetPosition = new Vector3(transform.localPosition.x, 1.5F, transform.localposition.z);
        glassPanelOpenPosition = new Vector3(glassPanels.localPosition.x, -4.0F, glasspanels.localPosition.z);
    }

    void Update()
    {
        if(actionStarted && !actionCompleted)
        {
            if(phase == 1)
            {
                transform.localposition = Vector3.Lerp(transform.localPosition, targetPosition, Time.deltaTime * movementSpeed);
                
                if(transform.localPosition.y >= targetPosition.y - 0.2)
                {
                    phase = 2;
                }

            }

            else if(phase == 2)
            {
                glassPanels.localPosition = Vector3.Lerp(glassPanels.localPosition, targetPosition,Time.deltaTime * movementSpeed);
                
                if(transform.localPosition.y <= glassPanelOpenPosition.y - 0.2)
                {
                    actionCompleted = true;
                }

            }   
        }
    }

    public override void playAction()
    {
        actionStarted = ture;
    }
}


报错内容如下:

img

  • 写回答

1条回答 默认 最新

  • 小赵爱吃肉 2022-08-08 10:44
    关注
    
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class PCA_ShouGenerator : MonoBehaviour
    {
        public Transform glassPanels;
        public float movementSpeed;
        private Vector3 targetPosition;
        private Vector3 glassPanelOpenPosition;
        private int phase;
        private bool actionStarted;
        private bool actionCompleted;
        void Start()
        {
            phase = 1;
            actionStarted = false;
            actionCompleted = false;
    
            targetPosition = new Vector3(transform.localPosition.x, 1.5F, transform.localPosition.z);
            glassPanelOpenPosition = new Vector3(glassPanels.localPosition.x, -4.0F, glassPanels.localPosition.z);
        }
        void Update()
        {
            if (actionStarted && !actionCompleted)
            {
                if (phase == 1)
                {
                    transform.localPosition = Vector3.Lerp(transform.localPosition, targetPosition, Time.deltaTime * movementSpeed);
    
                    if (transform.localPosition.y >= targetPosition.y - 0.2)
                    {
                        phase = 2;
                    }
    
                }
    
                else if (phase == 2)
                {
                    glassPanels.localPosition = Vector3.Lerp(glassPanels.localPosition, targetPosition, Time.deltaTime * movementSpeed);
    
                    if (transform.localPosition.y <= glassPanelOpenPosition.y - 0.2)
                    {
                        actionCompleted = true;
                    }
    
                }
            }
        }
        public override void playAction()
        {
            actionStarted = true;
        }
    }
    
    

    你的大小写都有问题,true都写错了。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月8日
  • 已采纳回答 8月8日
  • 创建了问题 8月8日

悬赏问题

  • ¥15 如何证明高斯噪声的包络公式
  • ¥150 寻找王者荣耀开发作者,合作或者解答
  • ¥15 乳腺癌数据集 相关矩阵 特征选择
  • ¥15 我的游戏账号被盗取,请问我该怎么做
  • ¥15 通关usb3.0.push文件,导致usb频繁断连
  • ¥15 有没有能解决微信公众号,只能实时拍照,没有选择相册上传功能,我不懂任何技术,,有没有给我发个软件就能搞定的方法
  • ¥15 Pythontxt文本可视化
  • ¥15 如何基于Ryu环境下使用scapy包进行数据包构造
  • ¥15 springboot国际化
  • ¥15 搭建QEMU环境运行OP-TEE出现错误