- Home /
Snapping Connection Points Together Rotation
Hello, I have been working extensively on a program for a block script that moves when you drag it. A 1x1x1 block has 6 connection points (one for each face), however, I am trying to make a placement system that would encompass blocks with larger dimensions and with a variable number of connection points. Here is the script I have so far when you drop the block on another block for position and rotation (I am checking for another block via raycasthit)
transform.position = blockDetect.collider.transform.GetComponent<ConnectPoint>().thisMainBlock.transform.position +
blockDetect.collider.transform.localPosition + connectPoints[selectedPointIndex].transform.localPosition;
transform.rotation = blockDetect.transform.rotation * connectPoints[selectedPointIndex].transform.rotation;
When I place the block, however, the rotation is off, I need the selected point (connectPoints[selectedPointIndex]) to be matched up with the connection point that I place it on (blockDetect is the raycasthit that hits the connection point that I am placing the dragged block on), however it will sometimes go inside the block I place it on because of it's rotation. So far, I have tried using Quaternion.Invert();
and Quaternion.AxisAngle();
on the rotation, but none of it has worked. I am probably doing it wrong.
I believe that the position is being set correctly, however, the rotation is not, does anyone have a solution?
are those connectionPoints representing the desired position and rotation exactly?
Without more context I'm a bit in the dark about all that is happening, but I sense you may have an issue between rotation and localRotation, position and localPosition.
Your answer
Follow this Question
Related Questions
Why is this rotation acting odd? 0 Answers
Quaternions acting up 1 Answer
Auto leveling help 0 Answers
Use a single rotation axis of a freely rotating object 1 Answer
How to Reverse an equation.. (c#) 2 Answers