1
\$\begingroup\$

For now I managed to resize my object but it resizes always from the center. I have the same problem like this question here.

I've been thinking like adjusting the position and stuff, but nothing works for my code. Here's my code

if (isMouseDragging)
    {
        //tracking mouse position.
        Vector3 currentScreenSpace = new Vector3(Input.mousePosition.x, Input.mousePosition.y, positionOfScreen.z);
        //converting screen position to world position with offset changes.
        Vector3 currentPosition = Camera.main.ScreenToWorldPoint(currentScreenSpace) + offsetValue;
        if(getTarget.CompareTag("LeftRightWall"))
        {
            currentPosition.y = getTarget.transform.position.y;
            currentPosition.z = getTarget.transform.position.z;
        }
        if(getTarget.CompareTag("FrontWall"))
        {
            currentPosition.x = getTarget.transform.position.x;
            currentPosition.y = getTarget.transform.position.y;
        }
        //It will update target gameobject's current postion.
        Vector3 v3Scale = getTarget.transform.localScale;
        getTarget.transform.localScale = new Vector3(v3Scale.x + 0.1f , v3Scale.y , v3Scale.z);
        getTarget.transform.position = new Vector3(mfX + getTarget.transform.localScale.x / 2.0f, 0 , 0);
        getTarget.transform.position = currentPosition;
    }

My idea is I want to make the gameobject tagged LeftRightWall will be resized whenever the FrontWall is dragged and vice versa, like adjsuting the room size but I want to know how to resize them first. Any ideas?

\$\endgroup\$
  • \$\begingroup\$ It resizes from your object's pivot point. You can edit the object's pivot point in your 3D editor. Place the point at the left/middle to resize towards the right, for example. \$\endgroup\$ – Doug.McFarlane Aug 8 '17 at 18:31
  • \$\begingroup\$ What about the other side? If I want to make the object to be able to be resize on both direction, according which sides the player choose. \$\endgroup\$ – Mira Aug 10 '17 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.