Hi guys my name is cuddle bunny I'm working on a project and I'm making a prototype But the 2d move mint isn't working I want my 2d charter to go in all 8 directions But my script isn't working usingUnityEngine; usingSystem.Collections; publicclassPlayerMovement:MonoBehaviour{ publicfloat speed =1f; // Use this for initialization voidStart(){ } // Update is called once per frame voidUpdate(){ if(Input.GetKey(KeyCode.D) Transform.position +=newVector3(speed *Time.deltaTime,0.0f,0.0f); if(Input.GetKey(KeyCode.A) Transform.position -=newVector3(speed *Time.deltaTime,0.0f,0.0f); if(Input.GetKey(KeyCode.W) Transform.position +=newVector3(0.0f, speed *Time.deltaTime,0.0f); if(Input.GetKey(KeyCode.s) Transform.position -=newVector3(0.0f, speed *Time.deltaTime,0.0f); } } the error it giveing me is Assets/scrps/PlayerMovement.cs(15,29): error CS1525:Unexpected symbol `Transform' Assets/scrps/PlayerMovement.cs(18,29): error CS1525: Unexpected symbol `Transform' Assets/scrps/PlayerMovement.cs(21,29): error CS1525: Unexpected symbol `Transform' Assets/scrps/PlayerMovement.cs(24,29): error CS1525:Unexpected symbol `Transform' if you guys can tall me how to fix this i will be exstremly happy
Try using "transform" < Lower case t. Also, you do not need Vector3 as it is 2D movement, use Vector2.
ok i tyed that it sill giveing the errors it funny my mono say evry thing ok but unity say ther a problum
Spaces are your friends. Not sure if its because you pasted it right into the post instead of using Insert>Code. But also, you needed another ) at the end of each if statement. You had if(Input.GetKey(KeyCode.D) it needed to be if(Input.GetKey(KeyCode.D)) Anyway, here's the code you want: Code (CSharp): using UnityEngine; using System.Collections; public class PlayerMovement :MonoBehaviour { public float speed = 1f; void Start() { } void Update() { if(Input.GetKey(KeyCode.D)) transform.position += new Vector3(speed *Time.deltaTime,0.0f,0.0f); if(Input.GetKey(KeyCode.A)) transform.position -= new Vector3(speed *Time.deltaTime,0.0f,0.0f); if(Input.GetKey(KeyCode.W)) transform.position += new Vector3(0.0f, speed *Time.deltaTime,0.0f); if(Input.GetKey(KeyCode.S)) transform.position -= new Vector3(0.0f, speed *Time.deltaTime,0.0f); } } Play with the speed variable in the inspector if you want it to go faster.