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"

"spawn actor from class" affecting "get hit result under cursor by channel"

I have a simple blueprint flow: get hit result under cursor by channel > break hit result > make transform > spawn actor from class

The actor does not spawn at the expected location. Instead, the hit result gets offset by the dimensions of the actor. I understand that I'm spawning the actor under the cursor, but did not expect the hit result to be affected by it. It was already calculated once, so why is it being calculated again?

Product Version: UE 4.19
more ▼

asked May 03 '18 at 02:02 AM in Blueprint Scripting

avatar image

1 1 1

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

1 answer: sort voted first

When testing in Visibility channel, the location on Break Hit Result should be returning the location on the surface of the hit object. If the spawned object is 100 uu in Z axis, half of the object should clip. Is this not the behaviour you're experiencing?

Perhaps, the collision is getting in the way and the the newly spawned object is being offset to account for that. It can be adjusted:

alt text

Another reason for the behaviour you're seeing might the manual offset in the actor's components. Worth double checking, too.

If this does not help, would you mind attaching a screenshot of the current result vs the expected one.

Below is the correct behaviour, I placed the cursor close to the edge and draw a debug sphere:

alt text

If I wanted the sphere to sit directly on the surface, I'd have to offset its Z by half.

untitled.png (33.5 kB)
unt2.png (147.4 kB)
more ▼

answered May 03 '18 at 07:23 AM

avatar image

13.7k 74 25 57

avatar image ThompsonN13 May 03 '18 at 03:34 PM

I was thinking something similar, offset is probably due to the actors origin location.

avatar image anthonyvr01 May 03 '18 at 07:01 PM

The actor is a cube that has been scaled by x=0.1, y=0.1, z=0.2. The z=0.2 is deliberate, so that when only half of the actor spawns above the surface, it still appears to be a cube. I've seen expected behaviour when manually specifying the location. The problem only sets in when trying to get the location from the hit result.

Setting the Collision Handling Override unfortunately didn't solve the problem. I had expected behaviour when setting the location manually and leaving the Collision Handling Override on default.

This also rules out the possibility that it might be the manual offset in the actor's components.

So at first my blueprint looked like this alt text which led to the unexpected result alt text

But when saving the transform in a temporary variable alt text it led to the expected result alt text

unexpected.jpg (47.6 kB)
unexpected.png (42.0 kB)
expected.jpg (53.2 kB)
expected.png (46.0 kB)
avatar image Everynone May 03 '18 at 08:41 PM

If setting the transform var is the only thing that makes the difference here, this is one of the weirder things I've seen in the engine recently.

Not that it would make too much of a difference, but could you shed some light on the component hierarchy, especially whether the DefaultSceneRoot is still present. Are the transforms set to Relative or World on that cube?

avatar image anthonyvr01 May 05 '18 at 10:28 AM

It is quite weird yes. If I don't find a solution to this, is there any way for me to get into contact with the unreal devs?

A DefaultSceneRoot is not present. The hierarchy contains a StaticMeshComponent (inherited). How do I know whether the transforms are set to Relative or World? Break hit result produces a location in world space.

avatar image Everynone May 05 '18 at 02:17 PM

Relative vs world - the tiny downfacing arrow next to location, rotation and scale

alt text

I doubt it's a bug. I still think it's something unique to your setup but I can't imagine what it could be. Could you test it with another static mesh or with the engine cube (Component -> Cube) or in a clean project?

In case you're convinced that it is, indeed, a bug, you can report it directly to Epic:


untitled.png (47.4 kB)
(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