Comme vous pouvez le voir sur l'image, le cube dissident c'est le bleu.
_blocKPosRound = 0.0625
Scale of little cube is 0.125f
Scale of the big cube is 0.5f
Code : Tout sélectionner
if(Input.GetMouseButtonDown(1))
{
GameObject fBlock = Instantiate(selectedBlock,Vector3.one,hit.transform.rotation);
float roundT = hit.transform.lossyScale.x;
Debug.DrawRay(cam.transform.position,point,Color.red,10f);
print("Valeur AB : " + point.x);
print("Valeur 1 : " + Mathf.Round(point.x));
print("Valeur 2 : " + Mathf.Round(point.x / _blocKPosRound));
print("Valeur 3 : " + Mathf.Round(point.x / _blocKPosRound) * _blocKPosRound);
Vector3 _position = new Vector3(
Mathf.Round(point.x / _blocKPosRound) * _blocKPosRound,
Mathf.Round(point.y / _blocKPosRound) * _blocKPosRound,
Mathf.Round(point.z / _blocKPosRound) * _blocKPosRound);
fBlock.GetComponent<Renderer>().material.color = Random.ColorHSV();
fBlock.transform.position = _position;
}
Merci.