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"

Making a character face the direction of movement in 2D

Hello,

I'm new to UE and recently finished reading up on C++ so thought I'd have a stab at making something, after reading around it seemed like blueprints were the way to go to get a better understanding of what needs to be done before delving into actual code. I've been following a guide to make a 2D game from Game from scratch. The movement scheme used was very simple, that it for every key press (or release) the character would move some number of units. This is slow and doesn't feel good so I tried using input axes instead but now I cannot get the character to face the direction of movement.I looked at the documentation but it all seems to be for 3D. Attached is a picture of the blueprint, I'm guessing I need to split the axis value into two and somehow modify one of the outputs so that it turns the character around. Sadly I am at a loss as to how to do this. Any help would be appreciated, thanks!

alt text

Product Version: UE 4.9
Tags:
more ▼

asked Sep 06 '15 at 11:36 PM in Blueprint Scripting

avatar image

Thaeryn
3 1 2 3

avatar image Thaeryn Sep 07 '15 at 01:06 PM

Thank you for your answer! That video was very helpful and I will use your channel. I was wondering if it was possible to set the rotation directly from the input axis, since if someone pressed right or left instead of a or d would it not work? I tried to use this (below) but he now constantly faces left.

https://gyazo.com/f8c4e625a41c61643303a906e0138872

Thanks for your help!

EDIT:I changed the capsule component to the sprite and now he always faces right. Could you please explain what I should be using? I thought that since the capsule component was the parent? It would work on everything below it: https://gyazo.com/11640c3dfe6783e4e9c620d5cc07b706

avatar image Thaeryn Sep 07 '15 at 05:45 PM

I should've just used the template and looked at what was done there, it never occurred to me that was how it was done, thanks for the help.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

The best practice, is by changing the sprite scale using the node "SetRelativeScale3D". And keep the actor itself as is!

Here is more info about that node:

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Utilities/Transformation/SetRelativeScale3D/index.html

alt text

But for more details about 2d character controller, I would recommend checking this quick video about building a 2d character controller:

https://www.youtube.com/watch?v=ovfUTmxMD3s

-m

more ▼

answered Sep 07 '15 at 01:45 AM

avatar image

mamoniem
1.2k 33 23 66

(comments are locked)
10|2000 characters needed characters left
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