Co ordinates issue

I’ve set my co ordinates in my code for a unity 2d game to move the tile to a set position. However it never goes to the X or y I have defined in inspector leaving me a bit confused to what’s wrong is it a simple fix or resolution issue. I do not have z defined also as I don’t see the point

You defined positions as a Vector3, not an int. I hope this analogy doesn’t offend you but you are trying to compare things that don’t compare with that statement like this pen is a car.
Try this:

`````` using System.Collections;
using System.Collections.Generic
using Unity Engine;

public class RandomPosition : MonoBehaviour
{
float randomRangeX;
float randomRangeY;
public int randomRange;
public Vector3 positions;
public void SetRandomPosition)
{
randomRangeX = Random.Range(0,
randomRange);
randomRangeY = Random.Range(0,
randomRange);
positions = new Vector3 (randomRangeX, randomRangeY,  0);
transform.position =  positions;
}
}
``````

What I am doing here is assigning the values of x and y to floats (ints with decimal values) and then when you call the function, getting those random numbers generated. After you have those, when you define the Vector3 positions, you plug in the random x and y values you just created (and left z at 0 because you don’t care about that in 2D). JUST A REMINDER, you need to set the value randomRange in the inspector for this to work.

Let me know if that works.

For some reason it still goes to some which aren’t desired is It the vector 3

``````using System.Collections;
using System.Collections.Generic;
using Unity Engine;

public class RandomPosition : MonoBehaviour
{
public Vector3[] positions;
public void SetRandomPosition()
{
int randomNumber = Mathf.RoundToInt(Random.Range(0,
positions.Length)); // I think that is how you round a float to an int, I'm not using an IDE so I double check if you copy and past this
transform.position = positions[randomNumber];
}
}
``````