A rather nooby c# question?

Okay, I bought the ultimate FPS addon a while ago, and it’s great, but I need a way to sprint.

So I went in there and wrote what I thought would work since I have no idea what I’m doing in C#

protected new void sprint()
    {
           if(Input.GetButton("Sprint"))
        MotorAcceleration = 5f;
        
    }

I’d post more code, but since the rest isn’t mine I’ll just tell you, The var up top is called " MotorAcceleration" which is = to .5f. So I figured if I got the button down below, and then set the value higher for when the button is pressed I’d be able to run.

It hasn’t worked or given me errors. I do have sprint bound to a key. Sorry if the answer is clear, as I said before I’m noob.

It would be useful if you provided the exact error message. It makes it a lot easier to help you.

… Please read my whole post next time.

Sorry, misread, thought you stated that it either hadn’t worked or had given you errors.

Anyway, in that case i’d guess that the sprint-function is not being executed, or that the MotorAcceleration variable doesn’t behave as expected. Do you run the sprint function inside of your update-loop?

Oh wow, I feel stupid now.

So now it works! Thanks a load man!.

Methods should have capital start letter, ie void Sprint() also you wont need to use protected new just use protected void. No need for the new bit.

No they don’t need capital start letters, this is purely a personal preference. Personally I capitalize the first letter of every word but there is no rule that you have to do this.

I should have stated it was for code beautifying.

I know everyone has different styles, but what is easier to read

    private Queue<GameObject> m_Queue; //The queue we use for FIFO method

    /// <summary>
    ///     Returns the total pooled GameObjects in this pool
    /// </summary>
    public int PoolCount
    {
        get { return m_GameObjects.Count; }
    }

    /// <summary>
    ///     Returns the total spawned GameObjects in this pool
    /// </summary>
    public int SpawnedCount { get; private set; }

    /// <summary>
    ///     Spawn's a GameObject from the pool or instaniate a new one if we need it.
    /// </summary>
    /// <param name="position"></param>
    /// <param name="rotation"></param>
    /// <returns></returns>
    public GameObject Spawn(Vector3 position, Quaternion rotation)
    {

or

    private Queue<GameObject> queue;
	
    public int poolcount
    {
        get { return somelist.Count; }
    }
	
    public int spawnedCount { get; private set; }

    public GameObject spawn_a_gameobject(Vector3 position, Quaternion rotation)
    {

I mean it don’t take much to make a code easier to read.

Beautiful to you, ugly as sin to someone else. Like I say I’m just playing Devils advocate. When I was in charge of a software department I banned upper case. No one was allowed to use a single upper case letter. The reason was I had to be able to move engineers onto a project that may have been written by someone else and they all had different styles. I lost count of the number of bugs caused by person B searching Person A’s code for a label and as they were doing a case sensitive search couldn’t find the label, function or variable they were looking for so wrote the code again from scratch when there was no need, thus introducing new bugs, long since eradicated.

Beauty is in the eye of the beholder.