Hello I am trying to instantiate a player into a scene and my code is throwing the following error
Error CS1503 Argument 1: cannot convert from ‘double’ to ‘float’ Pornstar Fighters D:\New folder\Pornstar Fighters\Assets\Scripts\ButtonAction.cs 18
I am kind of lost here as well I am still kind of new to the API and learning, could any one possibly lead me in the right direction on how to fix this? Code is below.
public void Character1()
{
player1 = GetComponent<GameObject>();
SceneManager.LoadScene ("Sky city scene lite", LoadSceneMode.Single);
Instantiate(player1, new Vector3(-40.10,23,44.51), Quaternion.identity);
}
There are three kinds of decimal numbers in C#. There is the decimal, which is very slow but very precise; the double, which is much faster but not as precise; and the float, which is even faster and less precise.
By default, if you just type the number -40.10 in your code, C# will give you a double. But Vector3() takes three float arguments, so you need to tell it you want a float.
You do this with the letter f after your number: -40.10f
If you wanted a decimal, you would use a letter m: -40.10m
And if you wanted to very clearly state you wanted a double, you would use d: -40.10d
Those last two also trip people up, because if -40.10 is a double, and you want a decimal… it only makes sense to say -40.10d, right? Wrong. -40.10m is the right way to declare a decimal constant. But neither of those matter much in Unity, because we use float for almost everything.
So what you need is to change the Vector3 constructor call:
new Vector3( -40.10f, 23f, 44.51f )
11 Likes
Thank you So Much cdarklock, That fixed it. I need to keep that in mind for next time 
3 Likes