Just a simple question about falling damage

0 favourites
  • 9 posts
From the Asset Store
This sound pack features 117 game sounds : Axe,Punch Swing & Hit & Damage. This is a perfect collection for your game.
  • 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!

  • 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.

  • 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

  • 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.

  • 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

  • Ok, I'm going to be annoying again

    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!

  • Just add a health variable subtract the value of damage from the health variable, your free to add a damage variable if you want.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, I found a proper solution for this

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)