@cheloveksupertypoi

Ошибка в c# 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 Weapon : MonoBehaviour
{
    public GameObject bullet;
    public Camera mainCamera;
    public Transform spawnBullet;

    public float shootForce;
    public float spread;

    public ParticleSystem muzzleFlash;
    AudioSource audioSource;
    public AudioClip shootClip;

    public void Start() 
    {
        audioSource = GetComponent<AudioSource>();
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
            Shoot();
            audioSource.PlayOneShot(shootClip);
            muzzleFlash.Play;
    }

    public void Shoot()
    {
        Ray ray = mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
        RaycastHit hit;

        Vector3 targetPoint;
        if (Physics.Raycast(ray, out hit))
            targetPoint = hit.point;
        else
            targetPoint = ray.GetPoint(75);

        Vector3 dirWithoutSpread = targetPoint - spawnBullet.position;

        float x = Random.Range(-spread, spread);
        float y = Random.Range(-spread, spread);

        Vector3 dirWithSpread = dirWithoutSpread + new Vector3(x, y, 0);

        GameObject currentBullet = Instantiate(bullet, spawnBullet.position, Quaternion.identity);

        currentBullet.transform.forward = dirWithSpread.normalized;

       currentBullet.GetComponent<Rigidbody>().AddForce(dirWithSpread.normalized * shootForce, ForceMode.Impulse);
    }
}
  • Вопрос задан
  • 123 просмотра
Решения вопроса 1
vabka
@vabka Куратор тега C#
Токсичный шарпист
muzzleFlash.Play;
Эта строка не имеет смысла, о чём и говорит тебе компилятор.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы