Align and rotate according to 2 actors

Sorry, I’ve read it like 5 times and I don’t understand what you want to do. Is A the parent of B? Do you want B to stay on the ground regardless the rotation of A? What does LT do in your example?

Please try and explain it in a different way.

Sorry, I read this too, and don’t get it … :frowning:

Can you do a really simple example with piccies?

Also, you might need to manipulate your actor’s origins/pivots if they are causing you problems.

Two things that come to my mind are:

  1. Use Add Relative Rotation with Sweep enabled. However, I think you won’t be able to sink the mesh into a sphere that way, just touch it, and I’m not really sure now how to determine the rotation axis.

  2. The angle by which you need to rotate the mesh will be approximately the same as the angle of vectors from the Sphere Center to Object A and from the Sphere Center to Object B. There’s a however here too: if the origin of Object B is not in its center, the angle will be different. But you can add a socket in the middle of Object B and get the vector from Sphere to Socket, that will give you a better result, I guess. To get the angle between the vectors, you can get [Acos] of [Dot] product VectorA • VectorB

Ok, thanks for the detailed explanation. It’s not your English, it’s the concept…

I think you can do it with spawning, you need to have consistency with your actor pivot points, otherwise you’ll never be able to align them. You can use the normal from the sphere at the connection point to align the other actor.

If you try and go down the sockets route, I think you might be in for a hard time. Either you need to create the sockets at run time taking the size of the attaching actor into account, or you need to control the way the actor attaches to the socket. Don’t know if that’s possible.

Does this make sense?

Can you narrow it down a bit? Will you always be spawning cubes onto a sphere?

Ok, sounds like you’ve got it covered. I saw this on my travels:


Although, again, I think the normal on the sphere at the point which intersects with the forward vector of the cube should give you coordinates and rotation.

So I worked around a bit and here’s what I’ve got.

  1. Two meshes: The first is already the component of the actor to be spawned:

and the second is the component that the actor will spawn after being spawned itself:

As you can see, their origins and sockets are different.

  1. Next, the blueprint that spawns the Actor:

It spawns the actor in a random point on the surface of the sphere.

Next, the actor BP:

It adds a component, and using Line Trace rotates it until it hits the surface of the sphere. Now, I’m pretty sure there’s a formula that allows to calculate the required angle and set the rotation at once based on the sphere radius and distance between two points on its surface, but I just couldn’t figure out how to translate the linear distance between the cube origin and its socket to the distance on the sphere surface, so maybe someone who’s better at math could help with that.

Note that the axes of the cubes should be correct for my blueprints to work properly, and Actor Tick is disabled in the blueprint from the start.

If you have any questions, feel free.

I thought about the sphere normal and I figured that would work great on a sphere with high poly count, but with less faces the rotation may be less accurate, especially if the mesh is located next to an edge of the sphere.

Hello @Tuerer & @ClockworkOcean

Thank you very much for looking into my problem! I really appreciate your help.
I had tried your proposals, approximatively.

You comfort me in the fact I only need a simple math answer!

With your help, I can set the actor rotation of the B actor, according to A actor (which is spawned according to the sphere). So, with the suggestive idea of the use of socket by Tuerer, the B Actor is perfectly fitted with the A actor!

I just need a relative rotation of Y (pitch) to adjust the B actor rotation to the sphere :slight_smile:

And, its just trigonometry! I have a isosceles triangle with Radius ‘R’ of the sphere, and widht ‘W’ of the actor B (by chance, my actor is cubic). I just need to calculate the angles because the triangle is always the same :slight_smile:

I will confirm that before the ending of the week. Still thank you guys!