- Home /
Snapping to Object Forward Axis
Hello,
I'm trying to figure out how to snap a selected object to another object based on my input coordinates. In the diagram below, the red circles refers to my input coordinates at different times and locations. The blue is the 'another object' which is an elongated cube (with the arrows showing the facing angle). The black cubes are is the 'selected object' that snaps to the elongated cube.
So basically, if I were to drag my finger around, the black cube would 'slide' on the blue cube (NOTE: there is only one BLUE cube in each scene). Also worth mentioning that is this Top-Down (using X Z only).
I can make it work fine if the angle is fixed forward (like the left example in the diagram), as it would just be as basic as;
_blackCube.position = new Vector3(_input.position.x, 0, _blueCube.position.z);
But what if the blue cube was angled somewhat? It seems so simple, yet my brain is failing me currently, any advice?
Thanks.
Your answer
Follow this Question
Related Questions
how to find direction between two points 2 Answers
How to get offset postition after rotation ? (Spent hours figuring it out) 3 Answers
Vector movement according to rotation glitching out at non-square angles. 0 Answers
Transform angle to grid position 2 Answers
Aim Down Sights Positioning Problem 1 Answer