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"

Limited Strafe Jump (Left or Right Only) Blueprint?

I want my game character to be able to only strafe jump left or right only. I don't want the character to be able to jump any direction. I want it to be very similar to Unreal Tournament strafe jumping by double tapping the A or D keys.

So far, my character got the basic third person jump blueprint and animation blueprint. What can I do to limit the jumping ability to left and right only and by double tapping the A or D (or bottom face button + direction of left stick for the controller) keys? Also what about a pause in between jumping (like 3 5 seconds) before being able to jump again?

Product Version: UE 4.19
Tags:
more ▼

asked Oct 08 '18 at 08:38 PM in Blueprint Scripting

avatar image

Oblivion2500
143 16 25 129

avatar image mightyenigma Oct 09 '18 at 07:09 PM

Which part are you having trouble with? HOw to get it to recognize the inputs for the strafejump, or how to get the pawn to move in a strafejump?

avatar image Oblivion2500 Oct 09 '18 at 07:52 PM

Both basically. I mainly need help with getting the character to move in a strafe jump and be able to adjust the distance of the jump as well.

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

1 answer: sort voted first

I don't know how Unreal Tournament does it, and I've never done it, but if I were making this feature from "scratch", I would probably take the following approach:

  1. Get a double-click detection working: Map input ACTIONS for the two strafe directions (this is in addition to the normal strafe movement input AXES), on the Input ACTION events, subtract a variable "StrafeActionTime" from the current Game Time. If the difference is small enough, then it counts as a double-click, so you run the StrafeJump function you're going to build. If not, do nothing but set the StrafeActionTime to the current game time (do this after checking the subtraction not matter which way the Branch goes).

  2. In the StrafeJump function, Take a variable, such as an enum or a bool, as an input pin, and use that to decide whether we're going right or left. (enum is good if you want to expand it to other directions later). Add a Launch Character node where the Z part of the vector is a small number and the X and Y are determined by the Character's Actor Rotation or the playercontroller's Control Rotation. From one of those, -> GetRightVector (multiply by -1 if jumping left, use returned value as-is for jumping right), and Make Vector where you plug in the X and Y from that jump direction you calculated, and the Z is just that small positive number that makes sure you get off the ground high enough to complete the strafe jump.

  3. You might need to temporarily alter some character movement variables such as air control velocity etc until the character has Landed event fires at which point you restore them to their original values. I would try it only doing steps 1 and 2 first and see if you like how it works. You might not need this step 3.

more ▼

answered Oct 10 '18 at 03:12 PM

avatar image

mightyenigma
3.8k 18 20 20

avatar image Oblivion2500 Oct 11 '18 at 03:56 AM

Alright, I took your approach. I got the double-clicking working. I can't seem to get the second step working properly. I can make the character launch into the air but it's more like an odd rocket instead of a leap left or right. I also can't get it to figure out the direction of the leap using the enum. Here are some screenshots. alt text

alt text

alt text

alt text

alt text

avatar image mightyenigma Oct 11 '18 at 07:05 AM

Well it looks pretty close to what I had in mind although the double-click is way different but that part is working so i won't worry about it.

Your jump direction I think what I would change is where you did that makerotator. You left off the Z (yaw) which is the most important axis for determining which way the char is facing for a strafe jump. In fact it might be better to makerotator with 0 on pitch and roll and ONLY use yaw.

avatar image Oblivion2500 Oct 11 '18 at 07:45 PM

Alright, I updated with get player controller and left the pitch and roll to 0 while having the yaw connected to the make rotator. My character just makes a very odd hop going up. Shouldn't it be at the Pitch? I mean, going left or right? I don't quite understand if you can explain why it should be the yaw. I'm using the dummy model that comes with UE4 for example. No animations for leaping yet. Here's what I got so far: weird hopping BP

avatar image mightyenigma Oct 11 '18 at 09:47 PM

Ah okay I know what's wrong. You need to multiply the Right Vector values by something big like 5000. The Right Vector is a unit vector so it is launching him at a speed of 100 in the up direction and only 1 in the right-hand direction.

The reason not to use roll or pitch is because your character is facing a certain direction and is not tipping over (roll) or leaning onto his face or back (pitch). We want the Yaw (horizontal direction) to determine which way is strafe right and which way is strafe left (it is strafe right multiplied by negative 1) in the world.

avatar image Oblivion2500 Oct 12 '18 at 03:46 PM

Still not working when I add a multiply float * float node from the right vector to the launch character yaw node. It still does the bunny hopping which is odd. What's weirder is that if I just get rid fo the multiply node and put in 5000 into the launch node, it will make the character launch straight up very high. Also, I'm so confused on how I can make the enum tell the blueprint if I'm going right or left. I can't seem to go to a branch node in the blueprint. It's basically a if that than that like in C++.

