Hi Guys.
Sorry for english,
I had made a code for move in vertical in a 2D game.
I can move, but the limit for max. and min. don’t work.
Seems that they said that a have to assing the object, but i already did it
It’s simple, i know… But what’s wrong?
THANKs!
var player : GameObject;
var maxHeight : float;
var minHeight : float;
var speed : float;
function Start () {
}
function Update () {
var move = Input.GetAxis("Vertical") * speed;
player.transform.Translate(0,move,0);
}
if (player.transform.position.y > maxHeight)
{
player.transform.position = new Vector2 (0, maxHeight);
}