I’m new to Unity and am trying to create a card game with a draw pile. I am trying to instantiate a prefab object, but while the code doesn’t error, it places the instantiated object under SampleScene instead of under the parent object (in this case “Hand”). Here’s my code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawCard : MonoBehaviour {
public Transform Hand;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("stuff");
GameObject newCard = Instantiate(Resources.Load("cardBase")) as GameObject;
newCard.name = "newCard";
newCard.transform.SetParent(parent: Hand);
}
}
}
Any help would be really appreciated!