Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null reference in update status #83

Open
michaelday008 opened this issue Feb 12, 2023 · 0 comments
Open

null reference in update status #83

michaelday008 opened this issue Feb 12, 2023 · 0 comments

Comments

@michaelday008
Copy link
Collaborator

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant