Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Creating a Jump System

Spoon

Member

Hi guys : )

I'm trying to make a jump system on RPG maker XP.. I've managed to do a lot so far
But I'm a bit stuck as to how to fix this one problem

Basicly what I've made is a common event, where if you press Q, the player jumps forward 2 squares. Heres my event:

Code:
[img]http://i307.photobucket.com/albums/nn310/TheSpoonFtw/CommonEvent1-2.jpg[/img]
Now I had a problem where it would crash if you ordered him to jump to somewhere he couldn't. I fixed that by ticking the 'ignore if can't move' in each of the move things...

But that raised a new problem where my animation would still play.. even when he doesn't jump. How can I fix this?

I have a feeling it might involve a script of some sort (which I have very little experience with). Can anyone help?
 
Actually, just try turning a 'success' switch on in each of your move routes. That way, it'll turn on when your player is able to jump. Then, put the animation in a conditional branch that checks if that switch is on, and if it is, play the animation, wait, and then turn the switch off again.
 

Spoon

Member

I tried your idea, changed my code to this:

Code:
[img]http://i307.photobucket.com/albums/nn310/TheSpoonFtw/CommonEvent1-1.jpg[/img]

Annoyingly enough.. it has stopped the animation from playing entirely T_T
 
Okay, I'm not entirely sure, but try cutting and pasting that animation condition beneath each of your move route events so that it's actually within the other conditional braches that test the variable.

Oh, and to make it a little more organized, when you have the dialogue open to edit a conditional branch, uncheck that box at the bottom if you're not using the 'else' feature. It just makes it easier to read.
 

Spoon

Member

No luck :C
I can't see why it shouldn't work.. I just pasted this into a completely un-touched map.. same problem here too.

But thanks for the organisation tip ^^

Theres a script that I believe goes something like this:
Code:
    temp = $game_map.passable?(x, y, 0)

