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

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 husky+kinova jaco2 仿真
  • ¥15 MATLAB数据处理
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的
  • ¥15 硬件IIC从模式的数据发送,中断数据的接收,不能用HAL库(按照时序图)
  • ¥20 QAxWidget上显示一个word文档后,如何直接在该QAxWidget上修改和保存word文档
  • ¥15 Simulink仿真报错,请问如何解决
  • ¥20 宝塔面板无法添加Node项目,一直处于正在添加脚本页面
  • ¥50 Dkeil5 CT107D单片机的程序编写
  • ¥30 Ubuntu20.04中PVN3D复现过程交叉编译问题