Are there any problems with my script? The console is telling error, but I can't find any.

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour 
{
	public float speed;
	void FixedUpdate ()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");

		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		rigidbody.velocity = movement * speed;
	}
}

despite showing the error (not related to your code), do you have a concrete problem?

1 Answer

1

This code is for moving my player. but he is not moving.
@hexagonius

your rigidbody might be kinematic, in which case it won't move. or speed is 0. debug each change to movement to see where that's zero in the latter case