Skip to content

Instantly share code, notes, and snippets.

View sasherafat-zz's full-sized avatar
🎯
Focusing

Seyed Abolfazl Sherafat sasherafat-zz

🎯
Focusing
View GitHub Profile
@sasherafat-zz
sasherafat-zz / gist:11c1894c96af7bc367ab923b62e44626
Created August 22, 2019 08:06
create first script in unity
using UnityEngine;
using System.Collections;
public class SpawnFood : MonoBehaviour {
// Use this for initialization
void Start () {
}
using UnityEngine;
using System.Collections;
public class SpawnFood : MonoBehaviour {
// Use this for initialization
void Start () {
}
}
@sasherafat-zz
sasherafat-zz / gist:6bb3265e617f0203bb710f5c60be6cb3
Created August 22, 2019 08:08
create GameObject in unity project
using UnityEngine;
using System.Collections;
public class SpawnFood : MonoBehaviour {
// Food Prefab
public GameObject foodPrefab;
// Use this for initialization
void Start () {
using UnityEngine;
using System.Collections;
public class SpawnFood : MonoBehaviour {
// Food Prefab
public GameObject foodPrefab;
// Borders
public Transform borderTop;
public Transform borderBottom;
void Spawn() {
// x position between left & right border
int x = (int)Random.Range(borderLeft.position.x,
borderRight.position.x);
// y position between top & bottom border
int y = (int)Random.Range(borderBottom.position.y,
borderTop.position.y);
// Instantiate the food at (x, y)
// Use this for initialization
void Start () {
// Spawn food every 4 seconds, starting in 3
InvokeRepeating("Spawn", 3, 4);
}
using UnityEngine;
using System.Collections;
public class SpawnFood : MonoBehaviour {
// Food Prefab
public GameObject foodPrefab;
// Borders
public Transform borderTop;
public Transform borderBottom;