Could we use this in any way? (Note.. I'd have no idea what to do with it)
 

Jason

Awesome Bro

Hmm, I've never used a variable linked to players direction when making a jump system o.O

I mean, wouldn't it be easier to do a conditional branch for each direction, and then place the jump animation in there ?

Example;
Code:
 

Conditional Branch: L is being pressed (L being Q)

   Conditional Branch: Player is facing left

   >Set move route: Jump -2, +0

   (Ignore if can't move)

   Else

      Conditional Branch: Player is facing up

      >Set move route: Jump +0, -2

      (Ignore if can't move)

      Else

         Conditional Branch: Player is facing right

         >Set move route: Jump +2, +0

         (Ignore if can't move)

         Else

            Conditional Branch: Player is facing down

            >Set move route: Jump +0, +2

            (Ignore if can't move)

            End

         End

      End

   End

End

 

Just put all of that into a common event, and on the first map of your game, make an event calling the common event, and make it parallel process, and it should work o.O
 
You probably could... I wouldn't be able to tell you how to use that one.
However, I think what the problem is is that the animation conditional branch is checking the condition before the switch is turned on... What you might need is a line of script that you can put in your move route that'll play the animation, but I don't know what that is.

Now that I think about it though... I MIGHT have an idea of how to use that line of script...
 

Spoon

Member

-> PhoenixTilea

I tried putting in a "Wait for moves completion" because you thought it was checking before it was on. I think you were right about that.

This is what happened when I added it:
- When it could jump, the animation played after it had jumped. (too late)
- When it couldn't jump, the animation played instantly anyways. (still there)

I think the switches are still activated, even when it doesn't jump


For the script, I was thinking we could do something like this:
- Find players location ( x and y )
- Find players direction ( 2, 4, 6 or 8 )
- Set 'temp' to the players location plus x and y values corresponding with the direction (similar to how I've done the jump)
- Check if 'temp' is passable
- If yes, then play the event as normal

- - - - - - - -

-> jbrist

I tried that, it basicly works the same as mine, although it is admittedly a bit simpler ^^
But there is still the same problem with the animation
 
Okay, I think this is what you need to do. (Change the numbers 1 and 2 to the switches you want to use for the player's x and y)

-Set variable 1 ot player's map x
-Set variable 2 to player's map y
-Set variable 3 to Map ID

Now, for example, in the conditional branch that says the player is facing up:

@>Script:
x = $game_variables[1]
y = $game_variables[2]
id = $game_variables[3]
test = $game_map
temp = test.passible?(x, y-2, id)
$game_variables[4] = temp

Then, test if variable 4 is true, and if so, jump and play the animation.

Hopefully that works... In the passibility text, you'll have to change that 'x, y-2' according to which direction you're currintly working with. This only works if the player is facing up.
 

Spoon

Member

Do you know if this would work?

Control Variables: [0001: Direction] = Player's Direction
Control Variables: [0002: X] = Player's Map X
Control Variables: [0003: Y] = Player's Map Y

SCRIPT:
Code:
direction = $game_variables[1]

x = $game_variables[2]

y = $game_variables[3]

 

case direction

when 2

y += 2

when 4

x -= 2

when 6

x += 2

when 8

y -= 2

end

 

temp = $game_map.passable?(x, y, 0)

if temp == true

  #$game_variables[4] = 1

  else

  #$game_variables[4] = 2

end

Then I simply add a thing in my other common event checking if Variable 4 is 1
Would this work?

Also I had to put the script into two different script things.. because it didn't fit..
Would that matter?

- - - -

Ok.. it didn't work. I just tested.
By this I mean it just crashes as soon as I open, error message reading:
'Syntax error occured while running script'

- - - -

Here are my 2 common events so far:
CommonEvent1-3.jpg
CommonEvent2-1.jpg
- - - -

I was playing around with it a bit.. the error message has changed its mind and now reads:
'NameError occured while running script.
undefined local variable or method `direction'for #<Interpreter:0x13f0878>'

Sorry I'm being a bit pesty guys ^^
 
I'm... not entirely sure if you can use things like switch cases and if statements in call scripts... Give what I said earlier a try, because I really don't know what to tell you for that one...

Oh, and if you do it that way and check the condition of variable 4, use a script in your conditional branch that says:

$game_varialbes[4] == true

I think I'm wrong about it equalling 1.
 
In the eventing system, variables are only numbers. However, when using scripts, you can create different types of variables, like strings and booleans. True/false is a boolean, and I believe that a boolean value is what $game_map.passible?(x,y,0) will return.

So, that's why you have to put a script for the condition instead of just using the regular variable radio button and whatnot.
 
Sorry I'm just taking shots in the dark here. I would be trying to do this on my own to test it, but RMXP doesn't work on my laptop and until tomorrow afternoon, I don't have access to my desktop computer. But, if that line of code is right, that SHOULD work....
 

Spoon

Member

-> Wizard 576
Nooo, I've already got a working jump system. - You've basicly re-aranged it a bit : p.
My problem was that my jump-animation would play, even if he couldn't jump (destination is unwalkable)

I'm quite certain the solution lies in these scripts - which I'm gonna keep playing with for now.
But I appreciate your help ^^.

- - - -

-> Phoenix Telia
Okay, I've managed to make a scipt that doesn't crash the game.
But.. on a negative.. it doesn't work.

Well anyways, heres the event:
Code:
[img]http://i307.photobucket.com/albums/nn310/TheSpoonFtw/Code.jpg[/img]

At the end I've put in a little test to see if the code works,
- if the square 2 infront of the player is walkable, then play animation every 5 frames
However.. the animation is playing, so it hasn't worked. Apparantly its always walkable.

I'm gonna try put up a demo for you guys to look at : s
 
I don't understand why your animation is playing when it is unwalkable. This is the jump system that I use and have had no problems. Sorry it doesn't work. I guess all I can say from here is good luck cause I'm kinda clueless.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top