x


In air movement troubles.

okay, been trying for3 hours, 4 in the morning, i lost my has wiped my big long explanation TWICE, but basically in a nutshell id really appreciate some help getting this code to allow in air movement.

// Check for jump
if ( character.isGrounded )
{
    if ( !rotateJoystick.IsFingerDown() )
       canJump = true;


    if ( canJump && jumpjoystick.tapCount == 1 )
    {
       // Apply the current movement to launch velocity

       velocity = character.velocity;
       velocity.y = jumpSpeed;





       canJump = false;
    }
}
more ▼

asked Apr 11 '12 at 03:35 AM

shinodan gravatar image

shinodan
0 3 5 6

Just a tip : if you are writing in a browswer and it refreshes or you just lose all your text , try writing in a blank notepad First, then just copy-pasta to where you want to post it. I told my sister this also, she was always getting cranky at FB for this problem.

Apr 11 '12 at 08:36 AM alucardj
(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

your if statement at the start is checking to make sure you are on the ground so before any of the rest of the code will work you have to be grounded.

more ▼

answered Apr 11 '12 at 04:19 AM

bodec gravatar image

bodec
354 6 13 19

would not allow me to edit but im assuming you are using the isGrounded like its used in common practice the the below collider is touching

Apr 11 '12 at 04:20 AM bodec

I think @bodeci has the right idea here, maybe add some Debug.Log 's in to see where the code is breaking. This should show you where in the code you are.

// Check for jump
if ( character.isGrounded )
{
    if ( !rotateJoystick.IsFingerDown() )
    canJump = true;

    Debug.Log("isGrounded:canJump = " + canJump );
}


if ( canJump && jumpjoystick.tapCount == 1 )
{
    // Apply the current movement to launch velocity
    velocity = character.velocity;
    velocity.y = jumpSpeed;

    canJump = false;

    Debug.Log("jumpjoystick:canJump = " + canJump);
}
Apr 11 '12 at 08:37 AM alucardj

the Debug.Log is giving an error? please copy the message from the console, and post a comment with this error as this can be very helpful in finding where it is breaking. I cannot see it being a null reference , as canJump is declared right before the Debug.Log print-in-console.

And Remember (this is IMPORTANT , it keeps all the 'site users happy , and you won't get negative marks on your karma) Don't comment in answer boxes , Please.

Look straight under this message. to the right, under my name alucardj, there is a little box saying 'add new comment'. Click On This, then a window opens up where you can type. Post your error message here. Put ALL your Comments here. NEVER use the Answer box, that is the solid rule, ok. Thanks.

Apr 12 '12 at 10:42 AM alucardj

I had no idea, apologies, too used to forums!

Assets/Standard Assets (Mobile)/Scripts/CameraRelativeControl.js(109,9): BCE0044: expecting EOF, found 'else'.

Is the error im getting.

Apr 12 '12 at 10:51 AM shinodan

No worries , thought I would point that out so people wouldn't be unfriendly about it to you.

ok , in your code , what is at line 109 to 118 ?

At a guess , there is a mis-placed } somewhere , so the function is terminating before the else statement is being reached.

You can post this as a comment, or, would it be possible to edit your original question at the top, delete your old code and paste in the full code you are using now? If the formatting and browser refresh is a problem , just comment =]

Apr 12 '12 at 10:59 AM alucardj
(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:

x1371
x336
x224
x57
x19

asked: Apr 11 '12 at 03:35 AM

Seen: 525 times

Last Updated: Apr 12 '12 at 02:11 PM