0% found this document useful (0 votes)
125 views3 pages

CSharp Unity CheatSheet

This document is a C# cheat sheet designed for Unity beginners, covering basic syntax, functions, conditional statements, loops, classes, and Unity-specific methods. It includes examples of player movement, input handling, and accessing components. The cheat sheet serves as a quick reference for essential coding concepts in Unity development.

Uploaded by

gamerhunter492
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views3 pages

CSharp Unity CheatSheet

This document is a C# cheat sheet designed for Unity beginners, covering basic syntax, functions, conditional statements, loops, classes, and Unity-specific methods. It includes examples of player movement, input handling, and accessing components. The cheat sheet serves as a quick reference for essential coding concepts in Unity development.

Uploaded by

gamerhunter492
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

C# Cheat Sheet for Unity Beginners

1. Basic Syntax

int score = 0;

float speed = 5.5f;

string playerName = "Jainam";

bool isAlive = true;

2. Functions / Methods

void Start() {

Debug.Log("Game Started!");

void Update() {

MovePlayer();

void MovePlayer() {

transform.Translate(Vector3.forward * Time.deltaTime);

3. Conditional Statements

if (score >= 10) {

Debug.Log("You Win!");

} else {

Debug.Log("Keep going!");

4. Loops

for (int i = 0; i < 5; i++) {

Debug.Log("Level: " + i);

5. Classes & Objects

public class Player {


public string name;

public int health;

public void TakeDamage(int damage) {

health -= damage;

6. Unity Special Methods

void OnTriggerEnter(Collider other) {

Debug.Log("Touched: " + other.name);

7. Accessing Components

Rigidbody rb;

void Start() {

rb = GetComponent<Rigidbody>();

rb.AddForce(Vector3.up * 5, ForceMode.Impulse);

8. Input Example

void Update() {

if (Input.GetKeyDown(KeyCode.Space)) {

Jump();

void Jump() {

Debug.Log("Jumped!");

9. Public Variables in Unity

public float moveSpeed = 5f;

void Update() {

transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);


}

10. Printing to Console

Debug.Log("Hello, Unity!");

You might also like