How to burrow undergound. need help please

ok so ive encountered a problem, i am making a 2d game and i need to burrow under which isnt hard. So ive got it set to keyboard, E, ive got it so i just tap the key. Ant it all works fine and does what i want it to do.

BUT…

I can keep taping E and i just keep going further and further and further. I want to make it so i can only press it once and then it wont go any further down, so that when i tap R i pop out of the ground.

I can explain it better i think if you are confused. Thanks

Maybe you should use states or make a property and call it something like xyz and than when you press E if the property is 0 the player does what you want him to do and the property changes to 1. That way you can only use it once. Also when you press the R key, the player does the other thing and the property changes back to 0.

Its simple!

Thanks man, Thumbs up :), that makes sense will look into it closer.

Edit: I am only using R to unburrow because i dont know how to make E have 2 actions, is there a way to do that?

is there some way to make it if value is 0 it goes moves -z value Xamount and changes value to 1, and then if value is 1 then it moves Z Xamount and changes value to 0? Or is it easyer to just keep it 2 different keys?

Josip’s suggestion of states is probably the best way without using python. With states you can have the E key burrow down and then in a second state have the E key trigger upward movement. Then E can have two actions associated with it.

I’ve attached a simple .blend demonstrating it. Hope this helps! :smiley:

burrowing.blend (125 KB)

Thanks man, That helped a lot esp the attached file. How do i make the grid infinite? Also with the states does that only work for 2 actions to the one key o could i say make like as many as i want? Thanks

I’m not sure what you mean by making the grid infinite? could you explain a little more please? Are you referring to making an action last longer so the player can dig deeper down?

You can have as many actions associated with a key as there are available states, so 30, having a different state for each action. If you’re using python the amount a single key could do is endless!

Ok thanks for the quick reply, and with the grid thing when i open up a blank blender file my grid only goes for a little while, where as the one on the blend file you gave me it seems to never end, Its probally in the settings or something.

Thanks

No worries, happy to help!

Yeah, you can mess with the grid settings in by clicking on the view menu on the 3D window then selecting view properties (in 2.49b anyway). Also the amount of the grid you can see is dependent on the current view. In the blend I posted I was in orthographic view (number pad 5 toggles between ortho and perspective) and viewing it from the front (number pad 1). These options can also be seen in the view menu on the 3D window. If your view mode is set to perspective or you’re panning around then the amount of grid is limited.

Hope this helps! :smiley: