Stranar/Assets/Scripts/yolo.cs
2022-06-25 15:42:49 +02:00

45 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class yolo : MonoBehaviour
{
public Pukvbrane pukvbrane;
public GameObject totok;
void PlaceObj(){
int x = Random.Range(-821, 1000);
int z = Random.Range(-950, 950);
int y = 800;
//pick y from either -75 and 845
if (Random.Range(0, 2) == 0)
{
y = 1600;
}
GameObject iks = Instantiate(totok.gameObject, new Vector3(x, y, z), Quaternion.identity);
iks.SetActive(true);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter(Collision other) {
if(other.gameObject.tag == "Player"){
pukvbrane.collectedcubes = 0;
}
else if (other.gameObject.tag == "puk"){
Destroy(other.gameObject);
pukvbrane.PlaceObj();
}
PlaceObj();
Destroy(this.gameObject);
}
}