How to lock the character in a direction?

These are the events I have.


When you press an arrow key it records it and if you press space the player holds up a cross in the direction of the recorded key, these events work fine the problem is I’m not sure how to make it so the character gets locked in the direction they are facing when the space key is pressed, is there a way to do this?

Is that some kind of dash with space?
Cause if yes i would make
Condition
Space key is pressed

Action
Change SOME BOOLEAN VARIABLE to true
Wait AS MANY SECS as dash last
Change SOME BOOLEAN VARIABLE to false

And now you can use true state of that boolean variable in condition to lock your controls

1 Like

No, the character stands still and holds up a cross like the religious type.

OMG i just read your post again 2 times and i just realized what exactly you want to achieve

SO
For that you could simply set max speed to 0 of your player when you are pressing space

Or add condition to movement keys
INVERTED Space is pressed

So it works only when space is not pressed

And rest is just making animation for each direction
Like condition
Up key is pressed
Space key is pressed

Action
Change animation to cross up

OR if you want it to register last key pressed
So for example you press up and release it WITHOUT pressing any other direction afterwards so when you press space now player should hold cross UP
You can make variable called CrossPos
And simply add extra action to direction events
So like

Condition
Up key is pressed

Action
Move player up
(Or if it is platformer) Change animation of player to look up
Change variable CrossPoss to UP

And now you make another event
Condition
Space key is pressed

Action
Change animation of player to variable(CrossPos)

This of course you would need to match names in CrossPos variable (which should be string) to match names in your player animations for holding cross in directions you want

1 Like

Sorry I took a bit to be able to reply.
I think you misunderstood the problem which is my fault for not explaining it well, but the problem is that say I press up and then press space the animation will change to cross up but if I hold space and then press a different arrow key the animation changes to the key I pressed but it shouldn’t, I want it to keep looking up(or whatever direction the character was facing) if I’m already pressing space.
this is what I want:
direction lock
This is what I have:
spin

If you used what i wrote in previous post you only need to change

Condition
Up key is pressed

To

Condition
Up key is pressed
INVERTED Space key is pressed

And same for every direction so

Condition
LEFT key is pressed
INVERTED Space key is pressed

This will prevent changing CrossPos variable from changing when space key is held

1 Like

Thank you it worked really well.

1 Like