Guest User

Untitled

a guest
Nov 19th, 2022
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class SpawnOnPositions : MonoBehaviour
  4. {
  5.     public GameObject cubePrefab;
  6.     public Transform[] spawnPoints;
  7.  
  8.     void Update()
  9.     {
  10.         if (Input.GetKeyDown(KeyCode.Space))
  11.         {
  12.             Transform randomPoint = spawnPoints[Random.Range(0, spawnPoints.Length)];
  13.  
  14.             GameObject instantiated = GameObject.Instantiate(cubePrefab);
  15.             instantiated.transform.position = randomPoint.position;
  16.         }
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment