Scale gameobject on just one side

后端 未结 2 779
予麋鹿
予麋鹿 2020-12-10 21:59

I have added Cube to scene and I scaled and put to position ( 0, 0, 0 ). I am scaling that Cube with code attached to Cube

IEnumerator Start() {
    StartCor         


        
2条回答
  •  半阙折子戏
    2020-12-10 22:52

    You can actually do this in two ways.

    METHOD 1:

    Change pivot point from an external application.

    Create a simple Cube in a 3D software such as Maya then position the pivot point to the bottom of the cube and then export it Unity. This should work out of the box.

    METHOD 2:

    Parent the Cube to an empty GameObject.

    Steps:

    A.Create a an Empty GameObject.

    B.Move the new GameObject to the position of the Cube then move the y axis of that new GameObject to the bottom of the cube. The y-pos must be positioned precisely by zooming in. See to the animation below for more information.

    C.Now drag the Cube to the that new GameObject and the cube should be the child of that new GameObject. You can now attach the script in your question to that new GameObject and it should scale the cube on one side only. Don't forget to remove the old scaling script that is directly attached to the cube.

    Image Tutorial. High quality version here.

提交回复
热议问题