- Home /
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;
}
}
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.
Answer by bodec · Apr 11, 2012 at 04:19 AM
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.
would not allow me to edit but im assu$$anonymous$$g you are using the isGrounded like its used in common practice the the below collider is touching
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);
}
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 I$$anonymous$$PORTANT , 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.
I had no idea, apologies, too used to forums!
Assets/Standard Assets ($$anonymous$$obile)/Scripts/CameraRelativeControl.js(109,9): BCE0044: expecting EOF, found 'else'.
Is the error im getting.
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 ter$$anonymous$$ating 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 =]
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
CharacerController not allowing mid-air movement 1 Answer
Disable movement control during jump 3 Answers
jump in air 0 Answers
In Air Movement 0 Answers