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?
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:
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:
If I wanted the sphere to sit directly on the surface, I’d have to offset its Z by half.
I was thinking something similar, offset is probably due to the actors origin location.
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
which led to the unexpected result
But when saving the transform in a temporary variable
it led to the expected result
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?
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.
Relative vs world - the tiny downfacing arrow next to location, rotation and scale
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: