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日

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元