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"

"End" Key Function accessible in Blueprint?

I'm looking to write a Blutility that can take either all selected objects (or shortcut buttons for specific classes of objects, like PlayerStart) and then snaps them to the ground the same way the "End" key would.

I've written my own using LineTraceForObjects to start, but for PlayerStarts in particular it's not working in the same manner. It's actually aligning the origin of the object to the ground (which is what I'm telling it to do, of course) whereas with the End key it actually places the object appropriately above the ground by some amount.

So my questions are:

  1. Can I call the exact implementation of the "End" key in Blueprint?

  2. What method is the "End" key using to determine how far above the ground to put an object?

  3. Where in C++ is the "End" key function defined? (I couldn't find it)

My first thought for #2 would be to find a collider and take half the height of it, but that's just a guess - I was hoping for something more substantiated.

EDIT: I've had pretty close to identical results using an explicit "92" offset to match the Capsule's half-height, but doing something more programmatically would be better so it can work with all objects as well as possible.

Product Version: UE 4.19
more ▼

asked May 15 '18 at 11:29 PM in Blueprint Scripting

avatar image

11 1 3

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

1 answer: sort voted first

The "End" key is called "Snap to Floor" in the Editor Preferences.

Maybe search the engine source code project for keyboard shortcuts? Search for the "Snap to Floor" name or for its description: "Snaps the actor or component to the floor below it".

Making this in Blueprints doesn't seem very difficult. You create the "End" key (or whatever else) as an action mapping bind from the Project Settings - Engine - Input - Bindings, and if you press it, it moves the object down on the Z axis until it overlaps something, at which point you stop moving it. But not too fast, else it will most likely pass through everything on its way down.

more ▼

answered May 16 '18 at 01:00 AM

avatar image

Andrei Despinoiu
270 4 9 12

avatar image Xoonaka May 16 '18 at 05:55 PM

Thanks, "SnapToFloor" gets me to the right spots in the source code. It's a lot more in-depth than I expected, but I supposed that's why it works so well compared to the line trace method I'm employing. I'm disappointed a similar "Snap" function isn't exposed to Blueprint from what I can tell. There's just SnapToGrid, which is inherently different.

I still think using a Line Trace is the right way to go (rather than moving the object over and over again), but determining the offset is the real challenge. Unreal's code seems to be grabbing the bounds of the object and using that, so I might give that a go myself.

(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