Error on every input command

Hey Everyone, I’m new to unity. I just downloaded unity 3.4.1 64-bit (because I’ve a low end pc) and for the first day got accustomed to the interface. The next day, I decided to start coding. I first decided to make a script for some basic input and movement. I created a sphere and then created a new script Test. After I entered the code, I decided to run it, but it said that I’ve entered the code incorrectly, but my code seems all correct to me. I tried many things, Destroy(GameObject); and commands like that works but input commands just does’nt. Pls help me. I’m using Unity 3.4.1 and MonoDevelop for coding.
The Code–>

using UnityEngine;
public class test : MonoBehaviour
{
public float speed;
void start()
{
speed=50f;  rb=GetComponent<RigidBody>();
}
xInput=Input.GetAxis("Horizontal");
zInput=Input.GetAxis("Vertical");
void update()
{
//Trouble starts from here//
if(Input.GetKeyDown(KeyCode.W))
{
rb.Velocity=Vector3.Forward*speed
}
}

Pls pls help me

The lines 9 and 10 are outside a method; they cannot be used where they are. You also need to learn how to organize an script; it’s probably why you didn’t noticed that these two lines were not at a correct place.

Pleeease go look at some example code and match your code to those examples. You need to pay close attention to detail as everything is important. Capitalization, punctuation, etc all needs to be perfect. You also need to read the error messages you’re getting and try to understand them. If you don’t understand one, feel free to post here. Currently though, your code is just broken in so many ways I think the best option is to go so some basic scripting tutorials.

1 Like