hi everyone, i’m new both to unity and this commnity but i really like this wolrd so i’m trying to set up a game base on which build a little “test game”.
this base is simply a setup for camera and movements but i encountered troubles trying to make my character jump and fall…
i’m going to explain the situation:
in the scene there are only a cube (floor), a light, a cam and a sphere to which i attached a character controller and this script
function Update () {
var c:CharacterController = GetComponent(CharacterController);
if(c.isGrounded){
var moveD = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
if(Input.GetButtonDown("Jump")){
moveD.y=100;
}
c.SimpleMove(moveD*15);
}
}
function LateUpdate(){
var c:CharacterController = GetComponent(CharacterController);
var Gravity = Vector3(0,-20,0);
c.SimpleMove(Gravity);
}
function OnGUI(){
var controller : CharacterController = GetComponent(CharacterController);
if(controller.isGrounded){
GUI.Label(Rect(10.0,10.0,300.0,30.0),"Grounded");
}
}
@script RequireComponent(CharacterController)
the movement works fine but the jump and the gravity (i tried different values for the movement with no change) don’t work…
can anyone explain me why this doesn’t work? where am i missing? i’d really like to understand
thank you in advance for any explaination