NZNathan/Project-Survive

[Bug] Code unreachable in over-ridden Start method

Closed this issue · 1 comments

Summary:
Overridden Start method doesn't return, causes initialization not start in Unity 5.6.2f1
Steps to Reproduce:
Run the game in editor mode, in unity 5.6.2f1
Expected Results:
Not getting Null Reference Exception
Actual Results:
Null Reference Exception Thrown, animator component not initialized,
More Info:
Since super call of the Start method never returns, rest of the lines are not read, causing null reference exception as result.
Example from PlayerMovement.cs

    public new void Start ()
    {
        base.Start();

        //Get Components      
        animator = GetComponent<Animator>();      <-- this Lines are not read 
        col2d = GetComponent<BoxCollider2D>();    <---/
    }

So I looked into this by throwing a debug.log above the get components line and it seems to read it for player movement and player combat so I'm not sure this is correct. Once the start method in the base class is finished unity continues to read the rest of the start method in the player movement.