cannot convert from 'UnityEngine.Vector3' to 'UnityEngine.Quaternion'

Viewed 2938

i got this error and it says error is in this bit of code

rotation.z = UnityEngine.Random.Range(0, 180);
            spawnPosition.y += UnityEngine.Random.Range(minY, maxY);
            spawnPosition.x = UnityEngine.Random.Range(-levelWidth, levelWidth);
    ERROR IS HERE >>>Instantiate(platformPrefab, spawnPosition, rotation);
2 Answers

You can use Quaternion.Euler replacing the last line with

Instantiate(platformPrefab, spawnPosition, Quaternion.Euler(rotation ));

Have you tried declaring rotation to be a Quaternion instead of a Vector3? Rotations are described by quaternions instead of Euler angles.

See here

Related