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"

How to get 8 directional mouse movement?

Is there anyway i can make my character rotate at 45 degree angles as it moves while using mouse movement?

I am using the top-down blueprint and would like my character to snap rotate to every 45 degree angle while moving forward, so the character can only face and move in the directions shown in the compass image below as i click and hold the left mouse button down.

alt text

Can it be done in the Character blueprint?

Sorry if i am being too vague. ><

Product Version: UE 4.14
Tags:
more ▼

asked Feb 13 '17 at 05:46 PM in Blueprint Scripting

avatar image

Smelly finger
3 1 2 3

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

1 answer: sort voted first

Here is a very simple setup of how you might do that in a pawn with a FloatingPawnMovement component. With this, the pawn will move toward the location of the clicked point while left mouse is held down, and will only move in 45 degree angles. You may need to add more detail in the description of what sort of movement you want to achieve if you want to get a more detailed answer though.

alt text

Edit:

Below is how you would do it in the TopDown template, put this in the PlayerController blueprint, TopDownController. Delete everything that is happening on the Tick event in the current one and replace it with this:

alt text

45.jpg (672.7 kB)
plc.png (247.0 kB)
more ▼

answered Mar 07 '17 at 11:55 AM

avatar image

Mosel3y
1.8k 49 22 67

avatar image Mosel3y Mar 07 '17 at 08:06 PM

Hey, updated the answer for the TopDown character, works pretty much the exact same.

avatar image Smelly finger Mar 07 '17 at 08:38 PM

Thank you for the help. :)

My character now moves in only 8 directions however, the character wont rotate as i move the mouse. I have to stop holding the left mouse button and then click again in another location for the character to face a new direction.

Is there a way for me to get the character to rotate 8 directions as it moves forward, as i hold down the mouse button?

avatar image Mosel3y Mar 07 '17 at 08:47 PM

Ah, just move the Sets, so that they are after the Gate: alt text

3.png (186.1 kB)
avatar image Smelly finger Mar 07 '17 at 08:52 PM

Thank you so much for the help, it works perfectly!

(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