NullRef exception in WaveManager



  • Hi

    I've run into a null error in WaveManager on line 838

    enemy.GetComponentInChildren<TweenMove>().pathContainer = options[waveNo].path[index];

    Error is:

    "NullReferenceException: Object reference not set to an instance of an object"

    I'm using peasant for prefab, have built a path in waveManager, and the peasant spawns correctly at waypointstart.
    But no movement or animation is being assigned.

    The waveManager is set to autostart

    Edit I have moved StartWaves unto a button. No change and autostart is ruled out edit

    Is there something obvious that I should check for?

    Best regards
    Pelle



  • Hi Pelle,

    thanks for posting the error. You possibly mean line 382 in WaveManager.cs? The script does not have 600+ lines.

    The enemy gameobject is checked right before that line so it can't be null. As you are saying that the enemy spawns at the first waypoint, the path can't be null either.

    What's left is the TweenMove script. Does the peasant still have a TweenMove script attached to it? Could you possibly upload a screenshot and post the link to it here?



  • Hi Baroni

    Thank you for your reply. you're absolutely right about the line number. Faulty memory on my behalf i guess :)

    I have referenced the peasant from your package directly, and the only thing I have been wondering about is the "pMapObjGround" reference and how significant it is.

    http://www.gamecraft.dk/images/peasant.png



  • "P Map Properties" are used for the progress map on the top of the screen, where it displays the progress of each enemy along a straight line. If you don't want to use the progress map, you won't need these properties. More explanations can be found on page 32-33 in the documentation pdf.

    Thanks for the screenshot. Well, the default prefab shouldn't cause that error. If you still experience it, could you please upload a screenshot of your waves too?



  • Ok I'll ignore PMapProperties for now.

    So far I've only got one enemy connected to Default Path

    http://www.gamecraft.dk/images/waves.jpg

    Default path screendump

    http://www.gamecraft.dk/images/debug-path.jpg

    Can't tell if it will make any difference



  • Thanks. Even though you probably want to delete the pMapObjGround from your scene and set some delay between enemies in the Wave Settings editor, I can't tell why that would cause any errors. So I'm pretty much clueless at the moment. I can see that you're not using some of the manager objects (Audio, PowerUp, Tower) and aren't using the provided GUI - in order to get to the bottom of this and save some time, please upload your project somewhere and send me an email with the link to it (not here).



  • I'll try to put in all managers first and stuff some more data into delay etc. and see what happens. If we can't find the problem I'll find somewhere to share i with you :)



  • Hi again

    I've tried a few different solutions.

    Using the "Enemy Setup" has taken me a little further. Enemies spawn and move, but isn't animating yet.

    But it's progress at least :)



  • *Using the "Enemy Setup" has taken me a little further. Enemies spawn and move, but isn't animating yet.
    *

    Check that the model rig and animation clips are set to "Legacy" in their import settings.


Log in to reply