Je m'appelle Alexandre et j'essaie de faire un petit jeu avec des pièces qui tombent sur un terrain mais parfois j'ai des pièces qui tombent à coté et je ne comprends pas où est mon problème
Ci dessous mon script :
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeclencheurObjetCache : MonoBehaviour {
GameObject My3DPiece;
void OnCollisionEnter2D ( Collision2D coll )
{
//Si le tag du gameObject du collider touché est égale à "Player"
if ( coll.gameObject.name == "Respawn" )
{
Destroy(gameObject);
My3DPiece = GameObject.FindWithTag("Piece3D");
//Instantiate(My3DPiece, new Vector3(3.61f, 7.29f + (2.0F + Random.Range(0.2f, 1f)),0.118f), Quaternion.identity);
Instantiate(My3DPiece, new Vector3(3.61f, 7.29f, -0.118f), Quaternion.identity);
}
}
}