Jordan
Jordan

Reputation: 424

Error: Vector3,Float

I've create a game where a new sprite is 'cloned' every 5 seconds using InvokeRepeating. Once the new sprite is 'cloned' I want it to be cloned at a exact location therefore I used this (C#):

newSpike.transform.position = new Vector3 (0.09, 8.27, 0);

and I get this error in the console window: Error CS1503:

The best overloaded method match for 'UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments.

Thanks.

Upvotes: 1

Views: 309

Answers (1)

Thomas Hilbert
Thomas Hilbert

Reputation: 3639

The Vector3 class works with floats, not doubles.

In C#, you have to append an f to your decimals to tell the compiler that you want them to be floats, not doubles.

Try

newSpike.transform.position = new Vector3(0.09f, 8.27f, 0f);

Upvotes: 1

Related Questions