@xdefx

Ошибка Unity в коде,что делать?

error CS1061: 'Collider' does not contain a definition for 'ComapareTag' and no accessible extension method 'ComapareTag' accepting a first argument of type 'Collider' could be found (are you missing a using directive or an assembly reference?)

код:

1using System;
2using System.Collections;
3using System.Collections.Generic;
4using UnityEngine;
5using UnityEngine.SceneManagement;
6
7public class Player : MonoBehaviour
8{
9    [SerializeField] KeyCode keyOne;
10    [SerializeField] KeyCode keyTwo;
11    [SerializeField] Vector3 moveDirection;
12
13    private void FixedUpdate()
14    {
15        if (Input.GetKey(keyOne))
16        {
17            GetComponent<Rigidbody>().velocity += moveDirection;
18        }
19        if (Input.GetKey(keyTwo))
20        {
21            GetComponent<Rigidbody>().velocity -= moveDirection;
22        }
23    }
24    private void OnTriggerEnter(Collider other)
25   {     
26        if(this.CompareTag("Player") && other.ComapareTag("Finish"))
27        {
28             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
29        }
30    }
31}
  • Вопрос задан
  • 246 просмотров
Решения вопроса 1
GavriKos
@GavriKos Куратор тега Unity
Будете продолжать плодить однотипные вопросы, или возьметесь за голову, мануал и туториалы?
ComapareTag - метод GameObject, а не Collider.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
16 апр. 2024, в 12:48
1500 руб./за проект
16 апр. 2024, в 12:30
12000 руб./за проект
16 апр. 2024, в 12:13
10000 руб./за проект