avatar image mightyenigma Oct 12 '18 at 04:25 PM

Make sure the multiply is AFTER the Get Right Vector, but before the Launch Character.

To make it choose right or left, pull a Select node out of the Jump Direction pin, and for the Left direction you multiply the Right Vector by -1 before multiplying by the 5000, but for the Right direction just use the 5000 without also multiplying by -1. Alternatively you could just choose either 5000 or -5000 to multiply by. Comes out the same.

avatar image Oblivion2500 Oct 14 '18 at 03:20 AM

Hm, yes, I do have the multiply after the Get Right Vector and before the launch character.

I created the select node which got enum values input/outputs. I converted the output to float to multiply by -1 for jumping left. I'm still not getting anything different. The character only hops up into the air for a half second when I hit the A key twice and strafe jump. Here's my progress so far: progress on bp for strafe jump

avatar image mightyenigma Oct 20 '18 at 03:50 AM

This is incorrecton just one part. Multiply the ENTIRE Right Vector by the large number (and maybe make it even larger. Lets try 20,000), and use the X and Y from the product of that multiplication. You have it where it is leaving the sideways vectors at a value between 0 and 1 (not multiplied) so no wonder the character does not jump sideways. You shouldnt need to multiply the Z of the right vector by anything as you are doing in this screenshot because you will not be using the vertical part of the right vector.

avatar image Oblivion2500 Oct 20 '18 at 02:07 PM

I'm a bit confused. Is this reply for my response/post from 6 days ago or last night? I know that Z is up in UE4. I had to make the Z a bit higher like 300 so the character can move off the ground. I had the Y (Pitch) see to 1000 which worked. The character now strafes right when I hit the 'D' key twice. I'm trying to figure out how to have the function multiply by -1 if I hit the 'A' key for left twice. I'm having trouble figuring out the Enum function, do I even need an Enum for left and right? It doesn't seem useful. I do want the flexibility to edit it in the future if I want forward and backward jump.

Also, I notice another issue. If the character is in the air, you are still able to hit the A or D key twice and it will still launch the character. I don't want the player to be able to "jump/launch" in midair which can break the game. Any ideas or tips on making the blueprint detect if the character is in the air and if so, don't register the double click keys for this function?

avatar image mightyenigma Oct 20 '18 at 03:36 PM

It is for the six days ago one because that screenshot is closer to how I would do it.

To prevent the strafe jump from activating while the character is off the ground, there are some varuables and events in Character Pawn classes that you can use. I remember one event called Landed which fires when the character has been falling or has jumped and then their feet land on the ground again.

I think there is also a Boolean called is falling or isAirborne or something like that which is automatically set true when the character leaves the ground and false when they land again. If not you can make your own by setting true when the character jumps or falls (though detecting a fall might require some logic on the Tick) and setting false when the Landed event fires.

Try to find a built in falling or airborne variable though because I think I remember there being one and that makes thinks way easier

Then just check for that variable in a Branch node at the beginning of your strafe jump action or just before calling the strafe jump function, and if it is True then do not proceed.

avatar image Oblivion2500 Oct 21 '18 at 02:41 AM

I got the midair part done. I just needed to add a not falling to not bool at the beginning. I got the enum select node and multiply -1 node. I'm still not understanding how this blueprint even communicates with the Enum or how it even knows that I'm jumping left or right or knowing what keys are left or right jump. alt text

avatar image mightyenigma Oct 21 '18 at 05:03 AM

Excellent. You pass the enum in from the A or D keyless event if it detects a double click. The A double click calls strafe jump with a left enum and D calls it with right enum

avatar image mightyenigma Oct 21 '18 at 06:32 AM

When you want to add forward and backward dodge/jump you can do the same way except use GetForwardVector instead of GetrightVector and use positive multiplier for enum forward direction and negative multiplier for enum backward direction

avatar image Oblivion2500 Oct 21 '18 at 09:03 PM

Can you give me an example? Do I create a custom event in the strafe jump function?

avatar image mightyenigma Oct 21 '18 at 10:41 PM

Maybe that would work. I was thinking just put a Switch node using the Direction parameter at the beginning. From the Forward and Backward pins it goes to some almost identical code except GetForward is used instead of Get right. And for the Right and Left directions it goes to the code you already have. All within the same function.

avatar image Oblivion2500 Oct 20 '18 at 03:26 AM

I have been working on this again, I managed to get the jump working. The problem was the velocity should NOT be at Yaw. Yaw takes you straight up. For left or right, you need to focus on the pitch! Just need to figure out how to make it determine to wither if I'm jump left or right. I have an Enum (see above in older reply) Here are some screenshots, still need some help:

alt text

alt text

alt text

avatar image mightyenigma Oct 20 '18 at 03:55 AM

Remember that in Unreal Z is up and down and Y is sideways. Unlike Unity.

(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