Hey guys! I am making a game in which the player has to shot the cube by the ball. After thet cube disappears. Now i have to write script which would take player to another scene (I mean after the disappear of the cube). So far i wrote such script but it doesn’t working
using UnityEngine;
using System.Collections;
public class nextScene : MonoBehaviour {
function OnControllerColliderHit (hit : ControllerColliderHit){
if(hit.gameObject.name == "s")
Application.loadlevel(Scena2);
}
}
Your problem is that that isn’t C# code. That’s half C#, half UnityScript. There is no keyword function in C#, because you have to explicitly state the return type of the function instead (in this case, void, meaning nothing is returned). Also, types in C# are not specified using the : notation as they are in UnityScript. That is reserved for inheritance (which you have used correctly after “nextScene”). Instead, you simply write the type, followed by a space, followed by the variable name. So, where in UnityScript you might write var x : int = 4;, in C#, you would write: int x = 4;. I suggest you look up some basic C# tutorials to get familiar with some of the concepts and syntax.