Forum rules - please read before posting.

Player character won't render, getting RecalculateAll console error

edited December 2020 in Technical Q&A

Hi there!

My player character will not render in my scene (as simple as it is), and I'm getting a single console error at runtime:

NullReferenceException: Object reference not set to an instance of an object
AC.PlayerMenus.RecalculateAll () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:3121)
AC.StateHandler.Initialise (System.Boolean rebuildMenus) (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:116)
AC.KickStarter.SetPersistentEngine () (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:157)
AC.KickStarter.Initialise () (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1111)
AC.MultiSceneChecker.Awake () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:43)

To reproduce:

Start a brand new Unity project (3D), with a SampleScene that is empty. Import Adventure Creator, and this dummy character that should work out-of-the-box. (Trust me, I've tried 6 different character prefabs at this point, I'm sure it's not the character itself that has the issue.)

Use the Game Wizard to set up the project to be an AC game, name it "TestBed" (nice and simple). Create a "Prefabs" folder within the "TestBed" folder that gets created.

Create a simple 3D plane, then plop the dummy onto it (either the male or the female dummy). Check "Apply Root Motion" on its Animator component. Use AC's Character Wizard to create a Player and set this as its model.

In the "Player" component settings, set the variables and movement settings as per the Making a 3D Character instructions. Drag the model to the "Prefabs" folder to make it a prefab (choose "Original Prefab"), delete the model from the Scene, then drag the prefab to the "Player prefab" setting in AC's Settings tab, under "Character settings".

At this point, I replaced the default MainCamera with a SimpleCamera. NOTE: The Camera component is unchecked by default for some reason. This has caused me numerous headaches with "No cameras rendering" displaying at runtime. Check this component to enable it. Then, I set it as the game's default camera in AC's Scene tab, under "Scene settings".

When I click Run... nothing happens. I only see my plain plane with no player character in sight, and the error message mentioned above.

I'm pretty sure I recorded all of the steps to reproduce above. I may have forgotten to type a step above, or I may have forgotten to take a step in AC/Unity. I've done this about 10 times now, with different variations of attempts, so my memory might not be the best. Also, I know there's no animation controller set up, but even with that in place, the character still does not render.

Comments

  • edited December 2020

    Forgot to mention, this is the latest 2019.x version of Unity (2019.4.16f1).

  • It's nothing to do with your Player - and all to do with your replacing of the default MainCamera.

    When AC's Scene Manager is used to create a new "AC" scene, it will update the default MainCamera with scripts to make it the AC MainCamera.

    The AC MainCamera is the one that actually performs any rendering. Any other camera in the scene (GameCamera, SimpleCamera etc) is simply used for position/rotation/FOV reference.

    The MainCamera will "attach" itself to a given GameCamera, or transition between two, at any given time.

    For this reason, all other cameras in the scene will have their Camera components disabled - they shouldn't be doing any rendering themselves.

    See the Manual's "Cameras overview" chapter for full details.

    To fix the scene you've described above, go to AC's Scene Manager and opt to organise your scene objects at the top (either with or without folders). AC will re-generate the MainCamera that it needs to perform all rendering from. You can then create or assign your intended camera (e.g. SimpleCamera), and assign it in the Scene Manager's "Default camera" field to have the MainCamera refer to it when your scene begins.

  • That makes sense! I must've misunderstood that part and went off of an assumption about cameras. Thank you so much for your help in clarifying that aspect of AC! Re-adding the MainCamera via AC fixed it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.