Alright guys I am trying to code a basic crane in C#. What i need it to do is just move left and right and up and down, and to be able to pick up objects. If anyone here can help me out that would be great!
What kind of crane?
it is a simple crane which you control left right forward and back, and space to go down,
var speed = 10.0;
var trans : int;
var go_down : boolean;
go_down = true;
var c_stable : boolean;
trans = 0;
function Update () {
// Get the horizontal and vertical axis.
// By default they are mapped to the arrow keys.
// The value is in the range -1 to 1
if (trans == -5){
go_down = false;
c_stable = false;
}
if (trans == 0){
c_stable = true;
go_down = true;
}
transform.Translate (0, trans, 0);
if (Input.GetAxis (“Jump”)){
if (go_down == true c_stable == true){
trans = trans - 1;
}
if (go_down == false c_stable == false){
trans = trans + 1;
}
}
var vtranslation = Input.GetAxis (“Horizontal”) * speed;
var htranslation = Input.GetAxis(“Vertical”) * speed;
// Make it move 10 meters per second instead of 10 meters per frame…
htranslation *= Time.deltaTime;
vtranslation *= Time.deltaTime;
// Move translation along the object’s z-axis
transform.Translate (0, 0, htranslation);
transform.Translate (vtranslation, 0, 0);
}
function wait(){
yield WaitForSeconds(5);
}
here is what i have now but the going down does not work