#Falling Damage for RPGB Third Person Controller

1 messages · Page 1 of 1 (latest)

neon bluff
#

I've seen during the last few months many requests for this feature, so here's my solution, made of a single component you add to the character prefab(s).
UPDATED #1021444621882101780 message

It has tooltips in editor but there are a few things worth mentioning.

1. This addon requires the standard RPGB controller

2. Falling Damage Formula
Character Mass x Falling Velocity / Falling Damage Resistance.

"Character Mass" and "Falling Damage Resistance" can optionally be set via RPGB Stats, but doing so (while interesting) will likely increase the complexity of your setup exponentially. You should think carefully before going that route.

Stats if present have priority (you could change the mass at runtime but it would be reset)

By default, Character Mass is set at 70 (overrideable in the editor) and Falling Damage Resistance is set to the value of Jump Speed in RPGBThirdPersonController. 70 kgs seemed a reasonable default value and I figured the stronger you jump the better you land.

Falling Velocity is the vertical speed of the character as defined by RPGBThirdPersonController. I am not touching it since my goal was to make a component that would work with RPGB out of the box, and to toy with it I should ask you to modify at least one of the core files.

3. Falling Time Threshold
I wanted to add a threshold below which your character is able to ignore any falling damage. My first thought was a distance, but I found out a timer would be functionally equivalent and MUCH simpler to setup and use.

4. Falling Effect
Create and add an Effect in the RPGB Editor for when the character takes falling damage but doesn't die. Use this to trigger anything you wish.

Quality
The code works, but is to be considered little more than a proof of concept. It could be refactored and improved, feel free to share tips, they're all welcome.

fathom ocean
#

this is only for the build in controllers or is this also for the John Stairs MMO Controllers

neon bluff
#

That is, unless John reads this and decides to integrate it himself (probably doing a better job tbh)

plush agate
#

Interesting. I tried it out and character take damage when jumping of a 50m high cliff when timer set to .5 instead of 1.5. The effect of falling and not dying, does not play though...will experiment. Thanks

#

Also, can mass be left as none?

#
FallingDamage.OnStatsChangeUpdateMassAndResistance (BLINK.RPGBuilder.Combat.CombatEntity entity) (at Assets/Scripts/FallingDamage.cs:66)
CombatEvents.OnStatsChanged (BLINK.RPGBuilder.Combat.CombatEntity entity) (at Assets/Blink/Tools/RPGBuilder/Scripts/Events/CombatEvents.cs:122)
BLINK.RPGBuilder.Combat.CombatUtilities.UpdateCurrentStatValue (BLINK.RPGBuilder.Combat.CombatEntity entity, System.Int32 statID, System.Single amount) (at Assets/Blink/Tools/RPGBuilder/Scripts/Combat/CombatUtilities.cs:115)```
#

if optional, it should not gen an error right?

#

Suggest you add a soundtemplate we can set to let player cry out in pain or something?

neon bluff
#

So thanks for pointing this out, I'll correct it

neon bluff
plush agate
#

Yep i got damaged down to 10% carried on running and did not die.

#

I like it though, so thanks for doing it 🙂

neon bluff
#

Meanwhile updated version upcoming, it should solve the errors festival... it does for me at least

#

OMG I deleted the original version, silly me

neon bluff
neon bluff
plush agate
#

I certainly will experiment more with it. Please ping me if you make any code changes/enhancements. So even with 0.5 delay you get your Shout effect to play then?

neon bluff
plush agate
#

will try, but can't right now

neon bluff
plush agate
#

I tried with .75 delay and two effects, none play for me, just fyi. i do get the falling damage of course.

plush agate
#

Another odd thing for me is that with your script active, npc cannot actually kill me, my health go to 0 but player still stands there and can move. when i disable your script, player does die as it should by npc attacks.

#

so i disabled it for now since it also throws a bunch of errors for the NONE slots as you know.

neon bluff
# plush agate so i disabled it for now since it also throws a bunch of errors for the NONE slo...

Mmm. Weird, since the errors should be corrected after the last change. Have you replaced the script with the last version?

Btw, I can’t imagine the reason for these bugs. None of those is even remotely expected, but I guess you live and learn. I haven’t tried fighting with the script on but I’ll try within an hour or two to double check.

Just to be sure: are you on the latest RPGB version?

neon bluff
plush agate
#

Version 2.0.6 and most current unity lts version. let me know how the fighting goes with script on yes.

neon bluff
plush agate
#

Well, not sure why mine is not working. show a screenshot of your settings please.

#

and which values/effects you used.

neon bluff
neon bluff
#

For me at least

plush agate
#

it is weird for sure.

#

could be a tag/layer issue?

#

on my side

neon bluff
#

Mmmm... idk, but seems unlikely.
Is there anything non-default about your Health Stat?

plush agate
#

and do you get console errors for the ones that are none?

#

no not at all, health stat is normal

neon bluff
#

#1021444621882101780 message

plush agate
#

ok let me get that version now, thanks

#

i am going to test the updated version now.

neon bluff
#

Great let me know, and if you have errors (new or old lol) pls share them so that I can have a look

plush agate
#

Hooray! The new version works and effects plays! with 1.5 delay.

neon bluff
plush agate
#

I will try a bit later with 0.5 as well, but works with 1.5 for sure.

#

Yep 0.5 works fine as well 🙂

#
UnityEngine.Debug:Log (object)
FallingDamage:OnControllerColliderHit (UnityEngine.ControllerColliderHit) (at Assets/Scripts/FallingDamage.cs:135)
UnityEngine.CharacterController:Move (UnityEngine.Vector3)
BLINK.Controller.RPGBThirdPersonController:UpdateState () (at Assets/Blink/Tools/RPGBuilder/Scripts/Controller/RPGBThirdPersonController.cs:203)
BLINK.Controller.RPGBThirdPersonController:LateUpdate () (at Assets/Blink/Tools/RPGBuilder/Scripts/Controller/RPGBThirdPersonController.cs:183)```
#

