【发布时间】:2021-07-13 15:05:12
【问题描述】:
这是我的移动平台播放器附加代码:
我收到错误 CS1001: Identifier expected for some reason ant youtube 没有帮助我...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttach : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
function OnTriggerEnter(other.Collider){
if (other.gameObject.tag == "player")
{
transform.parent = other.transform;
}
}
function OnTriggerExit(other.Collider){
if (other.gameObject.tag == "player")
{
transform.parent = null;
}
}
}
}
【问题讨论】:
-
欢迎来到 SO。请尽可能详细。你在哪一行得到错误?确切的错误信息是什么?另请阅读How to Ask
-
function OnTriggerEnter(other.Collider)- 那是 not C# 语法。看起来更像是您从 javascript 世界中复制粘贴了一些东西?另外:欢迎来到stackoverflow。我推荐taking the tour,以及阅读how to ask a good question 和what's on topic。 -
我收到 CS1001: Identifier expected 错误,我在 youtube 上观看了 Unity 教程:youtu.be/9KdY4mafG_E?t=347