Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
How do I create a homemade jump without default settings but with JavaScript

en929
Registered User
Quote
2018-08-07 18:01:29

Let's say that I have two cubes. One cube is the player and the other is the floor. I am trying to make the player cube jump using the functions:

"When a key is pressed do something" --> "Key S" --> "Action" -> "Execute JavaScript"

That is, I want to make my character jump using JavaScript instead of the prebuilt in jump functions.

I also want to know how could I reuse the same code, make some slight changes to make my character fly at will?

Thankshttps://www.ambiera.com/forum/images/submitquick.png


just_in_case
Moderator
Quote
2018-08-07 18:15:05

go through this post... Xanimalking has made a behaviour for jumping by tweaking the script provided by me....
https://www.ambiera.com/forum.ph...


en929
Registered User
Quote
2018-08-08 17:23:49

Just_in_case, I was trying to make my character fly with this code below. The code below is something that I found on this forum a long time ago. But, I don't fully understand how it works - I'm sorry, I'm kind of an intermediate leveled programmer. But, I'm not very advanced yet.




//moves up

/////////////////////////////////
//Let's get the player reference and position and rotation
player=ccbGetSceneNodeFromName("Henry");
curPos=ccbGetSceneNodeProperty(player,"Position");
curRot=ccbGetSceneNodeProperty(player,"Rotation");

//The Y xis will tell us what direction the player is facing
playerDir=curRot.y;


moveX=(-Math.sin(playerDir*Math.PI/180))*2.6;
moveY= -12
moveZ=(-Math.cos(playerDir*Math.PI/180))*2.6;
vecMove=new vector3d(moveX, moveY,moveZ);

newPos=curPos.substract(vecMove);
//let's move the player
ccbSetSceneNodeProperty(player,"Position",newPos);




I use the "U" key to make my player go up. But, when I release the U key via the "if key is pressed do something ---> if key is let up" scenario, my player just stays in the air and doesn't go down. Thus, how do I fix the code above to make the player go down. It seems like it could be something simple. But, I don't know what it is.


faith_254
Registered User
Quote
2018-08-20 08:19:14

to make it go down create a when key left up
set value to Camera1.CanFly or Camera1.AffectedByGravity
False or True


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (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