I have this script for random movement within specific locations but there are 2 problems first, it is for images and i want it for objects .Second the objects should not take the features of the original card.
please can you help me?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class randpics : MonoBehaviour
{
public const int gridRows = 2;
public const int gridCols = 3;
public const float offsetX = 1.5f;
public const float offsetY = 1.5f;
[SerializeField] private MainCard originalCard;
[SerializeField] private GameObject[] images;
private void Start()
{
Vector3 startPos = originalCard.transform.position; //The position of the first card. All other cards are offset from here.
int[] numbers = { 0, 1, 2, 3, 4, 5};
numbers = ShuffleArray(numbers); //This is a function we will create in a minute!
for (int i = 0; i < gridCols; i++)
{
for (int j = 0; j < gridRows; j++)
{
MainCard card;
if (i == 0 && j == 0)
{
card = originalCard;
}
else
{
card = Instantiate(originalCard) as MainCard;
}
int index = j * gridCols + i;
int id = numbers[index];
float posX = (offsetX * i) + startPos.x;
float posY = (offsetY * j) + startPos.y;
card.transform.position = new Vector3(posX, posY, startPos.z);
}
}
}
private int[] ShuffleArray(int[] numbers)
{
int[] newArray = numbers.Clone() as int[];
for (int i = 0; i < newArray.Length; i++)
{
int tmp = newArray*;*
int r = Random.Range(i, newArray.Length);
newArray = newArray[r];
newArray[r] = tmp;
}
return newArray;
}
}