Код создаёт пулю, но когда я дописал transform.rotation Юнити стала выдавать ошибку:
error CS1503: Argument 2: cannot convert from 'UnityEngine.Transform' to 'UnityEngine.Vector3'
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gun : MonoBehaviour
{
public GameObject bullet;
public Transform shotPoint;
public float Ofset;
void Start()
{
}
void Update()
{
Vector3 diference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position ;
float rotateZ = Mathf.Atan2(diference.y, diference.x) * Mathf.Rad2Deg ;
transform.rotation = Quaternion.Euler(0f, 0f, rotateZ + Ofset);
if (Input.GetMouseButton(1))
{
Instantiate(bullet, shotPoint, transform.rotation);
}
}
}