Update Not Called in 2017,1,1f1

I have this script responsible for player movement and it gets both horizontal and vertical inputs. Whenever I entered play mode and started hitting W, A, S, and D the player remains stationary. It seems the Update() method was never called and Debug.Log(“Update”); never logs anything into the console.

I never had this issue before and I fear that the new update (2017.1.1f1) might have a bug regarding this issue.

Here’s my PlayerMovement Script

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

public class PlayerMovement : MonoBehaviour {

    public float speed;

    public Animator animator;
    
	
	void Update () {
        float XInput = Input.GetAxisRaw("Horizontal") * speed * Time.deltaTime;
        float YInput = Input.GetAxisRaw("Vertical") * speed * Time.deltaTime;


        Debug.Log("Update");
        
        Turn(XInput, YInput);
        Move(5f, YInput);
	}

    void Move(float x, float y) {
        x += transform.position.x;
        y += transform.position.y;

        transform.position.Set(x, y, transform.position.z);
    }

    void Turn(float x, float y) {
        if (x < 0) {
            animator.SetInteger("Direction", 3);
            //animator.SetBool("IsWalking", true);
        } else if (x > 0) {
            animator.SetInteger("Direction", 1);
            //animator.SetBool("IsWalking", true);
        }

        if (y < 0) {
            animator.SetInteger("Direction", 0);
            //animator.SetBool("IsWalking", true);
        } else if (y > 0) {
            animator.SetInteger("Direction", 2);
            //animator.SetBool("IsWalking", true);
        }

        animator.SetBool("IsWalking", x != 0f || y != 0f);
        
    }
}

All public variables are set.
This is a 2D game.

Is your script actually attached to a GameObject? If it is, is the checkbox next to the scripts box ticked in the inspector? Failing this, reinstall Unity, because 2017.1.1f1 definitely has Update working.

Well if you are 100% sure that your script is attached to an active gameobject. the script is enabled and your console is not set to “collapse”, there’s no reason why Update shouldn’t be called here. So if it really is not called at all, the problem is somewhere else.

However if your observation is mainly that your object is not moving, that’s another story. This line:

transform.position.Set(x, y, transform.position.z);

does nothing. “position” is a property of a value type. What you do here is calling the getter of the property which gives you a copy of the Vector3. Then you change the members of the copied Vector3 with the Set method. And nothing more. The actual position does not get changed. In order to change the position you have to invoke the setter of the property. You do that by assigning a vector3 value to position.

So either do:

x += transform.position.x;
y += transform.position.y;
transform.position = new Vector3 (x, y, transform.position.z);

or just:

transform.position += new Vector3 (x, y);

Another way would be to use Translate:

transform.Translate(x, y, 0, Space.World);

transform.position.Set();

appears to be the culprit.

transform.position += new Vector3();

works and the Debug.Log(); is outputting to the console.
The Set() method froze the whole Update method with no errors beforehand.

Thanks for the help :stuck_out_tongue_winking_eye: