Unity gets stuck when entering Playmode

hello, unity always gets stuck when i go into playmode. it says “EditorApplication.playModeStateChanged” i’ve already completely deleted unity once and reinstalled. I removed my project and added it again. No matter what i do it gets stuck at that point. I only have a simple script in the project that handles W,A,S,D input for character movement. I dont know what to do.

I use Unity 2020.1.3f1 on Windows 10

6389927--712283--upload_2020-10-6_21-55-45.png

Does it get stuck without your script?

If it only gets stuck with your script, then perhaps you have made an infinite loop somewhere.

Post your script. Please use code tags: Using code tags properly

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

1 Like

Hi! I disabled the script and still the same thing happens.
Edit: i removed the component completely and then i was able to enter playmode without a problem. Here is the Code:

using UnityEngine;
using System.Collections;

public class PlayerMoveS : MonoBehaviour {

    [Header("Settings")]
    public float speed = 1f;
    int currentNumber = 0;
    private CharacterController cc;
    private Animator anim;
    bool horseiswalking;
    private int _characterState;

    void Awake()
    {
        cc = GetComponent<CharacterController>();
        anim = GetComponent<Animator>();
    }

    void Update()
    { 
        // float v = Input.GetAxis("Vertical");
        //float h = Input.GetAxis("Horizontal")
    Vector3 forward = transform.forward  * speed * Time.deltaTime;
    Vector3 backwards = -transform.forward * speed * Time.deltaTime;

    //    Vector3 right = transform.right * speed * Time.deltaTime;
    //    Vector3 left = -transform.right * speed * Time.deltaTime;

    if(cc.isGrounded){

            if (Input.GetKeyDown(KeyCode.W))
            {
                _characterState++;
            }
            //Decrease state
            if (Input.GetKeyDown(KeyCode.S))
            {
                _characterState--;
            }

            //Clamp state between stopped and run values
            _characterState = Mathf.Clamp(_characterState, 0, 2);

            if (_characterState == 0)
            {
                horseidel();
            }
            else if (_characterState == 1)
            {
                horsewalking();
                Debug.Log(_characterState + " horse is walking" );
            }
            else if (_characterState == 2)
            {
                horsetroting();
                Debug.Log(_characterState + " horse is troting" );
            }
        }

        /*        if (Input.GetKey(KeyCode.W)){
                cc.Move(forward);
                horsewalking();
                horseiswalking = true;
                if(Input.GetKey(KeyCode.W) && horseiswalking == true ){
                    cc.Move(forward);
                    horsetroting();
                }
            }

        if(Input.GetKey(KeyCode.S)){
                cc.Move(backwards);
            } */

        if (Input.GetKey(KeyCode.D)){
            transform.Rotate(0, 1 , 0);
        }

        if(Input.GetKey(KeyCode.Alpha1)){
                   horsegalopping();
                }

        if(Input.GetKey(KeyCode.A)){
            transform.Rotate(0, -1 , 0); 
        }
    }

    void KeyPressed(int input) {
        currentNumber = currentNumber + input;
    //    Debug.Log(currentNumber);
    }

    void horseidel()
    {

        anim.SetFloat("gear", 0);
        speed = 0f;
    }

    void horsewalking (){

        anim.SetFloat ("gear", 1);
        speed = 2f;
    }

 
    void horsetroting (){
        anim.SetFloat ("gear", 2);
        speed = 5f;

    }

 
    void horsegalopping (){
    anim.SetFloat ("gear", 3);
    speed = 10f;
    }

    void horsejumping (){
        //todo
    }
}