我正在创建一个代码,在统一的“熔岩”块,在那里,一旦玩家接触它,玩家的呼吸。但是我收到了三个错误,我不明白问题出在哪里。错误:
使用System.Collections;使用System.Collections.Generic;使用UnityEngine;公共类KillScript : MonoBehaviour { void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Lava") {MonoBehaviour(GameObject);} if (GameObject)销毁){ current.transformation.position Newvector3(-0.37,-0.13,0);} }
发布于 2021-06-05 19:44:26
对于您的if声明,我建议使用bool来检查您的玩家是否死了。此外,第14行在Vector3和current.transformation.position之间没有等号,Vector3也没有大写。另一个问题是小数后面没有f。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KillScript : MonoBehaviour
{
public bool isDead;
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "Lava")
{
Destroy(gameObject);
isDead = true;
}
if (isDead = true)
{
current.transformation.position = new Vector3(-0.37f, -0.13f, 0);
isDead = false;
}
}
}我也不知道current.transformation.position是什么。您可以使用预制件创建一个克隆,然后将该位置设置为Vector3。
发布于 2021-06-07 13:26:14
让我看看..。
首先,看起来( GameObject )破坏是检查GameObject是否被销毁。看,问题是如果GameObject被销毁了,那么这个脚本也会被销毁…?我很确定current.transformation.position注定要成为transform.position?您还需要等号,Vector3应该大写。
https://stackoverflow.com/questions/67852394
复制相似问题