Quantcast
Channel: Questions in topic: "namespace"
Viewing all articles
Browse latest Browse all 398

MathF not found in UnityEngine?

$
0
0
Hi, I have this chunk of code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class MouseLook : MonoBehaviour { public enum RotationAxes{ MouseXAndY = 0, MouseX = 1, MouseY = 2 } public RotationAxes axes = RotationAxes.MouseXAndY; public float sensitivityHor = 9f; public float sensitivityVert = 9f; public float minimumVert = -45f; public float maximumVert = 45f; private float _rotationX = 0; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (axes == RotationAxes.MouseX) { transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityHor, 0); } else if (axes == RotationAxes.MouseY) { _rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert; _rotationX = MathF.Clamp (_rotationX, minimumVert, maximumVert); float rotationY = transform.localEulerAngles.y; transform.localEulerAngles = new Vector3 (_rotationX, rotationY, 0); } else { //both horizontal and vertical rotation } } } Nevertheless i get this compilation error in console: Assets/Scripts/MouseLook.cs(32,17): error CS0103: The name `MathF' does not exist in the current context Moreover, if I add **Unity.Engine.** to **Mathf.Clamp** I get: Assets/Scripts/MouseLook.cs(32,29): error CS0234: The type or namespace name `MathF' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference? Nevertheless, according to MathF Unity 5.5 (my version) online reference MathF is contained in Unity Engine: https://docs.unity3d.com/ScriptReference/Mathf.html Is there something wrong with my UnityEngine library? Someone else had this issue? In past versions I had no problem about this.

Viewing all articles
Browse latest Browse all 398

Trending Articles



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