i mostly want to get my homework done, but i can’t tell what is wrong, what should i fix for the code to work?
What are you trying to do? What is happening when you try to execute the code? What did you expect to happen? What error messages are you getting?
Also add your full code into a code block, pictures don’t help.
As I see your code, why it is not working is obvious, but you should refrain from writing low effort posts. If you want someone to spend his time to help you, you should also spend your time to write a post that is properly formatted and explains your problem, what you have tried, what is happening and what errors you have as detailed as possible.
IF you have an error, fix it.
The complete error message contains everything you need to know to fix the error yourself.
The important parts of the error message are:
- the description of the error itself (google this; you are NEVER the first one!)
- the file it occurred in (critical!)
- the line number and character position (the two numbers in parentheses)
- also possibly useful is the stack trace (all the lines of text in the lower console window)
Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.
Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly? Are you structuring the syntax correctly? Look for examples!
All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.
If it’s just not working, debug it.
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...);
statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.
using UnityEngine;
public class movecontroller : MonoBehaviour
public float playerSpeed = 2.5f;
// Update is called once per frame
void Update()
{
}
if(Input.Getkey(Keycode.A))
{
transform.Translate(Vector3.left * Time.deltaTime * = playerSpeed;)
}
if(Input.Getkey(Keycode.D))
{
transform.Translate(Vector3.right * Time.deltaTime * = playerSpeed;)
} if(Input.Getkey(Keycode.W))
{
transform.Translate(Vector3.forward * Time.deltaTime * = playerSpeed;)
} if(Input.Getkey(Keycode.S))
{
transform.Translate(Vector3.back * Time.deltaTime * = playerSpeed;)
}
it is a script for a component on the object
26,75, but i’m new enough that i don’t know what 26 75 in parantheses would mean.
See the third bullet point in what I already posted.
line 26 but what does the 75 mean?
Go back and read the REST of the third bullet point.
the error is cs1315 btw, so a curly brace is missing, but i can’t tell how it is missing? maybe that could help, the code is in pics
Sounds like you better go over that line one character at a time with where you got it from.
Clue: looks like you made the typing mistake once, then copied it, so you have it in there twice.
Review step #1 below:
Two steps to tutorials and / or example code:
- do them perfectly, to the letter (zero typos, including punctuation and capitalization)
- stop and understand each step to understand what is going on.
If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.
what is the mistake? sorry but i’m very new and mostly doing this for a random homework rather than having any formal education
There are at least FIVE typing mistakes. We can’t fix your typing mistakes.
It is on you to go back to where you go this from and type it correctly.
i used this tutorial: https://www.youtube.com/watch?v=wH_bNxocHSc
i can’t tell what i actually wrote wrong according to this tutorial.
if you don’t want to tell, then i’ll get someone else to do my homework, it’s not anyone’s fault that i’m incompetent, but i honestly was never interested in coding to begin with, this is to get over with school.
That sounds like it might be best in this case if you are simply unable to compare two lines of text.
In 25 seconds of pressing the right key to step through that video I found the code and I can clearly see the difference between the video and what you typed.
Go fix your code. We cannot do it for you. We cannot reach your keyboard.
you can tell one of those differences then, if i genuinely was able to easily see the difference this post wouldn’t even be made, this comes off as empty snarkposting.
I mentioned that I could easily spot why this doesn’t work, I assure you that @Kurt-Dekker was not snarkposting. Instead of being lazy you should try and follow the advices given in this topic.
Considering the way you write your posts, I’m pretty sure it is your fault.
Asking for help is different than waiting for someone to do your job for you or asking for someone to give you a way to avoid the consequences of you actions.
You mentioned that this is homework, if you had devoted half the time to learn for this homework instead of writing these posts you would have solved it by now.
The solutions are really, really, really easy and obvious. If you want to stop being “incompetent” as you mentioned then as I said in my reply, stop low effort posts and follow the advice given here, being lazy or writing that people here are “snarkposting” won’t get you anywhere.
Put all INPUT methods into the large box of Update,like this:
Update
{
if(Input){}
if(){}
if(){}
}