Error CS1061 (169698)

Hey Guys, I wanted to make an Player Controller for a 2D Plattformer. But i keep getting the CS 1061 Error. Here is my code: PlayerController.cs Error CS 1061 (Unity 5) - Pastebin.com

Error is in the following lines; 33,45 and 35,27.

Full Error: Assets/Scripts/PlayerController.cs (xx,xx): Error CS1061: Type ´UnityEngine.Transform´ does not contain a definition of ´localScale´ and no extension method ´localeScale´ of type ´UnityEngine.Transform´ could be found (are you missing a using directive or an assembly reference?)

I wonder why I can not make transform.localeScale, because I see on google and in a YouTube Video, where I typed the full correct code from this guy, that it worked

YouTube Video (german, you can see the code at 20:22): https://www.youtube.com/watch?v=HebQN8RbgVU

It would be very helpfull if anybody could help me. Please dont laugh at my if I make any little mistake, because I’m new in Unity and C#

oh. Try GetComponent<Animator>().enabled = false it will make the character not move a single inch

Your problem here was probably that you did if (health = 0) { //allow to move } When you should of done: if (health > 0) { //allow to move } especially if your 'health' variable is a float, it is probably not exactly = 0. If the above still does not work, you have a serious 'bug' :) Even though my previous answer that you accepted seems better, I wanted to clarify that @Laiken answer was good too.

1 Answer

1

I believe the property name you are referring to is transform.localScale, and not localeScale
The error message is indicating it cannot find ‘localeScale’.

    public void Flip()
    {
        lookingRight = !lookingRight;
        Vector3 myScale = transform.localScale;
        myScale.x*= -1;
        transform.localScale = myScale;
    }

And, note, no one is here to criticize, we are all here to help one another. Welcome to Unity and to C#.

At first, thanks for your reply! But, the code you send with the reply is exactly the code I wrote. Or am I wrong? I will test it soon when my Visual Studio is full installed Sorry for my bad english, I'm from Germany :D

enabled doesn't work. It gives an error. But I was able to do it with another method. Thank you :)