ok, i have tried a few tutorials (like 20 or something) for a 2D game and the scripts they used didn't help since im unable to make my own script (i keep getting errors). first i want to be able to make my character move atleast, and then make the sprite move (like a gif, the sprite changes when you push the move button. im using this script: using UnityEngine; using System.Collections; public class MovingPlayer : MonoBehaviour { public float moveSpeed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetKey(KeyCode.UpArrow)) { transform.Translate(new Vector3(-moveSpeed, 0, 0)) * Time.deltaTime) } if (Input.GetKey(KeyCode.DownArrow)) { transform.Translate(new Vector3(-moveSpeed, 0, 0)) * Time.deltaTime) } if (Input.GetKey(KeyCode.LeftArrow)) { transform.Translate(new Vector3(0, -moveSpeed, 0)) * Time.deltaTime) } if (Input.GetKey(KeyCode.RightArrow)) { transform.Translate(new Vector3(0, -moveSpeed, 0)) * Time.deltaTime) } } }
Well for starters, try a semicolon after your transform.Translate statements. Brush up on your C#, if you aren't an experienced programmer focus on learning C#.
i dun wanna learn programming i just want to make my character move for my portfolio t-t i wanna do gameart not gamedeveloping XDD can you explain why i am getting errors instead of making me learn something?
oh and also, i tried putting a semicolon in it and i even get more errors o-o thankyou for replying tho.
That was the solution, or at least one of them. If your going to use C#, your going to have to learn C#, I'm not saying become a C programmer, but clearly if you have to write a script, it must be syntactically correct, and you must know some basics.
No, we can't explain why you're getting errors without making you learn something. You would be unable to understand the explanations. @Foggy Noggin is quite right; you're missing semicolons at the end of your statements. If you're really unwilling to learn any programming, then you should quit trying to make scripts. Stick to things you can find among the standard assets or Asset Store, or find a friend who enjoys programming to help you out. It's a deep skill, I'm afraid — just like art, it takes some dedication and quite a bit of practice to get any good at it. On the other hand, I believe you can learn it if you try... and you may be surprised how much fun it is!
Ok, now look in the console in the Unity editor, it will tell you the error(s), which you may not understand, but it will also give you the line number and position of each error. Fix that line and try again. You may get another error, fix that line and so on. At some point you will run out of error and it will compile. Make sure you save the changes in the script .
well someone once told me " ; " is like a period to a sentence o-o im not sure what semicolons mean but i gave it a shot XDD anyway thanks, i will google wha it means.
the errors are saying: ; expected (line 20) } expected (line 20) ; expected (line 25) } expected (line 30) ; expected (line 30) } expected (line 35) ; expected (line 35) Operator '*' cannot be applied to operands of type 'void' and 'float' (line 20, 25, 30 and 35) and my script is: using UnityEngine; using System.Collections; public class MovingPlayer : MonoBehaviour { public float moveSpeed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetKey(KeyCode.UpArrow)) { transform.Translate(new Vector3(-moveSpeed, 0, 0)) * Time.deltaTime); } if (Input.GetKey(KeyCode.DownArrow)) { transform.Translate(new Vector3(-moveSpeed, 0, 0)) * Time.deltaTime); } if (Input.GetKey(KeyCode.LeftArrow)) { transform.Translate(new Vector3(0, -moveSpeed, 0)) * Time.deltaTime); } if (Input.GetKey(KeyCode.RightArrow)) { transform.Translate(new Vector3(0, -moveSpeed, 0)) * Time.deltaTime); } } } i already put the semicolons in it so i have no clue what to do now. it'd be awesome if you gave me a hint.
Now the problem is that your parentheses don't match up. Just like in school, if you wrote "x = ((y+z)*3)/2)" on your paper, you'd get points off because you have three ')' close parentheses but only two '(' open parentheses. So it just doesn't make sense. In your case, I think you just need to remove one of the doubled ')' in the middle of each Translate line, e.g.: Code (csharp): transform.Translate(new Vector3(-moveSpeed, 0, 0)) * Time.deltaTime); should be Code (csharp): transform.Translate(new Vector3(-moveSpeed, 0, 0) * Time.deltaTime); Whenever you've got an error on a line, and you've already checked the semicolon, counting parentheses is a good next step.
OHMYGOD I GOT IT FINALLY. 0 ERRORS. okay how to try the game? it'd be awesome if you could help me out tommorow when i continue making the game.
Erm... how have you done 20 or so tutorials, but you don't know how to try a game? Is there some particular difficulty in your game that just clicking the Play button doesn't do it?
Umm... what happens when you click the play button? Did you put your scripts on the objects? We arent mind readers, and we arent going to do your project for you. What are you doing differently from the tutorials you watched? When you did the tutorials, did you just watch, or did you follow along with the tutorials step by step to get the same results that they did? Following along helps for a few reasons: 1) you will remember what you learned better 2) you will have to debug some problems when things dont match up with what the tutorial shows, so you will learn more of the system 3) you will come out with a reference you can save that you can refer to in the future Honestly, I am not sure what you are doing here if you dont want to learn how to program. It almost sounds like you are taking some sort of class, but dont want to learn the material or do the work, and want the forum to do it for you. Whether or not that is the case, though, I recommend that you really think seriously about why you are here, why you are doing this project, and what uou are hoping to gain from this.