so it looks like there are no issues any longer. Thanks again for support.

neon bluff
plush agate
#

excellent. hope you come up with many other enhancements to rpgb. one thing I wish for is that my pet/companion would follow me from Scene A to Scene B and be persistent, but that is not currently possible as far as I know...

neon bluff
plush agate
#

I understand, it is a pain to keep track of core code changes and might not work in future versions, so make perfect sense.

neon bluff
neon bluff
#

My main issue (considering the low complexity of the task) is time, but I’ll do it 💪

solemn nova
#

@neon bluff
I hope this is the correct post :).

So I was testing John's controller and your fall dmg script. This is about jumping so it's not directly connected to your script but I was wondering if it could be added nonetheless since you already have a RPGB stat connection in it :).

John has a preset parameter for midair speed. (picture 1)
Currently you can only preset it to X. If you walk or run ingame and increase those movement stats you move quicker. However this midair setting will always be the preset amount. So you can run at speed 100 but if you jump you will slow down to this preset speed of 5. That looks weird/clunky.

So I was wondering if it would be possible to also make this midair setting into an RPGB stat like you did with jump height (picture 2 as a simple example).

neon bluff
#

As for the general clunkiness you were describing, is there anything specific I should check/improve in your opinion? 🙂

solemn nova
#

There is no general clunkiness :). At least not that I found up to now. 🙂 Just the running and then slowing down clunkiness haha.

solemn nova
neon bluff
#

The only thing I need is to check whether or not that value is public or not. If it's not, I can still modify it with some black magic but I'd rather ask John to set it to public instead

#

Give me some time since I masochistically started a project that is taking away all of my free time, and then this is going to be added to my todo list 🙂

solemn nova
#

okay awesome! Please keep me posted when you can 🙂

neon bluff
solemn nova
neon bluff
solemn nova
neon bluff
#

And this is the story of Min finding out it took 7 years to do it

solemn nova
#

HAHA

solemn nova
#

@neon bluff I thought of an addition. Simular to my other request.
A way to change the max times a player can jump. Now John has a predefined way to do this in the controller. It would be awesome if it would be possible to set default to 1 in the controller and then be able to use an RPGB stat to make it 2 or 3 etc. This is more a nice to have for me, but I would surely use it in my game if I would have it 😉.

neon bluff
solemn nova
#

@neon bluff 1 other thing I found out today (possibly a bug) is that the speed of falling is different if you fall from an object compare to when you jump.

The available options in your script don't allow me to change that fall speed or am I missing something? (Did a few tests but nothing seemed to changed).

If I remove your script it does work as intended, so it has to be something in your script I guess?

neon bluff
fathom ocean
#

m just saying

#

i have no clue

#

may be this can be set to lower numbers to see if it dos anything @solemn nova

solemn nova
# fathom ocean

I would expect that also. But changing those settings to 1000 or 1 doesn't seem to effect the jumping (not the regular jumping nor the falling from an object).

neon bluff
#

IIRC that is

#

But mass should only be used to calculate damage

#

I'll check asap guys, I'm finishing a BIG thing, please be patient 🙂

#

In fact I just quick checked the script directly from discord and I can't even see any reason why the script should do something to the fall speed. It reads it, but never changes it.

#

@solemn nova do you also have something else in your project that could interfere?
@fathom ocean have you experienced the same thing?

solemn nova
neon bluff
# solemn nova It's okay take your time 🙂

Wait since you use John's controller, you used THIS ==> #1027958068362879066 message
Right? Because this chat is the one about the falling damage for RPGBThirdPersonController and I realised that only now

solemn nova
neon bluff
#

On that script there might be something, the jump strenght stat. If John changed anything in the controller, since my script is a bit dated, there might be a bug potentially

solemn nova
#

Didn't know there are 2 almost the same addon channels haha.

#

This is the script so it's from the other channel 🙂

#

So the requests are also for the other script and not this 1 🙂

#

My bad

neon bluff
#

No worries, anyway I think I'll start checking the jump stat

solemn nova
fathom ocean
#

😅

solemn nova
#

HMMM think I might have found something. 1 sec gonna do a little more testing.

#

I can consistently fall normally and also not normally.

Normal =
Walk to the very last millilitre from the platform and give a minor left/right button tab so you fall off.

Not normal =
Just walk off pressing+hold left/right

#

Did test it with 3 characters.
John's basic character and John's basic + your script give the same results. As described above.

Blink character controller = always normal.

#

@neon bluff
So I don't think it's something caused by your script but in John's script. Still makes me wonder how can it work properly with @fathom ocean . Since hes using John's + your script if I recall correct.

fathom ocean
#

i have no problem the way it works right now i am fine with it, this is cos you dont like the way the jumping works in this controllers for me its fine the way it is

solemn nova
flat oreBOT
#

@solemn nova just reached level 7!

fathom ocean
#

@solemn nova try play around with the settings also the character controllers gravity can be a factor here

solemn nova
fathom ocean
#

here from longer falling distance

solemn nova
fathom ocean
#

@solemn nova i have a question did this work before the new Patch cos i also experience some ode stuff happening when John updated the last patch, but its not with jumping more other stuff, but maybe this can be the problem

solemn nova
fathom ocean
#

dos this also happen with out the falling damage script

solemn nova
fathom ocean
#

k i found the problem

#

i will recode to show

solemn nova
fathom ocean
#

this is the problem like i tried to explain to you before

solemn nova
#

I'm gonna test it right now awesome! 😄

fathom ocean
#

pls don't get up on those numbers this will pull you right down

solemn nova
fathom ocean
#

@solemn nova if you had listen first time when i try to help would save you like hours #1008698695656689788 message 😀

solemn nova
#

@neon bluff sorry to have bothered you with this none problem.

fathom ocean
#

i tryd to help but you must have missed the post

#

😅

solemn nova
fathom ocean
#

hey it happens to me all the time no bigey

#

dont be sorry

#

it happens

#

so much stuff to keep track of some time it will blow up or faces

#

😅

#

its normal

solemn nova
fathom ocean
#

a thanks buddy, just started to work on this map

solemn nova
#

I can only say keep up with this great work! Looking forward to a release to see the full content!

neon bluff
#

Thanks @fathom ocean I was starting to lowkey worry about this XD

solemn nova
fathom ocean
solemn nova
fathom ocean
#

yepo amazing scripts, he is good like that min taking time to help out community ❤️

solemn nova
neon bluff
#

And thanks to both for the kind words, I hope to get better and better. Sharing helps in this 😄

solemn nova
fathom ocean
#

@neon bluff sorry to bother, when you find some time, can you look in to the falling damage script you made, here is the question would it be possible for you to ad falling damage on distance, what i mean by that you already have added it only one part missing is the damage is always the same no meter the distance falling, Like lets say i fall from 30 meter's or 10 meters that would have a huge impact on my HP, but now no meter how tall my fall is i always take same damage, so if i am falling from 30 Meters Or 10 Meters the damage is the same

#

anyway as always not rush TY 💪

neon bluff
# fathom ocean <@764983142985498625> sorry to bother, when you find some time, can you look in ...

It could be done, right now iirc it’s based on impact velocity. (not at my pc and I haven’t looked at it in a while so I’ll check)

Which is ALMOST the same in theory, except when you hit terminal velocity the damage stops increasing.

I could probably add a selection for how to calculate it. Distance, velocity, time… and that’s it, those are pretty much the only three ways to calculate it 😂

#

BTW please try to use the right chat, this is for the RPGB controller (which BADLY needs an update asap anyway lol)

#

No problem of course, just a tip for the future 🙂

fathom ocean
#

its giving me this so i tooth its the right channel

#

is that not the addon

neon bluff
#

TADAAAN 🤣

fathom ocean
neon bluff
#

I’ll rename this chat to make it clearer, it’s my responsibility to keep it simple 🙂

neon bluff
#

BUT

neon bluff
#

If there’s a field like “maximum falling speed” in John’s controller, try messing with that, it should also affect falling damage

fathom ocean
neon bluff
#

Don’t overdo it, or if you fall from high enough you’ll go fast enough to pass through colliders

fathom ocean
#

this is bean added by support

neon bluff
#

The script here has about half the functionality and is for the default controller, I’d like to avoid confusion for other users

fathom ocean
#

understood 🤘

#

makes sense

neon bluff
neon bluff
#

Falling Damage for RPGB Third Person Controller