Trying to fix a Vector3 script

So i made a vector3 script to change the scaling.

    {
        if (Input.GetKey("f"))  // If the player is pressing the "f" key
        {
            // makes the object shrink.
            Vector3 CurrentScale = transform.localScale;
            Vector3 newScale = CurrentScale + new Vector3(0, 0. - 0.4);
            Transform.localScale = newScale;
            Debug.Log("Shrunk!");
        }

    }

It gives me a console error at the - line 5 (just says identifier expected), and a "object reference is required for the non-static field method or property "Transform.localScale’
i dont know what the problem is

Transform with a capital T is a class, if the class derives from MonoBehaviour, transform with a lowercase t is a reference to the game object’s transform which the class is attached to.

I’m guessing that you have used an uppercase in your code but have pasted it with a lowercase which is correct. Once you get past that though, floats need to be defined with an f at the end. So -0.4 will give an error, just add an f so it reads -0.4f instead.

Vector3 newScale = CurrentScale + new Vector3(0, 0. - 0.4f);
like this? transform is working now, but this is not working, still a error on -

You have a period instead of a comma after the second 0

2 Likes