Skip to content

null reference in update status #83

@michaelday008

Description

@michaelday008

Describe the bug
NullReferenceException: Object reference not set to an instance of an object
AnyRPG.TradeSkillPrerequisite.UpdateStatus (System.Boolean notify) (at Assets/AnyRPG/Core/System/Scripts/Quest/TradeSkillPrerequisite.cs:28)

To Reproduce
Steps to reproduce the behavior:

  1. set any trade skill to auto-learn
  2. use the new game window and have any unit spawn in unit preview mode

Expected behavior
no error

Additional context
The exact issue happens on line 27 of trade skill prerequisite

bool checkResult = playerManager.MyCharacter.CharacterSkillManager.HasSkill(prerequisiteSkill);

When a unit preview spawns, the player character is not spawned yet, so the reference is null.

Possible solutions

  • wrap these types of checks in if-then statement to prevent null reference
  • drop support for players in the scene not spawned through unit spawn nodes. This prevents the automatic setting of unit type to AI in this case.
  • only auto-learn skills if the player type is the actual player character. This requires testing to ensure that code that sets unit profile type to player is not re-triggered at any point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions