So i am working on a simple game. the object you control moves forward only, forever, at a constant speed. you can only jump. i have some sort of script that my friend helped me with, but it doesn’t work. If any of you could, a little help would be nice.
here is the script:
var jumpHight : float = 3;
function Update () {
Vector3.Scale(transform.position + Vector3(0,0,1), transform.forward);
}
if (Input.GetButtonDown("Jump")){
rigidbody.AddRelativeForce(Vector3(0, jumpHight, 0));
}
var jumpHight : float = 3;
var speed : int = 10;
function Update () {
transform.Translate(Vector3.forward * speed);
if (Input.GetButtonDown("Jump")){
rigidbody.AddRelativeForce(Vector3(0, jumpHight, 0));
}}
I have the ridged body. Was close. forgot to add the var speed and i got the closing brackets off. but i ran into a small problem. Instead of going along the X axis, it is going along the z. should i add (speed, 0, 0) here: transform.Translate(Vector3.forward * speed);?