Announcement

Collapse
No announcement yet.

Fall damage based on distance fallen rather than velocity?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Fall damage based on distance fallen rather than velocity?

    Hello, I'm using the rather common way to calculate fall damage which is to take your last known velocity and apply damage based on that on landing, but I wanted to get more variation in the fall damage by getting distance fallen and applying damage per 0.2meters for instance. I'm not sure how to track how far I've fallen so if someone could point me in the right direction that'd be great.

    #2
    If you want to keep track of distance fallen, I would store your current z location value in a variable the moment that you are simultaneously moving downward (-z velocity) and not touching the ground (otherwise walking down a slope will count as "falling"). Then later when you hit the ground, get the distance you fell by subtracting your start fall position z and your current z location.
    You can find me on twitter: @graeme_crackers

    Comment


      #3
      Thanks Graeme_Crackers . I did that and it works, now to just balance out the numbers.
      Click image for larger version

Name:	FallDamage.JPG
Views:	128
Size:	197.0 KB
ID:	1425184
      The "Fall Damage" function is just calculating the damage by distance fallen, everything necessary is visible. First branch is connected to event tick, just in case anyone wants to know what I did.
      Attached Files

      Comment


        #4
        I think that fall distance is a better and a more accurate indicator than velocity as when grabbing some type of objects also hanging into objects the velocity due to impact might give a very high negative reading, thanks and good Job guys.

        Comment

        Working...
        X