Hello I am currently trying to create rail grinding in my project. I created a test script that will rotate along the surface of the rail, but when testing it shows the Z rotation is changing but not the object itself?
Here is the code below:
{
Debug.DrawRay(startPoint.position, Vector3.down * lineDistance, Color.white);
RaycastHit2D hit = Physics2D.Raycast(startPoint.position, Vector3.down * lineDistance, lineLayerMask);
if ((hit.collider == null))
{
return;
}
else
{
Debug.Log($"{hit.collider.gameObject.transform.rotation.z}");
transform.rotation = Quaternion.Euler(0f,0f ,hit.collider.gameObject.transform.rotation.z);
}
} ```