Question by
mike1233 · Feb 03, 2017 at 11:17 PM ·
c#javascriptscripting problem
convert this 3 line code to c# ? i cant figure it out?
i need to convert to c form java
I keep getting errors
#pragma strict
function Start () {
}
function Update(){
if (transform.position.y <-5){
GameOver();
}
}
function GameOver()
{
Application.LoadLevel("Menu");
}
Comment
remove the pragma line, replace function with void and use Scene$$anonymous$$anagement.Scene$$anonymous$$anager.LoadLevel ins$$anonymous$$d of Application.LoadLevel
Best Answer
Answer by brunocoimbra · Feb 04, 2017 at 04:41 PM
using UnityEngine;
public class #YOURFILENAME# : MonoBehaviour
{
private void Start()
{
}
private void Update()
{
if (transform.position.y < -5)
{
GameOver();
}
}
private void GameOver()
{
Application.LoadLevel("Menu");
}
}
Don't forget to replace #YOURFILENAME# with, guess what, the name you gave to your script.
If you are trying to learn C# and already know UnityScript: http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html
Also, not that it really matters by now, but "C" and "C#, as "Java" and "JavaScript (which is not really JavaScript, but this is how Unity calls it, while others calls it as UnityScript)" are all different things.