- Home /
How to jump multiple times to mid air?
Okay, so I'm writing this swimming script, but I'm have some problems on the final core pieces of it. Right now, I have the game successfully identifying whether or not your under water. When you are, it it changes basic movement controls such as speed, gravity, fall speed, etc. That way, it makes it look like your swimming through water, even though it just modifies you movements and gravity. Now, I need to make it so you can swim up and get to the surface. Right now, all you do is sink to the bottom. When you jump, you move up slowly, but eventually sink back to the bottom. I want the player to be able to press the space bar in mid air, and the character would jump again, even if they are not grounded. It's similar to the swimming controls in Minecraft.
I'd like to simply be able to modify the existing CharacterController.js script if that's possible. Any idea's or alternate ways?
There are many ways of doing this. If we write something from the top of our head, it would maybe not fit your scenario that well. If you post some code, it would be more easy for us to help you.
Answer by brumdogpro · Nov 24, 2011 at 09:35 PM
I don't know how your code looks but you can add a boolean value such as "isUnderwater" to the scripts and set it to where the player can jump:
if(isGrounded || isUnderwater)
{
}
That is the approach I would probably take. Hope I helped out a little.
Answer by Kacer · Nov 24, 2011 at 11:12 AM
You can access a "IsGrounded" bool in the charactercontroller from another script, if you forcefully set that to false you're able to jump indefinately.
Your answer
Follow this Question
Related Questions
Natural Jump algorithm 2 Answers
Joystick - movement and jump in the same direction 0 Answers
i'dont want double Jump 1 Answer
Modifing Standard Assets FPC to swim 0 Answers
controller.Move not working correctly 0 Answers