Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Camera attached Error.

$
0
0
Hi, for everyone. I need a help with an unexpected error that I found in my code. The following is a peace of my code using in a component: public class Shoot : MonoBehaviour { [SerializeField] private GameObject bulletPrefab; private GameObject _bullet; private Camera _camera; private float _yPlayerPos; void Start() { _camera = GetComponent(); _yPlayerPos = transform.position.y; } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = _camera.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); //---- I cut the other part of the code because it is irrelevant for the error---- } } } As you can see in this peace of code avobe, I got the camera attached to this object to make some internal logic. This script is a componne that I added to my player object. I also attached the camera to the player object, as you can see in the following image: ![alt text][1] When I start the game, and press clic, the following error is showed: ![alt text][2] I have not found a posible cause for this error, so I appreciate if someone knows the reason and help me with this. [1]: /storage/temp/154034-camera-attached.jpg [2]: /storage/temp/154035-error.jpg

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>