Skip to main content
Tweeted twitter.com/StackGameDev/status/1368169499539673095
added 145 characters in body; edited tags
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

I'm a beginner in unity so I got this problem. Here is the script:

using UnityEngine;

using System.Collections;

public class Playercontrol: MonoBehaviour {

using System.Collections;
public class Playercontrol: MonoBehaviour {
    public float maxspeed = 10f;
    bool facingRight = true;
        
    void FixedUpdate () {
        float move = Input.GetAxis ("Horizontal");
 
    GetComponent<Rigidbody2D>().velocity 
 = new Vector2(move * maxspeed,   GetComponent<Rigidbody2D>().velocity.y);
                          = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);

        if (move > 0 && !facingRight){
            Flip ();
        } else if (move < 0 && facingRight) {
            Flip ();
        }
    }
            
    void Flip()
    {
        facingRight = !facingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;    
    }
    }

I don't know why but it keep saying that Can't add script component 'Player control' because the script class cannot be found.Make sure that there no compile errors and that the file name and class name match.

I'm a beginner in unity so I got this problem. Here is the script:

using UnityEngine;

using System.Collections;

public class Playercontrol: MonoBehaviour {

public float maxspeed = 10f;
bool facingRight = true;

void FixedUpdate () {
    float move = Input.GetAxis ("Horizontal");
 
    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
                                       if (move > 0 && !facingRight){
        Flip ();
    } else if (move < 0 && facingRight) {
        Flip ();
    }
    }
    
    void Flip()
    {
        facingRight = !facingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;    
    }
    }

I don't know why but it keep saying that Can't add script component 'Player control' because the script class cannot be found.Make sure that there no compile errors and that the file name and class name match.

I'm a beginner in unity so I got this problem. Here is the script:

using UnityEngine;
using System.Collections;
public class Playercontrol: MonoBehaviour {
    public float maxspeed = 10f;
    bool facingRight = true;
        
    void FixedUpdate () {
        float move = Input.GetAxis ("Horizontal");
     
        GetComponent<Rigidbody2D>().velocity
             = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);

        if (move > 0 && !facingRight){
            Flip ();
        } else if (move < 0 && facingRight) {
            Flip ();
        }
    }
            
    void Flip() {
        facingRight = !facingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;    
    }
}

I don't know why but it keep saying that Can't add script component 'Player control' because the script class cannot be found.Make sure that there no compile errors and that the file name and class name match.

Source Link
Bob
  • 127
  • 3
  • 11

I can't add script in unity

I'm a beginner in unity so I got this problem. Here is the script:

using UnityEngine;

using System.Collections;

public class Playercontrol: MonoBehaviour {

public float maxspeed = 10f;
bool facingRight = true;

void FixedUpdate () {
    float move = Input.GetAxis ("Horizontal");

    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
                                       if (move > 0 && !facingRight){
        Flip ();
    } else if (move < 0 && facingRight) {
        Flip ();
    }
    }
    
    void Flip()
    {
        facingRight = !facingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;    
    }
    }

I don't know why but it keep saying that Can't add script component 'Player control' because the script class cannot be found.Make sure that there no compile errors and that the file name and class name match.