I’m trying to orient a cube with the same up vector as the normal of whatever object the ray cast hit using its up vector with an infinite lenght, but my cube is flickering all around. Anyone can help me on this/provide some mathematical references as I’m a bit rusty on how to do it…
Hi! Sorry to interrupt this topic, but I’m looking for something similar, only that it needs to work while placing an Actor inside the viewport. (Exactly as in your example, @ClockworkOcean )
Another thread I found regarding that topic already is dead, kind of.
Rotate Blueprint Actor to surface normal when placing in editor - Programming & Scripting / Blueprint - Unreal Engine Forums
Would you say, that your setup would work fine if used in Construction graph and only is executed while in Dragging mode? For ArchViz I’ve gathered a few assets and always have them assembled inside a BP class. There will be a few hundred assets in the scene … would that impact performance? Sorry if this is going too far, but your GIF gave me some hope again
Hi, no worries.
Because it’s in construction, it only has an impact when you’re moving an object. During ‘play’ or a sequence, there’s no overhead.
The version I put here, only aligns the object to something underneath the actor. But it’s perfectly possible to get it to something above or beside it. Just more code.
If you have a class that all your object descend from, then you only have to put the code in that base class.
It’s possible to have something like the mesh placement you see in the mesh editor
No overhead is exactly what I wanted to hear.
And yes, having everything in a base class comes with many benefits.
That example looks like the end result I’m looking for. While still working in UE4 I’ve never used the Mesh Editor until now. This is only working in that mode and not for placing actors in ‘Default Mode’, right?
Based on that example I’d say something like:
- Use LineTrace under Cursor
- Get World Location + Face Normal
- Use these informations to determine Actor Location and Rotation
I’ll give it a try and, if it works, may add this to the thread. Thank you!
The mesh tool is not your answer, of course, it’s just an example of constant normal monitoring.
You need to trace in all 6 directions and move the actor to the impact point.
I’ll put something here in a while…
So I wrote a trace function
And used it to trace in all directions
Even though it’s a sequence, the function exits when a return node is called. It’s just much easier to look at than a if chain.
Then the construction script is just
It’s very early days, but something vaguely in the right direction
I think the mesh placement tool ( Epic one ) is mapping screen space to world space. Another approach.
Big thank you for that setup. I tried it for my own project and it works, even though I had to change two things. Until now it works quite good - as far as I can tell, based on my quick tests.
But - first - if someone else is curious and wants to try it out:
Be careful! And use a test blueprint until everything works as intended!
After setting up the nodes and a quick Compile+Save, all my assets flipped upside down on the ceiling - straight into Spiderman Mode. Missed to take a screenshot there - but here is one with the assets on the roof instead.
No damage there, but it all happened so fast.
My changes for the BP:
- Reduced the Distance to 20. Right now it is enough, but I’ll maybe change it later on.
- Turned on 'Trace Complex’
- Replaced ‘Make Rot From X’ with 'Make Rot From Z’
- WIP for now: A boolean in front of the MultiTrace that gives me the option to disable it for specific Child classes.
Now everything works as intended, but one thing that may become a problem at some time: If I compile the parent class, every already placed asset in the scene re-runs the Construction script. That doesn’t happen regularly, but who knows …
But, again: A really big Thank You!
It might be an idea to make the default off, and you have to switch the trace on when you want to move an object.
Yes, a way better approach. Around 80% of the assets are positioned on the floor / on top of something anyway … with no need for MultiTracing. But my lovely pictures now snap to the wall the way they’re meant to! Brilliant.
How is this working though? Normal should be aligned with the z axis but you plug the normal into the X input of the block. Can you explain what Make Rot from X is doing?
X is forward. The forward direction of the normal vector. If you get what I mean…
I just tried what you’ve proposed and what worked for me is MakeRot from z.
EDIT - Actually this method is not working for me, as it changes the direction of the x axis as well.
You can use a Make rot from ZX, or something like that.