quality-control/Assets/Scripts/Machines/ProductSpawner.cs

19 lines
627 B
C#
Raw Normal View History

using System.Collections.Generic;
using UnityEngine;
public class ProductSpawner: MonoBehaviour
{
public List<Transform> PossibleOrientations;
public Vector2 yRotation;
2024-08-18 20:01:15 +00:00
public void SpawnProduct(ProductType type)
2024-08-18 20:01:15 +00:00
{
var randomIndex = Random.Range(0, PossibleOrientations.Count);
var randomOrientation = PossibleOrientations[randomIndex];
var rotation = Quaternion.AngleAxis(Random.Range(yRotation.x, yRotation.y), Vector3.up) *
randomOrientation.rotation;
ProductType.SpawnProduct(type, transform, randomOrientation.position, rotation);
}
}