I have no idea why I’m getting this error with this line of code:
CODE:
Cam = GameObject.Find (“Main Camera”);
Vector3 SpawnPos = Cam.GetComponent ().ScreenToWorldPoint(x,y/2,0) + new Vector3(1.5f,0,0);
ERROR:
Assets/Scripts/PlayerController.cs(34,64): error CS1501: No overload for method ScreenToWorldPoint' takes 3’ arguments
1 Answer
1
corn
2
From the Camera.ScreenToWorldPoint Script Reference page :
public Vector3 ScreenToWorldPoint(Vector3 position);
You’re trying to call ScreenToWorldPoint with three arguments, for the three coordinates of your Vector3, but you need to call it with a Vector3.
Vector3 SpawnPos = Cam.GetComponent ().ScreenToWorldPoint(new Vector3(x, y/2, 0)) + new Vector3(1.5f,0,0);