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"

Rotating an object towards the mouse

We are working on a 3D Sidescroller (using the sidescroller template as a base). Our character can shoot bullets from himself and the player will use the mouse to aim. Currently I am trying to rotate a spot light around the player that faces in the direction of the mouse, this will be used to help aim. I have the behavior I would like when the player is aiming on the lower half of the screen. However, once you begin to aim above the player, the spotlight begins to shine in the direction opposite the mouse, obviously not what I would like.

Here is the blueprint I am using to calculate a point in 3D space that represents the mouse location, I found this after reading through forum posts here on unrealengine. alt text

And here is the blueprint I am using to rotate the spotlight: alt text

Any ideas on why I am getting this behavior and how to correct it?

Product Version: UE 4.10
Tags:
more ▼

asked Jan 13 '16 at 06:14 PM in Blueprint Scripting

avatar image

UsefulEndymion
31 3 6 9

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

1 answer: sort voted first

Of course I solved the issue nearly immediately after posting this. When getting the mouse position from ConvertMouseLocationToWorldSpace, I was projecting the mouse location into 3d, but since Unreal uses a different coordinate system, we were dividing z/z instead of x/x. Changed that and now it is working like a charm!

more ▼

answered Jan 13 '16 at 06:23 PM

avatar image

UsefulEndymion
31 3 6 9

avatar image Squashy92 May 16 '17 at 09:24 AM

Hello :) I know you solved this long ago. But I'm working on a problem which seems similar to yours back then. In order to display the distance between two spots in the world, I need to convert my mouse location into a world location. Otherwise my result will change just by walking backwards and clicking on the same object. I think you know what I mean.

Even though i tried to copy your setup which I do not fully understand to be honest, it's not working. It is still changing the coordinates if i click on the same place in the world when i click on it from different directions/angles

avatar image Xcog Jul 02 '17 at 11:34 PM

This post was a GODSEND. I'm serious. It made all my problems just vanish into thin air. I'm so happy that this post exists. Thank you so much for posting it.

(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