Just a simple question about falling damage

Discussion and feedback on Construct 2

Post » Sun Feb 08, 2015 3:48 pm

Hi!
To make it simple, I'm simply trying to understand how this works. So far I got this working, but I would like to understand the reason for this.

Platform behavior for Character
max Fall Speed is set at 960
global variable maxFallHeight set at 0

So if PlayerDetect.Platform.VectorY > maxFallHeight ------> Set maxFallHeight to PlayerDetect.Platform.VectorY

So onLanded and if maxFallHeight > 704, Player receives damage.

Now, that's the part I would like to understand since I would like to have the control over it to set it at a distance in pixels. For now it doesn't seems to match the actual height (distance) in pixels.

Thanks in advance!
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Sun Feb 08, 2015 4:31 pm

Rename maxFallHeight to maxFallSpeed and it might make more sense. VectorY is the speed the player is moving vertically - ie. the speed they're falling at. maxFallHeight keeps track of the highest speed that the player reaches and if that is > 704 then when they land they take damage. Of course you'd want to then set it back to zero before the next fall.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610

Post » Sun Feb 08, 2015 5:35 pm

Yes, it's set back to zero. Like I mentionned in my post, it works fine. My question was how can I set it so it's a distance based in pixels, and not pixels per second
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Sun Feb 08, 2015 9:29 pm

Sorry I thought you asking how that works. To get the fall height in pixels you can store the players y position when they begin falling and then subtract that from the y position when they've landed.
You do not have the required permissions to view the files attached to this post.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610

Post » Sun Feb 08, 2015 9:58 pm

Thanks! Thats's exactly what I needed.
In my current project I need to have a better control over the distance fall and the only way was knowing the height in pixels.

Thanks again

Cheers
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Feb 11, 2015 2:47 am

Ok, I'm going to be annoying again :D
I can presently see the falling distance in pixels, and at a certain height I can have my player receiving damage. But when using Player.Platform.VectorY it works but if I change it to instead detect the Player Y position in pixels, it no longer works.
I tried different options but its not working as I need it.

To be precise, I need to set up my falling distance in pixels so after x amount of pixels Player loses x amount of energy and so on. With Vector position it becoems a little more difficult to set up based on the levels layout.

Thanks in advance!
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Feb 11, 2015 11:02 am

Just add a health variable subtract the value of damage from the health variable, your free to add a damage variable if you want.
B
8
S
2
Posts: 134
Reputation: 1,001

Post » Wed Feb 11, 2015 12:24 pm

Thanks but that's not what I'm asking.
I'll try to explain it better. When I use Player.Platform.VectorY I have to set up a number like 700, so if the height is higher is 676 then Player receives damage.
But, this is equivalent (aproximately) to 192-3 pixels.

Now, what I would like to do is actually say that if my fall is higher than 192 pixels there's damage.
When I use Player.Y instead of Player.Platform.VectorY it simply doesn't work.

My problem is having to use a number like 676 instead of 192 specially since I need some degree of precision for my project.
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Thu Feb 12, 2015 12:45 pm

Thanks, I found a proper solution for this :)
B
43
S
12
G
14
Posts: 488
Reputation: 10,570


Return to Construct 2 General

Who is online

Users browsing this forum: Kyatric and 8 guests