Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Fall Damage

Manangwe
Guest
Quote
2017-05-09 02:12:18

So, I am going to take a bash at scripting fall damage..

The idea is to calculate the distance between colision of the player and any other object on the verticle access.

If the distance is over a certain limit, health will be deducted as based on the distance...

Does anyone have any better ideas before I give this a bash?


tim12345
Guest
Quote
2017-05-09 02:24:30

i hear ya, I got fall damage on my 'to do' list as well but I just haven't got around to it yet...my first thought was to calculate the time it takes to fall rather than the distance, but maybe you are more correct


Manangwe
Guest
Quote
2017-05-09 05:26:38

Ok, so here is my code and it works


First set a coppercube variable...I called mine "Altitiude" Then run this code every second using the looped interval behavior (Can't remember what it is called)

---------------------------------------------------------------------------------

var LastAltitude = ccbGetCopperCubeVariable("Altitude");
print(LastAltitude);

var s = ccbGetSceneNodeFromName("Camera1");

var position = ccbGetSceneNodeProperty(s, "Position");

ccbSetCopperCubeVariable("Altitude", position.y)

var currentAlt = position.y;
currentAlt = currentAlt + 60;
if(LastAltitude > currentAlt)
{

print("Died");

}else
{

print("Working");

}

-------------------------------------------------------------------------

That's all


Manangwe
Guest
Quote
2017-05-09 05:27:55

Oh yea, forgot to mention that I used gravity of 10 and a 1 second interval on loop behavior


tim12345
Guest
Quote
2017-05-09 06:16:26

hm, not quite how I would implement it, but could be useful... thanks for sharing!


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