I have a ball that is supposed to bounce on a plane, I generate in a 5x5 grid of balls but every time the row/column is meant to be 6, or the row number is 2 and the column number is 8 (and vice versa) the numbers start to break and aren’t exact ints? They seem to gradually increase, and the row 0 also appears to be moving just very slowly. I have 0 clue why this is.
Script to spawn the balls in:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateBalls : MonoBehaviour
{
// Start is called before the first frame update
static int size = 25;
private GameObject[] Balls = new GameObject[size];
void Start()
{
double l = Math.Sqrt(size);
int i = 0;
for (int y = 0; y < l; y++)
{
for (int x = 0; x < l; x++)
{
Balls[i] = Instantiate(Resources.Load("Objects/MyBouncingBall")) as GameObject;
Balls[i].transform.position = new Vector3Int(x, 5, y) * 2;
Balls[i].transform.rotation = Quaternion.identity;
i++;
}
}
}
// Update is called once per frame
void Update()
{
}
}
Anyone have any ideas?
Here is what happens:


