- Home /
Finishing game script c#
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);
}
}
Answer by Hoeloe · Sep 28, 2013 at 04:45 PM
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.
No problem. If my answer was helpful, please mark it as accepted!
Answer by Ericroy · Sep 28, 2013 at 04:06 PM
Be sure to add Scena2 in the build window.
I did it, but it doesn't work. error CS1041: Identifier expected
Your answer
Follow this Question
Related Questions
End game then an Object is close to another object? 0 Answers
how do you actually stop a game? 3 Answers
Problems with script 1 Answer
Bullet Fire script not working 1 Answer
Manipulate object on a tablet 1 Answer