【发布时间】:2021-10-11 23:13:43
【问题描述】:
我正在尝试将粒子添加到我的 Collison,但收到错误消息。我不断从我的代码中得到他的错误,我不知道为什么。错误是: OnGUIDepth 已更改:0 为 1。事件类型为 0 (56,60):错误 CS1001:预期标识符。 (56,55): 错误 CS1003: 语法错误, ',' 预期
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController1 : MonoBehaviour
{
public float horizontalInput;
public float speed = 10.0f;
public float xRange = 100;
private Animator playerAnim;
public AudioClip crashSound;
private AudioSource playerAudio;
public GameObject projectilePrefab;
public ParticleSystem explosionParticle;
public bool isOnGround = true;
public bool gameOver;
// Start is called before the first frame update
void Start()
{
playerAudio = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
if (transform.position.x < -xRange)
{
transform.position = new Vector3(-xRange, transform.position.y, transform.position.z);
}
if (transform.position.x > xRange)
{
transform.position = new Vector3(xRange, transform.position.y, transform.position.z);
}
else
{
}
horizontalInput = Input.GetAxis("Horizontal");
transform.Translate(Vector3.right * horizontalInput * Time.deltaTime * speed);
if (Input.GetKeyDown(KeyCode.Space))
{
//Instantiate(projectilePrefab, transform.position, projectilePrefab.transform.rotation);
Instantiate(projectilePrefab, transform.position, transform.rotation);
}
}
private void OnCollisionEnter(Collision collision other)
{
if (other.gameObject.CampareTag("Rock"))
{
isOnGround = true;
} else if (other.gameObject.CompareTag("Star"))
{
Debug.Log("Game Over");
gameOver = true;
playerAnim.SetBool("Death_b", true);
playerAnim.SetInterger("DeathType_int", 1);
explosionParticle.Play();
playerAudio.PlayOneShot(crashSound, 1.0f);
}
}
}
我的代码有什么需要修复的地方吗?
【问题讨论】:
标签: c# visual-studio unity3d