using System.Collections; using System.Collections.Generic; using UnityEngine; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class Spawn : MonoBehaviour { public GameObject item; // The item prefab to be instantiated private Transform player; // Reference to the player's transform void Start() { // Find the Player GameObject and get its Transform component player = GameObject.FindGameObjectWithTag("Player").transform; } // Method to spawn the item public void SpawnDroppedItem() { // Calculate the spawn position, slightly above the player's position Vector2 playerPos = new Vector2(player.position.x, player.position.y + 2); // Instantiate the item at the calculated position with no rotation Instantiate(item, playerPos, Quaternion.identity); } }