Minor hang-up with code

I’m stuck on this little hang-up, and I can’t figure out why Unity won’t compile this script, except for the fact that Visual Studio seems to expect me to end my start() function after the first line. I’m just starting to learn C#, so any help/advice/criticism would be much appreciated!

Visual Studio underlines the semi-colon following “float movementSpeed = 1” and says “} expected” and underlines the word void in front of update() and says “A namespace cannot directly contain members such as fields or methods.”

using UnityEngine;
using System.Collections;

public class SoldierControl : MonoBehaviour
{
    void start() 

{ 
    
            float movementSpeed = 1;
            public float jumpHeight = 1;
            public int lowerLimit = -10;
            int health = 100;
            int yPos = transform.position.y;
            bool isGrounded = false;
    }

    void update()
    {
            if (Input.GetAxis("Horizontal") == 1)
                moveRight();
            if (Input.GetAxis("Horizontal") == -1)
                moveLeft();
            if (Input.GetAxis("Jump") == 1 && isGrounded)
                jump();

        if (yPos < lowerLimit || health < 1)
            kill();
    }

    void moveRight()
    {
        rigidbody.AddForce(Vector3.right * movementSpeed);
    }

    void moveLeft()
    {
        rigidbody.addForce(Vector3.left * movementSpeed);
    }

    void jump()
    {
        rigidbody.addForce(Vector3.up * jumpHeight);
    }
    void kill()
    {
        destroy();
    }
}

The declaration of your public variables need to be at the class level, not inside the Start() method (which is why you receive the error). The declaration of your other variables probably also should be moved outside of the Start() method since they pass out of scope as soon as Start() is finished.

Though what you have here will work, you may want to initialize your floating point variables with floats rather than ints. For exmaple:

public float jumpHeight = 1.0f;