Can You Help me with this code (It's in C#)

Heres My code
Its in C#
Legend: ____ = Can U Help Me?
-----code-----
public int Jump = 3;
void FixedUpdates()
{
if (Input.GetKeyUp("w"))
        {
            if (Jump > 0)
            {
               int Jump = (Jump - 1);
                rb.AddForce(0, 300, 0);
            }
               // if (Jump == 2)
               // {
              //      WaitForSeconds.(5000);
              //
                //
            }
            else
            {
                rb.AddForce(0, 0, 0);

             

            }
        }
}
-----End code-----
Nicholas RevelloAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
What do you need help with?
(eg. code explanation, missing functionality, bug fixing (The last 2 please be specific of what the requirements and/or problem is including stack trace)
0
Dr. KlahnPrincipal Software EngineerCommented:
There has to be more to the program than this.  Where are the headers and the includes?  Where is the main?  We need to see the whole thing, otherwise we are shooting in the dark at a problem that may well be somewhere else.  Show us the compile time errors and the run time errors, too.  If it doesn't compile that's one thing; if it compiles and doesn't run that's another.  The more information you give us, the better we can help you troubleshoot the problem.
0
AndyAinscowFreelance programmer / ConsultantCommented:
I guess you mean what is this
int Jump = (Jump - 1);

Basically some bad code.  It is meant to reduce the value in Jump (eg. 3 goes to 2) but the int creates a local variable called Jump and then promptly attempts to use it.  For C# it means that Jump starts out as zero (default) so it should be -1 after the line runs.
0
David Johnson, CD, MVPOwnerCommented:
int Jump = (Jump -1);
Error      CS0165      Use of unassigned local variable 'Jump'      29083423      
also instead of public int jump =3;  use
static int jump =3;
using System;

namespace _29083423
{

    class Program
    {
        static int Jump;

        static void Main(string[] args)
            {
            Jump = 3;
            int JJ = Jump;
            do {

                JJ--;
                Console.WriteLine(JJ);
            } while (JJ > 0);

            Console.WriteLine(Jump);
            Console.ReadKey();

        }
    }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David Johnson, CD, MVPOwnerCommented:
answered
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.