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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

How to move towards where the mouse points

Hi people

I'm working with unreal's rollerball template trying to make a movement mechanism similar to Marble Blast or even the third person template. I achieved mouse look on the template so the player can look around the world but when I move forward in moves according to the forwards direction. So I'm failing to make the player move towards where the mouse is pointing or where the player looks at.

Any help with this would be greatly appreciated as I can find any solutions online.


Product Version: UE 4.9
more ▼

asked Feb 14 '16 at 05:19 PM in Blueprint Scripting

avatar image

6 4 7 10

avatar image Ryan Darcey Feb 14 '16 at 05:21 PM

can you post a screenshot of the blueprint controlling the movement?

avatar image D4njo Feb 14 '16 at 06:23 PM

Here are the screenshots. Movement and mouse look alt text

alt text

avatar image Ryan Darcey Feb 14 '16 at 06:31 PM

So, it looks like you're using a static world vector to control forward/right input in that first image. Like, forward is always (1,0,0) in world coordinates and right is always (0,1,0). If your intent is to use the mouse cursor to define forward, you'll have to calculate that direction as the difference between two vectors; ball's current position and the mouse cursor position in the world.

avatar image D4njo Feb 15 '16 at 05:40 AM

I'm rather new at this. Do you know of a step by step to achieve this?

avatar image Ryan Darcey Feb 15 '16 at 04:39 PM

If you just want to move in the direction that the camera is facing, substitute your vector in "roll left/right" with GetRightVector call on the camera. Also, substitute "roll forwards/backwards" vector with a call to GetForwardVector on the camera.

avatar image D4njo Feb 15 '16 at 05:27 PM

I've made the change but the player now doesn't move in any direction.

avatar image Ryan Darcey Feb 15 '16 at 05:58 PM

sorry...without knowing exactly what your project is, i'm just guessing your intent. maybe you want to move in the direction the character is facing? if so, replace those GetForwardVector and GetRightVector calls to reference the character instead of the camera.

avatar image D4njo Feb 16 '16 at 06:38 PM

Sorry if i didn't explain it correctly. My project is a 3D platformer, the player (a ball) moves around rolling and jumping and has a third person view.

avatar image D4njo Feb 16 '16 at 06:40 PM

And yes, you can rotate the camera around the player but I want the player to roll forwards always to where the player is facing.

avatar image D4njo Feb 17 '16 at 08:04 PM

When I replace the vectors with the GetForwardVector and GetRightVector for some reason my left and right become my forwards and back and my forwards and back become my left and right. It does work in the sense that it moves forward towards the camera but with that weird input problem. Here's a screenshot of the BP

alt text

avatar image Ryan Darcey Feb 17 '16 at 08:13 PM

It looks right to me. Are you sure you have your input mapped properly in your projects controls?

avatar image D4njo Feb 20 '16 at 02:59 PM

Yes I'm sure because when I don't make the change the controls are as they should.

avatar image ChaoSXDemon Feb 14 '16 at 06:05 PM

I'm guessing you are probably missing the direction from mouse? Also, mouse is a 2D point on screen. If you want a point in your game world (even if you are topdown), you need to project that point onto something. Typically you cast a ray into the scene and take the first hit point and tells the player to move there.

avatar image D4njo Feb 16 '16 at 07:12 PM

I'm working in a 3D setting for a third person platformer with a rolling ball. The camera rotates around player as it should but I want the player to always move forward to where he is looking.

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

1 answer: sort voted first

seems you want to 'orient rotation to movement' however I see your not using a character movement component so this is now more difficult than if you did.

Off the top of my head my solution would be: on your movement events branch on axis value being nearly equal to 0, if true set 'use controller rotation yaw' to false, if false set 'use controller rotation yaw' to true.

not quite sure why you wouldn't want to just 'use controller rotation yaw' all the time but w/e.

more ▼

answered Feb 18 '16 at 10:16 AM

avatar image

33 2 4 5

avatar image D4njo Mar 11 '16 at 05:02 PM

Got it! Thanks for the help

(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