x


jumping error!?

i am making a 2d platformer that involves jumping but when i put my code in it gives me this error: Unknown identifier moveDirection. but i know it should a known identifier because it's highlighted orange!

my script:

var jumpSpeed = 5.0;

if(Input.GetKeyDown("UpArrow"))

{

moveDirection.y = jumpSpeed;

}

p.s. please help!

more ▼

asked Aug 19 '10 at 06:02 PM

john 2 gravatar image

john 2
75 29 35 46

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

It's unknown because you haven't defined it anywhere. You need to define variables before you can use them.

more ▼

answered Aug 19 '10 at 07:20 PM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

what do i need to put in after i type var moveDirection = ? if i put a number it comes up with an error.please comment back! thanks!

Aug 19 '10 at 07:35 PM john 2
(comments are locked)
10|3000 characters needed characters left

Try this.

var jumpSpeed = 5.0;
var moveDirection : Vector3;

if(Input.GetKeyDown("UpArrow"))
{
    moveDirection.y = jumpSpeed;
}
more ▼

answered Dec 10 '10 at 09:05 PM

Statement gravatar image

Statement ♦♦
20.1k 35 70 175

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1945
x198
x70

asked: Aug 19 '10 at 06:02 PM

Seen: 678 times

Last Updated: Dec 10 '10 at 09:08 PM