Skip to content

Instantly share code, notes, and snippets.

View AtlasWeng's full-sized avatar

Ata Weng AtlasWeng

  • London
View GitHub Profile
@AtlasWeng
AtlasWeng / AsteroidSpawn.cs
Last active December 1, 2017 00:09
place asteroids at random position
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AsteroidSpawn : MonoBehaviour {
// Array of object to spawn
public GameObject[] asteroids;
// Time it takes to spawn asteroids
[Space(3)]
@AtlasWeng
AtlasWeng / Once a time.cs
Created November 30, 2017 23:24
Run code in update method only one time
public bool boolean = false
public float t = 3;
void Update(){
if (!boolean){
t --;
if(t < 0){
boolean = true;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AsteroidSpawn : MonoBehaviour {
// Array of object to spawn
public GameObject[] asteroids;
// Time it takes to spawn asteroids
[Space(3)]
@AtlasWeng
AtlasWeng / MusicPlayer.cs
Created November 20, 2017 20:55
scripts for Music Player and destroy the duplicated one
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MusicPlayer : MonoBehaviour {
static MusicPlayer instance = null;
// Use this for initialization
void Start ()
{
@AtlasWeng
AtlasWeng / LevelManager.cs
Created November 7, 2017 19:48
This script shows how to manager our level in U3D.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelManager : MonoBehaviour {
public void LoadLevel(string name)
{
Debug.Log("Load Level Requested for: " + name);
@AtlasWeng
AtlasWeng / MoveLerp.cs
Created October 26, 2017 12:11
MoveLerp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//[ExecuteInEditMode]
public class MoveLerp : MonoBehaviour {
[Range(0, 100)]
public float Duration = 10f;
@AtlasWeng
AtlasWeng / Collisions.cs
Created October 19, 2017 11:12
About some function of collision
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerScript : MonoBehaviour {
[Header("Movement")]
[Range(0, 10)]
public float Speed;
@AtlasWeng
AtlasWeng / TextController.cs
Last active October 17, 2017 19:28
Using keyboard to control the game (Adventure game)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
public Text text;
private enum States {cell, sheets_0, mirror, lock_0, sheets_1, cell_mirror, lock_1, corridor_0,
stairs_0, floor, closet_door, stairs_1, corridor_1, in_closet, stairs_2,
@AtlasWeng
AtlasWeng / MovementScript.cs
Created October 16, 2017 17:51
Using script to let object move
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovementScript : MonoBehaviour {
// ATTRIBUTE
// [Range(-10, +10)]
public float Speed;
// public Vector3 Speed;
// public KeyCode RightKey, LeftKey;
@AtlasWeng
AtlasWeng / NumberWizard.cs
Created October 16, 2017 16:11
Console game named Number Wizard
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizards : MonoBehaviour {
// Use this for initialization
int max;
int min;
int guess;