Function purpose
|
Syntax
|
Spawning an object
|
Instantiate(object_name,transform.position, Quaternion.identity);
|
Removing an object
|
Destroy(gameObject);
|
Controlling the position of
an object
|
object_name.transform.Translate (x position, y position, z position);
|
Moving an object
|
var vel = rigidbody2D.velocity;
vel.x = object_speed;
rigidbody2D.velocity = vel;
|
Referring to a particular
object
|
GameObject.Find("object_name");
|
Referring to a tag
|
CompareTag ("tag_name");
|
Collision detection
|
void OnTriggerEnter2D(Collider2D);
|
Returning a random number
from a specified range
|
Random.Range(minNum, maxNum);
|
Accessing a variable from
another class
|
GameObject variableName = GameObject.Find("object_name");
Class_Name classVariableName = variableName.GetComponent<Class_Name>();
|
Calling a function from
another class
|
objectVariableName = GameObject.Find("object_name").transform;
objectVariableName.gameObject.SendMessage ("Spawn",null,SendMessageOptions.RequireReceiver);
|
Calling a class every so
seconds
|
InvokeRepeating("function_name", startTime, repeatitionTime);
|
Adding an OnClick listener
|
Input.GetMouseButtonDown(0);
|
Reloading a level
|
Application.LoadLevel(0);
|
Spawning text
|
GUI.Label(new Rect(x position, y position, x size, y size), "text");
|
Setting the game orientation
to portrait
|
Screen.orientation = ScreenOrientation.Portrait;
|
Playing audio
|
if (!audio.playOnAwake){
audio.Play();
}
|
This adds up to 16 pieces of code I have learned and used throughout the production of Square Drop. I have also used plenty of boolean, GameObject, and int variables, however having learnt how to use those already before the dissertation, I didn't include them in this list dedicated particularly to C#.
After possible Square Drop iterations due to feedback from my playtesters, I'm hoping to then create another prototype, and learn more code.
No comments:
Post a Comment