Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Fall Damage??

behroz-khan
Registered User
Quote
2018-07-04 09:44:13

I am creating FPS game and when the player gat's high and jumps down, he get's no damage! In good games like IGI the player get's damage when he jumps from high places. In simple words can Fall damage be possible in Coppercube???


just_in_case
Moderator
Quote
2018-07-04 14:16:41

Maybe this post can help you out....
https://www.ambiera.com/forum.ph...


behroz-khan
Registered User
Quote
2018-07-06 08:21:49

I took a closer look at that script but it seems to me that when our altitude will be high and when player will jump from there, player will die!!
I need:
When player is at 10 altitude, player will get 10 damage
When player is at 30 altitude, player will get 30 damage
When player is at 60 altitude, player will get 60 damage
And so on.....
And When player is at 100 altitude, player will die.


just_in_case
Moderator
Quote
2018-07-07 03:42:09

You can use variable for that....or you can use my precreated behaviour to check the altitude then compare it or you can script something like this by yourself....

Here is the link to the post containing my behaviour.....
https://ambiera.com/forum.php?t=...
https://ambiera.com/forum.php?t=...

Link to another intresting post...

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


behroz-khan
Registered User
Quote
2018-08-18 12:49:46

You gave me the behavior_altitude.js but it is only to show the height not to get the damage....


behroz-khan
Registered User
Quote
2018-08-29 22:15:09

No answer...


karmacomposer
Registered User
Quote
2018-08-29 22:36:21

You will likely have to do some programming yourself or hire someone. Like my problems, at some point in game creation you have to get your hands dirty if you're a one man show.

Mike


xanimalkingx
Registered User
Quote
2018-08-30 01:48:30

Exactly what I did for a double jump feature.


just_in_case
Moderator
Quote
2018-08-30 09:06:12

i have already answered you @behroz khan and provided you with the solution on some other post...all you are doing is asking again and again the same thing on different post... while the solution to your issue has already been provided to you..
am not saying that don't ask questions all am saying is please try the solutions provided to you before repeating your question..


behroz-khan
Registered User
Quote
2018-08-30 11:24:07

I have tried but it only shows altitude and do not takes damage.
So please help me with this.

I will give you a credit in my game..
http://behrozkhan.wixsite.com/ex...

Exellar game designing studio


just_in_case
Moderator
Quote
2018-08-30 14:04:12

okay! here is the implementation of the code... you can change the code as per your requirements...
try pressing spacebar for a jump and when the player reaches ground it will take damage by -10 and if you do a double jump the damage will be higher...and so on...

here is the link to download the ccb file:-
https://drive.google.com/file/d/...


karmacomposer
Registered User
Quote
2018-08-30 15:58:24

@JIC - NICE!

You are much appreciated.

Mike


DeltaXGames
Guest
Quote
2019-03-18 19:21:15

I implemented this in my project by drawing 3 lines from the player to the ground and calculated how long these lines were above the land.

Here's the code from my project (Sorry it's a bit sloppy, I'm not a great programmer, I write this in a way I would best understand, If you have any questions, you can send me a message on facebook www.facebook.com/deltaxgames).


var __deltaTime=0;
var __lastTime=0;
var isFirstCount=true;

function getDeltaTime()
{
var now=(new Date()).getTime();

if (isFirstCount) {
__deltaTime=0;
isFirstCount=false;
} else {
__deltaTime=now-__lastTime;
}

__lastTime=now;
}

ccbRegisterOnFrameEvent(getDeltaTime);



var player=ccbGetSceneNodeFromName("Player scene node name");
var playerHeight=18; //the height of the player
var canClimbLadder=false;
var isFalling=true;
var inAir=true;
var airTime=0;
var isFirstFall=true;

function gameLoop() {
//check if player is falling
var playerPos3D=ccbGetSceneNodeProperty(player, "Position");
var playerBottomYPos=playerPos3D.y-playerHeight;
var startPos3D = playerPos3D;
if (ccbGetCollisionPointOfWorldWithLine(startPos3D.x, startPos3D.y, startPos3D.z, startPos3D.x, playerBottomYPos, startPos3D.z)||ccbGetCollisionPointOfWorldWithLine(startPos3D.x, startPos3D.y, startPos3D.z, startPos3D.x+20, playerBottomYPos, startPos3D.z)||ccbGetCollisionPointOfWorldWithLine(startPos3D.x, startPos3D.y, startPos3D.z, startPos3D.x-20, playerBottomYPos, startPos3D.z)||ccbGetCollisionPointOfWorldWithLine(startPos3D.x, startPos3D.y, startPos3D.z, startPos3D.x, playerBottomYPos, startPos3D.z+20)||ccbGetCollisionPointOfWorldWithLine(startPos3D.x, startPos3D.y, startPos3D.z, startPos3D.x, playerBottomYPos, startPos3D.z-20)) {
isFalling=false;
inAir=false;
} else {
isFalling=true;
inAir=true;
}

//calculate AirTime
if (inAir) {

airTime+=__deltaTime;

} else {

if (airTime>0) print("Last Air Time: "+(airTime/1000)+" Seconds");

//damage player if he falls from a high place (falls for more than 800 miliseconds)
if (airTime>=800) {
var name=ccbGetSceneNodeProperty(player, "Name");
currentHealth=ccbGetCopperCubeVariable(""+name+".health");
ccbSetCopperCubeVariable(""+name+".health",currentHealth-(airTime/40));
}

airTime=0;
}

}
ccbRegisterOnFrameEvent(gameLoop);


DeltaXGames
Guest
Quote
2019-03-18 19:23:34

Ooh and yeah you must put this in an Execute Javascript action. And add that action to a on First drawing do something behavior in the root scene node.


Create reply:


Posted by: (you are not logged in)


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