• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Parabola System

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hi!
I made some threads about jumping system. It was an epic fail . Now , I wish I find a solution : I have a 2D Platform System .... Easy to use, But , It's not smooth , where the jump isn't parabola . I need a parabola jump system that works on the ground ( not 3D ) . Please help :
The Unit must not leave the ground , I mean his Z is constant .+ The jump must be parabola ( smooth ) + It uses Regions So the platforms are regions ( It's like jumping from a higher cliff onto a lower one . the unit must not stop in the air ) when it found a region it stops ) + Thank you ( rep + Credits )
rcq4k3.jpg
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
On jump activation,
set VelocityX = 5 (the forward speed)
set VelocityY = 15 (the initial upward speed)

Every 0.03 seconds,
call SetUnitX( unit, GetUnitX(unit) + VelocityX) (move the unit forward)
set VelocityY = VelocityY - 1 (account for gravity)
animation - change unit flying height to (flying height of unit) + VelocityY at 0 (this will move the unit up for the first 15 ticks, and down for the next 15 ticks)

That's the basis of it. For exit condition, just check when the VelocityY = -15 (negative of the starting vertical velocity).
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, the "up" movement doesn't have to collide with your "Forward" movement.

Whenever you press "Up" You can increase/reduce the Z of your unit (Check a boolean first to prevent multi jumping). No need to manipulate the X/Y, since you can also manipulate those independently, without having to touch the Z thing. (This would allow you to "stop" your movement to any side while you're in the air. Will also allow straight jumping up)

Whenever you press "up" You periodically add about 5 + CONSTANT Z every 0.03. And every 0.03 reduce constant by a bit (0.1 or so). Eventually constant will become negative (Thats the top point of your unit) then it will start falling faster every time. The Base value (5) is determines somehow the initial jump speed. The constant will determine the Jump duration andd the Up/Down speed. When it reaches 0, just stop the thing and reset the values.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I know, i helped him with the 2D system he's working on. I say "Z" meaning the unit height from the floor reference. It got all messed up in my head :)

In his case it's "Y". My point is he can handle the Y jumping independently from the X movement.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Well I made my own parabola jump in the two dimensional ground .
Instead of insulting his intelligence, you could link a few tutorials about indexing... Like Things a GUI User Should Know. And it seems that he wants his jumping to only be two dimensional, with the WC3 y-axis as the up and down, and the x-axis as forward and backward.
That's what I meant , And well I know about GUI and MATH too . Okay , this is the system that I've made , but it seems it's too fast to detect that the unit has touched the ground ( which is a region ) , so it doesn't land correctly . This is parabola as I wanted . But I dunno how to slown it or idk because it seems to be faster than the speed to detect if the jumper enters a region(the unit goes deeper in the ground and some times it doesn't reach the ground) . Any other idea for how to detect the ground? ( not cliffs )
  • Init Constants
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set g_Acceleration = 981.00
      • Set h_JumpHight = 230.00
      • Set t_TimeStep = 0.03
      • Set const_X_Speed = 200.00
  • Up on
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
      • Player - Player 2 (Blue) Presses the Up Arrow key
      • Player - Player 3 (Teal) Presses the Up Arrow key
      • Player - Player 4 (Purple) Presses the Up Arrow key
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Jumping_No_Up[(Player number of (Triggering player))] Equal to False
        • Then - Actions
          • Set Jumpers_Y_Velocity[(Player number of (Triggering player))] = 1000.00
          • Set Grounded[(Player number of (Triggering player))] = False
          • Set Jumping_No_Up[(Player number of (Triggering player))] = True
          • -------- -------------------------------------------------- Set the correct Animation ----------------------------------------- --------
          • Animation - Change _Hero_2D[(Player number of (Triggering player))]'s animation speed to 100.00% of its original speed
          • Custom script: call SetUnitAnimationByIndex(udg__Hero_2D[GetConvertedPlayerId(GetTriggerPlayer())], 9)
        • Else - Actions
          • Set Jumping_No_Up[(Player number of (Triggering player))] = True
  • Set Velocity and Position
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set _IntegerFl_2D = 1
      • For each (Integer A) from 1 to _AmountPlayers_2D, do (Actions)
        • Loop - Actions
          • Set _tempPointDXD_2D = (Position of _Hero_2D[_IntegerFl_2D])
          • Set _tempPointD2_2D = (_tempPointDXD_2D offset by _BlockDistance2_2D towards 0.00 degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at _tempPointD2_2D) Not equal to _GroundStable_2D
            • Then - Actions
              • For each (Integer ForLoopIntegerC) from 1 to NumberOfJumpers, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Grounded[ForLoopIntegerC] Equal to False
                    • Then - Actions
                      • Set Jumpers_Y_Velocity[ForLoopIntegerC] = (Jumpers_Y_Velocity[ForLoopIntegerC] - (g_Acceleration x t_TimeStep))
                      • -------- Set the new position --------
                      • Unit - Move _Hero_2D[ForLoopIntegerC] instantly to ((Position of _Hero_2D[ForLoopIntegerC]) offset by ((Jumpers_X_Velocity[ForLoopIntegerC] x t_TimeStep), (Jumpers_Y_Velocity[ForLoopIntegerC] x t_TimeStep)))
                    • Else - Actions
            • Else - Actions
              • Do nothing
          • Set _IntegerFl_2D = (_IntegerFl_2D + 1)
      • Custom script: call RemoveLocation( udg__tempPointDXD_2D )
      • Custom script: call RemoveLocation( udg__tempPointD2_2D )
  • Stop Jump Ground
    • Events
      • Unit - A unit enters H0 <gen>
      • Unit - A unit enters H1 <gen>
      • Unit - A unit enters H2 <gen>
      • Unit - A unit enters H5 <gen>
    • Conditions
    • Actions
      • Set Stop_Jump_Ground = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to _Hero_2D[Stop_Jump_Ground]
        • Then - Actions
          • -------- Find THE ground (if it hits the ground) --------
          • Set Jumpers_Y_Velocity[Stop_Jump_Ground] = 29.43
          • Set Grounded[Stop_Jump_Ground] = True
          • Set Jumping_No_Up[Stop_Jump_Ground] = False
        • Else - Actions
      • Set Stop_Jump_Ground = (Stop_Jump_Ground + 1)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Set Stop_Jump_Ground = (Player number of (Triggering player))

"A unit enters Region" is not a Generic Unit Event, therefore (Triggering Player) returns null. Use "Owner of (Triggering Unit)"
 
Status
Not open for further replies.
Top