Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
How to implement double jump?

xchellx
Registered User
Quote
2018-04-20 07:55:20

How can I make a character double jump with the "controlable with keyboard" behavior?
I can take any scripting and such but Im not sure how to make my own jump script with it obeying the set gravity and such.


just_in_case
Moderator
Quote
2018-04-20 20:14:04

Well implimenting a single jump is tough enough.... but as you asked i have to answer your Question...

there can be many ways to do this..

theoretically the easiest and possible way to do a double jump is to by do later action...

when a key pressed do something "jump"... and then execute action Do later...
Set the minimum time... ( it should be when the player still in air)
and then execute the "jump" again..

instead of using the in built jump system i will recommend you to create your own.. as the inbuilt jump system is not good enough..

and if you can't use gravity, you can use change "Y" position of the object when a key is pressed down and after a few second revert back the "Y" position..

hope that helps ...

you can checkout this forum post and should download the ccb file provided by me... in which the player do jumps when "Z" key is pressed...


https://www.ambiera.com/forum.ph...

just download the provided ccb file and go to scene one and check out the root node behaviours for when a key pressed "Z" amd see how i implement the jump...

you can use the same method or develop your own using javascript.


xchellx
Registered User
Quote
2018-04-20 23:08:19

wrote:
Well implimenting a single jump is tough enough.... but as you asked i have to answer your Question...

there can be many ways to do this..

theoretically the easiest and possible way to do a double jump is to by do later action...

when a key pressed do something "jump"... and then execute action Do later...
Set the minimum time... ( it should be when the player still in air)
and then execute the "jump" again..

instead of using the in built jump system i will recommend you to create your own.. as the inbuilt jump system is not good enough..

and if you can't use gravity, you can use change "Y" position of the object when a key is pressed down and after a few second revert back the "Y" position..

hope that helps ...

you can checkout this forum post and should download the ccb file provided by me... in which the player do jumps when "Z" key is pressed...


https://www.ambiera.com/forum.ph...

just download the provided ccb file and go to scene one and check out the root node behaviours for when a key pressed "Z" amd see how i implement the jump...

you can use the same method or develop your own using javascript.


My issue is, even if setting the Y position relative to the scene node, it stops all momentum (player stops moving if you jump while moving) of the scene node.


just_in_case
Moderator
Quote
2018-04-22 10:00:46

yup but may be adding another change position action executed at the same time... using move forward into facing direction may solve this...
i am not sure if it will help.


just_in_case
Moderator
Quote
2018-04-23 16:16:00

if you know scripting a little bit you can use it on animate function.... see the 2d jump and run behavior for further help..


wild-master
Registered User
Quote
2018-04-23 23:48:14

Hello.

I created an example of double-jumping with CopperCube.

It's very complex, but I don't know an easier method.

Download the CCB file here:
https://drive.google.com/file/d/...

Open that file with CopperCube and then test the game.

Move with the "WASD" buttons, and press the spacebar to jump. If you press the spacebar again before the character touches the ground again, it will double-jump.

I spent so many hours to create the example that now I'm too tired to write a super-detailed description. Haha.

In the editor, click on the object called "Player" and then click its "Behavior" tab. Open the Behavior called "Every few seconds do something" and then open the JavaScript window inside of it.

Near the bottom, you will see this:
if (ccbGetCopperCubeVariable("IsPlayerJumping")==1&&ccbGetCopperCubeVariable("SpacebarPressesBeforeReset")<1&&IsHeightLimit1Reached==0) {
ccbSetSceneNodeProperty(player, "Position", currentXposition, currentYposition+5, currentZposition);
}

else if (ccbGetCopperCubeVariable("IsPlayerJumping")==1&&ccbGetCopperCubeVariable("SpacebarPressesBeforeReset")==1&&IsHeightLimit2Reached==0) {
ccbSetSceneNodeProperty(player, "Position", currentXposition, currentYposition+5, currentZposition);
}

For the bolded part that shows the number 5, you can try different numbers until you see a jumping speed that you like. Those numbers are also related to the "Gravity" setting of the root scene node, so you must test them until you find a good balance.

To find the gravity setting, click the root scene node in the "SceneGraphExplorer". It's called "DoubleJumpExample". Then click its Attribute window and you will see the gravity setting there.

