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

How to "Camera.ScreenPointToRay". I get an error in MonoDevelop.

$
0
0
Hello, I am pretty new to Unity. I am trying to cast a ray from the main camera, mouse position into the game world. This video http://www.youtube.com/watch?v=P0PHY1hJp5k shows exactly what I want to do. I have also tried to copy and paste from the Unity script reference page. I thought the unity script reference was supposed to be a working code snippet. When I try either one and to debug them I get the same 3 error messages. The 2 versions of code are.. void Update () { Ray ray = Camera.mainCamera.ScreenPointToRay (Input.mousePosition); Debug.DrawRay (ray.origen, ray.position * 10, Color.cyan); } and public class ExampleClass : MonoBehaviour { void Update() { Ray ray = camera.ScreenPointToRay(new Vector3(200, 200, 0)); Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow); } This one is from the Unity script reference. When I try to debug them I get these 3 errors and warning... 1. Error CS0029: Cannot implicitly convert type 'UnityEngine.Ray' to 'Ray' (CS0029) (Assembly-CSharp). 2. Error CS1061: 'Ray' does not contain a definition for 'origin' and no extension method 'origin' accepting a first argument of type 'Ray' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Assembly-CSharp). 3. Error CS1061: 'Ray' does not contain a definition for 'direction' and no extension method 'direction' accepting a first argument of type 'Ray' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Assembly-CSharp). 4. Warning CS0618: 'UnityEngine.Camera.mainCamera' is obsolete: 'use Camera.main instead.' (CS0618) (Assembly-CSharp). So I understand the Warning. I have Unity version 4.1.5f1 on my other computer and all this code works fine. Running the newest version, how can I make the code work now?

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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