Random object location

I have 4 jigsaw puzzle object that place in different location but i want to random that 4 object. I don’t know how? I need some help. Please !!! :cry:

Here’s what you should need, I’ve done it all in JavaScript for you. Just put all the ‘pieces’ you want to inside the objects variables in the Inspector window, and set the min and max ranges on the position variables minPos and maxPos.

The script will then go through each object in the objects array, and randomly position it within the ranges you define. This means everything is limited to being placed in a square area, but it’s a start for what you should need.

public var objects : Transform[];
public var maxPos : Vector3 = Vector3.zero;
public var minPos : Vector3 = Vector3.zero;

function Start()
{
	for(var obj : Transform in objects)
	{
	var newPos : Vector3 = new Vector3(Random.Range(minPos.x,maxPos.x),
									Random.Range(minPos.y,maxPos.y),
									Random.Range(minPos.z,maxPos.z));
	
	obj.position = newPos;
	}
}

Do you want to randomise the objects, or the locations? It sounds like you want to place 4 objects at specific locations, but randomise which objects go where?

I’d suggest you put your 4 objects in to an array, your 4 locations in to another array, and then use Random.Range to pick one of the objects and assign it to a location. I can write up the script if you’re unable to do this yourself?

no need to answer my last question . i already know what to do . super thanks you . it works well . ANSWERED …!!