When I tested my example, I discovered that the settings I had in the first patch of code, I mean the parts that are both set to the number 5, I realized that the number 5 combined with the gravity setting set to 1 will allow one huge jump of around that reaches a vertical position of around 400.

I tested by pressing the spacebar without releasing it and the character reached a spot of around 400, so I set a realistic number by setting the limit of the first jump to 130 and the limit of the second jump to 260.

I set the limit in the same JavaScript window that you saw before. Go back to it and look at the bottom to see this:
if (currentYposition > 129) {
ccbSetCopperCubeVariable("IsHeightLimitReachedJump1", 1);
}

if (currentYposition > 259) {
ccbSetCopperCubeVariable("IsHeightLimitReachedJump2", 1);
}

If you look at that code, you will realize that first jump will stop the character from moving higher after it reaches one point above 129, and the second jump will stop moving the character higher after it reaches one point higher than 259.

So you can see that I chose the number 5 for two settings, and a gravity setting of 1. When you test with those numbers, you should also change the number that says 129 in the second patch of code above. Change it to a crazy number, like 1000, so when you test your other numbers, your jump won't be limited and it can reach its full height. When you choose your other numbers, press and HOLD the spacebar to see how high the character can jump. The panel on the right will show you the vertical height of the character.

(My instructions will continue in the next post. This forum has a length limit for the posts.)


wild-master
Registered User
Quote
2018-04-23 23:51:28

(continued from the last post)

For example, if you hold the spacebar and the character reaches a height of 500 before it starts falling, you can then set the height limits of your first and second jumps. I discovered that the highest height that can be reached by both jumps combined must be less than or equal to the height of the one huge jump during testing. So, if your highest point reached with one gigantic jump is 500, then you could set the first jump's limit to 200 and also set the second jump's limit to 200 because the combined height of both jumps will be within the limit of 500. I don't know why that happens, but my limited intelligence might not be able to discover why.

You should also remember that the camera is tied to the object with the 3rd Person Camera mode, so checking if your jumps are working correctly might be difficult. If you want a better view of your jumps, you could remove the 3rd Person Camera feature from its Behavior tab, and place the camera extremely far away from the cube so you'll have a great view that will allow you to see many giant jumps without the camera seeming glitchy because it will have a static viewpoint.

I hope these disgusting instructions don't deter you. Please try the example and see if it works well for your needs. I don't know if my example contains glitches. The main annoying problem that I noticed is that the character seems like it falls down too quickly when either of the height limits is reached.

I hope a smarter person can improve my example to solve problems with it. I am almost empty of energy now!




IMPORTANT INFORMATION ADDED TO THIS MESSAGE LATER:
Ignore my messages in this thread. That's a bad way to achieve the goal of double-jumping.
A much better way is to use the script I contributed to in this thread:
https://ambiera.com/forum.php?t=...


xchellx
Registered User
Quote
2018-04-26 23:17:03

wrote:
(continued from the last post)

For example, if you hold the spacebar and the character reaches a height of 500 before it starts falling, you can then set the height limits of your first and second jumps. I discovered that the highest height that can be reached by both jumps combined must be less than or equal to the height of the one huge jump during testing. So, if your highest point reached with one gigantic jump is 500, then you could set the first jump's limit to 200 and also set the second jump's limit to 200 because the combined height of both jumps will be within the limit of 500. I don't know why that happens, but my limited intelligence might not be able to discover why.

You should also remember that the camera is tied to the object with the 3rd Person Camera mode, so checking if your jumps are working correctly might be difficult. If you want a better view of your jumps, you could remove the 3rd Person Camera feature from its Behavior tab, and place the camera extremely far away from the cube so you'll have a great view that will allow you to see many giant jumps without the camera seeming glitchy because it will have a static viewpoint.

I hope these disgusting instructions don't deter you. Please try the example and see if it works well for your needs. I don't know if my example contains glitches. The main annoying problem that I noticed is that the character seems like it falls down too quickly when either of the height limits is reached.

I hope a smarter person can improve my example to solve problems with it. I am almost empty of energy now!


I have taken someone's jump and move script which works perfectly for me but has a infinite jump issue.
I am now trying to make it work as a double jump.
If anyone wants to see my progress, here is my work:
https://www.mediafire.com/file/626d7s972x52lux/behavior_moveObjectByKeyboardWithDoubleJump.zip


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact