How to limit momentum

Hello, i'm having trouble trying to limit z momentum of the character ability, its suppose to make the character bounce higher on each bounce but stop to certain height but keep going higher.
Is there a way to make it stop bouncing higher, I tried searching in the wiki but couldn't find anything useful.

Thanks in advance.

Here the code.

[CODE=lua]//power bounce addHook("JumpSpinSpecial",function(player) if player.mo.skin ~= "mk2sonic"//if not mecha sonic return false return end local LIMIT = 17 // ground bounce height limit local fixedz = FixedMul(FRACUNIT/2, player.mo.momz) // multiply z movement by 0.5(bounce momentum) if player.bouncing == nil // if var nil player.bouncing = 0 // make it end if player.bouncing == 1 //if bouncing 1 and not (player.pflags & PF_SPINDOWN) //and not holding spin player.bouncing = 0 //make it 0 end if (player.pflags & PF_JUMPED) // if player jumped and (player.pflags & PF_SPINDOWN) // and holding spin player.pflags = $1|PF_BOUNCING //player flag = bouncing if not (player.panim == PA_ABILITY) //if animation not ca_ability(bounce) player.state = S_PLAY_BOUNCE // force it to animation bounce player.bouncing = 1 //bouncing is true(bad place to put but it works) end else // else return false return end if (player.eflags & MFE_JUSTHITFLOOR) // if player just hit floor and (player.pflags & PF_SPINDOWN) // and holding spin player.state = S_PLAY_BOUNCE_LANDING // set player animation to bounce landing if fixedz >= (LIMIT) P_SetObjectMomZ(player, 17*FRACUNIT) else P_SetObjectMomZ(player, fixedz) //bounce up print("bounceup") end end end) [/CODE]
 
please put your code in one of these
1696902794136.png

LIMIT is 17, and youre comparing it with a fixed scale number, which is like comparing 2 and 17/65536 in regular math. try multiplying it by the player's scale
 
please put your code in one of these
View attachment 102542
LIMIT is 17, and youre comparing it with a fixed scale number, which is like comparing 2 and 17/65536 in regular math. try multiplying it by the player's scale
So do I need to use fixedmul something like, fixedmul(limit, scale)?
I'm new to modding, so could you please give me an example much appreciated.
Sorry for my bad english.

Edit: it worked using fixedmul, but sadly I didn't get the desired result since limit is always smaller than fixedz, I think it end up comparing mom z at max height rather than current height or something like that.
 
Last edited:
So do I need to use fixedmul something like, fixedmul(limit, scale)?
I'm new to modding, so could you please give me an example much appreciated.
Sorry for my bad english.
Doing something like LIMIT*p.mo.scale is what I meant, but using that would be better
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top