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"

Lock Direction of Player when jumping?

Hello, I'm pretty new to UE4 and I've been following a few tutorials and such. The problem I'm having is how to lock the player's rotation to the same rotation as when they jumped? This seems really easy to do but I can't figure it out. To explain what I mean in more detail: in any platformer, when the character jumps, their rotation is locked to where it was at the start of their jump. alt text

I'll use the classic Super Mario Bros as an example. In this image, I started facing right. Then I jumped and held the Left Arrow Key and my movements followed the yellow arrow. However, Mario stayed looking the direction I was facing when I started jumping.

alt text

The same thing also happens in reverse. Here, I jumped and held the Right Arrow Key while facing left (again my movement followed the yellow arrow), and as you can see Mario stayed looking left even though I have moved backwards.

For some reason I cannot figure out how to do this. One thing I tried was to store current Rotation in a variable and then set the variable On Jump Event. I thought this would set the variable once and then I could lock him in that Rotation. Instead, it constantly updated the variable, so it was constantly setting the Rotation to itself, and basically it had the same effect as if I didn't have the blueprint in the first place. Can anyone help me with this? I would appreciate it very much!

Product Version: UE 4.10
Tags:
more ▼

asked Feb 11 '16 at 07:42 AM in Blueprint Scripting

avatar image

penguin0
1 1 1

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

1 answer: sort voted first

HI,

A quick way I would do this, is off your left and right, let us say arrows, put a bool in, "Is jumping",

When jump triggered, Bool = Yes

If "Is jumping = Yes", check if left and right are hit, and jump in that direction, -> Play jumping section. At end of jump section, set bool to No.

If "Is jumping = No", then left and right "Arrows" work as normal"

Hope it helps,

Narg

more ▼

answered Feb 11 '16 at 12:23 PM

avatar image

Narghile
1.7k 74 38 110

(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