Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Пишет ошибку в Юнити

tema777mars shamardin Ученик (96), открыт 1 день назад
В юнити пишет: Assets\Scenes\scripts\CarEnterExitSystem.cs(64,13): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

код:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CarEnterExitSystem : MonoBehaviour
{

public MonoBehaviour CarController;
public Transform Car;
public Transform Player;

public GameObject PlayerCam;
public GameObject CarCam;

public GameObject DriveUi;

bool Candrive;



// Start is called before the first frame update
void Start()
{
CarController.enabled = false;
DriveUi.gameObject.SetActive(false);
}

// Update is called once per frame
void Update()
{

if (Input.GetKeyDown(KeyCode.F) && Candrive) // Here After Click F button and trigger is true player is driving
{

CarController.enabled = true; // After Click F button Car Controller Script is enabled
DriveUi.gameObject.SetActive(false);
Car.GetComponent<AudioListener>().enabled;
PlayerCam.GetComponent<AudioListener>().disabled;

// Here we parent Car with player
Player.transform.SetParent(Car);
Player.gameObject.SetActive(false);

// Camera
PlayerCam.gameObject.SetActive(false);
CarCam.gameObject.SetActive(true);
}

if (Input.GetKeyDown(KeyCode.G))
{


CarController.enabled = false; // After Click G button Car Controller Script is disable

// Here We Unparent the Player with Car
Player.transform.SetParent(null);
Player.gameObject.SetActive(true);

// Here If Player Is Not Driving So PlayerCamera turn On and Car Camera turn off

PlayerCam.gameObject.SetActive(true);
CarCam.gameObject.SetActive(false);
Car.GetComponent<AudioListener>().disabled;
PlayerCam.GetComponent<AudioListener>().enabled;
}
}


void OnTriggerStay(Collider col)
{
if (col.gameObject.tag == "Player")
{
DriveUi.gameObject.SetActive(true);
Candrive = true;
}
}

void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Player")
{
DriveUi.gameObject.SetActive(false);
Candrive = false;
}
}
}
1 ответ
Похожие вопросы