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"

Get result under cursor in construction script

Hey,

I have a project with a square grid that actors can be placed on, and when I place an actor in the world while using the editor I'd like it to snap to the nearest grid position to the mouse cursor, allowing me to place the actors accurately and also cache the index of the grid node for later use. Unfortunately the 'Get Hit Result Under Cursor by Channel' function requires a player controller and of course there isn't one available when just using the editor, so I can't call it. There is a more generic line trace function but I can't find any way to get the mouse position without a player controller.

Is there a way to either get the mouse position during construction or get a player controller during controller, or alternatively another place I can put this functionality that's more suitable?

alt text

Thanks.

Product Version: UE 4.14
Tags:
more ▼

asked Nov 27 '16 at 11:59 AM in Blueprint Scripting

avatar image

CapnFuzzles
5 2 4

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

1 answer: sort voted first

Why don't you use the location of your newly placed actor? You know your grid and you know the non-snapped position of your actor so rounding it to the nearest grid cell should be easy. This should also work while dragging the actor around as there will always be the non-snapped location available during your construction script.

more ▼

answered Nov 27 '16 at 12:24 PM

avatar image

Schadek
193 6 4 12

avatar image CapnFuzzles Nov 27 '16 at 12:28 PM

You're right, that's exactly what I could do and it's such an obvious and simple solution I have no idea how I didn't think of it myself!

Thanks very much.

(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