I am trying to use functions within the math namespace that are not available with Mathf namespace, I figured I had to add this at the beginning of my script in order to access this area but it’s failing…
using System.Math;
I would really like to be able to use these missing functions, so that I may perform things like this:
I found this link that is along the lines of what I’m trying to do, but I cannot figure out how this person got it to work (or if they even did…)
Ok, maybe just answered my own question by mistake, I tried this:
using System;
I now have access to the math function, I guess now my question is this, is there a better way to go about this? or, is this the proper way? ((I feel that telling unity to access EVERYTHING in the system is probably a bit slower than it would be by using something similar to using system.math.whatever))
It’s just importing a namespace, and you don’t actually need it. You could always write System.Math.Cos (or whatever). If you import the System namespace then you would write Math.Cos, and if you import System.Math you can write Cos. It’s nothing to do with anything being faster or slower or loading libraries, it’s basically just a shortcut.
If I try typing anything with math.whatever it fails unless I add the namespace
plus since adding the namespace I now get these errors, which I makes sence…unfortunately
Assets/Imported Assets/Scripts/C#/HRSIG_vs_a4.cs(56,93): error CS0104: Random' is an ambiguous reference between UnityEngine.Random’ and `System.Random’
This does not work…
using UnityEngine;
using System.Collections;
public class HRSIG_vs_a4 : MonoBehaviour
{
void Update()
{
double testThisNumber = Math.Round(1.5, MidpointRounding.AwayFromZero);
print (testThisNumber);
}
}
I get this error when I try: Assets/Imported Assets/Scripts/C#/HRSIG_vs_a4.cs(8,41): error CS0103: The name `Math’ does not exist in the current context