Why this code moves the drawer only in the Z?

I don’t understand why the below code moves the drawer only on the Z ?

void Update()

{

    if (isGrabbed && drawerTransform != null){

        drawerTransform.localPosition = new Vector3 (drawerTransform.localPosition.x, drawerTransform.localPosition.y, drawerTransform.localPosition.z);

       

    }

}

It’s strange that it’s moving it at all. You are setting the position to itself, so you are saying;
My current location is (1,2,3). Please set it to (1,2,3)

I would suggest looking at the end of lecture code but your code in update should look something like:

drawerTransform.localPosition = new Vector3( _limitPositions.x, _limitPositions.y, transform.localPosition.z );
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms