x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

disable backwards sprinting

I have set up a sprinting action while moving and pressing shift.
I set up a branch to check if the player is not moving backwards and if he is moving at all. this works until i sprint forward (w and shift), then release the move key, while still holding the shift key, now if i move backwards i still sprint. how can i disable this? so that if shift is still pressed after running, the sprint ability gets disabled or checks again if i'm moving backwards?

do i have to split the movement into forward and backward? because the branch that checks if i move backwards when pressing shift the first time doesn't check again if i'm still holding the shift key.

hope this isn't too confusing.

alt text

Product Version: UE 4.14
Tags:
sprintbp.jpg (326.3 kB)
more ▼

asked Jan 09 '17 at 10:28 AM in Blueprint Scripting

avatar image

CitéNoir
60 9 11 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

4 answers: sort voted first

as i couldn't really figure the gate thing out, i found two other solutions.

the easiest one was to just add a branch to the forward/backward movement axis that checks that axis is >=0 (which means the player is moving forward and/or sideways) and if the sprint key is being pressed, then set max walk speed to a sprint speed variable, if the input axis would be smaller (which means he is moving backwards) set the walk speed to a walking speed variable. this works as intended.

the second solution uses an enum (that has three different walking states in it: walking / running / crouching ) on an event tick. the event tick goes through branches that check if the player is moving forward or backward, pressing the sprint key or is crouching, stuff like that, and then sets the enum accordingly, going into a switch for the enum, that then sets the walking speed based on the enum. this also works nicely.

more ▼

answered Jan 15 '17 at 04:33 PM

avatar image

CitéNoir
60 9 11 10

avatar image CitéNoir Jan 15 '17 at 10:07 PM

now i only have to figure out, how to add my timeline to it, that eases the walk speed in an out of sprinting, cause right now it only switches between walk and sprint speed.

in terms of performance, i don't know what to prefer, i like the enum but it's running on the tick, so wouldn't that be more intense on the performance, as opposed to using branches on the axis which already checks every frame. anyone got an idea?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi there,

Because the Booleans are not being checked until keypresses, I would suggest using a gate. Have the gate run on a tick event and use the key presses to open and close the gate. Make the gate open event check those Booleans instead so they stay current and can be applied correctly at all times.

more ▼

answered Jan 09 '17 at 11:28 AM

avatar image

TechnicallyLew
134 7 3 8

avatar image CitéNoir Jan 09 '17 at 10:58 PM

Hi NukePie,
thanks for the answer, that seems to be exactly what i need. could u maybe elaborate on the setup? i tried the whole day to wrap my head around the correct setting, but i just can't figure it out. still new to this and never used a gate and the epic documentation on that is fairly short.
have a nice evening..

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Very Simple Way

alt text

2018-03-17.png (416.9 kB)
more ▼

answered Mar 17 '18 at 05:25 AM

avatar image

Lohrian
6 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

here is the simple way I apologise for my poor editing skills

alt text

more ▼

answered May 18 '19 at 02:14 PM

avatar image

BluAstronaut
6 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question