ERROR: The type or namespace name 'localScale' could not be found (are you missing a using directive or an assembly reference?)

I am a Beginner and just started learning Unity 2 weeks ago.

I am Trying to Create just the Player Movement by my own…

My Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

    public Rigidbody rb;
    public Transform t;

    // Start is called before the first frame update
    void Start()
    {
        rb.velocity = new Vector3(0, 1 ,0);
    }

    // Update is called once per frame
    void Update()
    {

        
      //Movement code
        if(Input.GetKey(KeyCode.Space))
        {
            rb.velocity = new Vector3(0, 5, 0);

        }

        if(rb.velocity.z > 5)
        {
            rb.velocity = new Vector3(0, 0, 0);
        }

        if(Input.GetKey(KeyCode.W))
        {
            rb.velocity = new Vector3(0, 0, 5);

        }
        if(Input.GetKey(KeyCode.A))
        {
            rb.velocity = new Vector3(-5, 0, 0);

        }
        if(Input.GetKey(KeyCode.S))
        {
            rb.velocity = new Vector3(0, 0, -5);

        }
        if(Input.GetKey(KeyCode.D))
        {
            rb.velocity = new Vector3(5, 0, 0);

        }

       //THE CODE I HAVE ERROR:
        if(Input.GetKey(KeyCode.C))
        {
            t.localScale = new localScale(1, 0.6, 1);
        }
    }
}

pls help

1 Answer

1

The local scale is a Vector3. Try this:

t.localScale = new Vector3(1f, 0.6f, 1f);

thx" it worked