An error screenshot:

Move scripts:
using System.Collections;
Using System. Collections. Generic;
using UnityEngine;
Public class move: MonoBehaviour {
The Transform _transform;
//Use this for initialization
Void the Start () {
_transform=gameObject. GetComponent(a);
}
//Update is called once per frame
Void the Update () {
MonitorUserSelectMoveGameObjet ();
}
///& lt; Summary>
///use iput monitoring user input in the use of the transform mobile game objects
///& lt;/summary>
Private void MonitorUserSelectMoveGameObjet ()
{
If (Input. GetKey (KeyCode. W))
{
_transform. Translate (_transform. Position + Vector3. Forward, Space. The World);
}
If (Input. GetKey (KeyCode. A))
{
_transform. Translate (_transform. Position + Vector3. Left, Space. The World);
}
If (Input. GetKey (KeyCode. S))
{
_transform. Translate (_transform. Position + Vector3. Back to Space. The World);
}
If (Input. GetKey (KeyCode. D))
{
_transform. Translate (_transform. Position + Vector3. Right, Space. The World);
}
}
}
CodePudding user response:
Error message clearly beyond the coordinates of camera screen beforeYou can know about the difference between camera coordinate system and world coordinate system
I think you want this code?
Float speed=1 f;
//
_transform. Translate (Vector3. Speed up * * Input. GetAxis (" Vertical ") * Time. DeltaTime);
_transform. Translate (Vector3. Right * * Input speed. GetAxis (" Horizontal ") * Time. DeltaTime);
//WASD can refer to the similar