heres the problem , when i instantiate a prefab it falls to the left how can i fix this ? heres the code :
public bool IsSelected = false;
public GameObject RIGHT_SHU;
public GameObject LEFT_SHU;
public GameObject SplitShu;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
if (hit.collider != null)
{
Debug.Log(hit.collider.gameObject.name);
IsSelected = true;
}
else if (Input.GetMouseButtonDown(0) && IsSelected == true)
{
Debug.Log("Split -------------------------------------");
IsSelected = false;
SplitShu.SetActive(false);
Instantiate(RIGHT_SHU, transform.position, transform.rotation);
Instantiate(LEFT_SHU, transform.position, transform.rotation);
}
}