Forum rules - please read before posting.

2D Tutorial Player not Moving

Good day

I'm a relative beginner with Unity, although I've completed most of the introductory tutorials. I've recently started with AC and I'm having an issue with player movement while following the 2D tutorial. I've created the player sprite, followed the character creation editor, created a prefab from the new New Player folder and pulled this into the Player Prefab field in the AC Setting Manager.

When I run the game the player spawns where the sprite is currently situated in the scene, rather than where the player start icon is located. Also, when trying to move (click), I get the following messages in the Console:

NullReferenceException: Object reference not set to an instance of an object AC.PlayerMovement.PointControlPlayer () (at Assets/AdventureCreator/Scripts/Controls/PlayerMovement.cs:906) AC.PlayerMovement.UpdatePlayerMovement () (at Assets/AdventureCreator/Scripts/Controls/PlayerMovement.cs:119) AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:253)

NullReferenceException: Object reference not set to an instance of an object AC.PlayerInput.AttemptGrab () (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:2115) AC.PlayerInput.UpdateDrag () (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:2057) AC.PlayerInput.UpdateInput () (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:768) AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:155)

I might be mistaken, but this appears to be a relatively stupid mistake (maybe could be solved by simply assigning the player prefab somewhere?), but I'm not sure where I need to add the reference, or where I went wrong while following the tutorial. If the solution is not as obvious as that, please let me know which screenshots would assist with solving the issue.

Thanks in advance for any assistance.

Comments

  • The error messages suggest that your scene is lacking an AC MainCamera - could this be the case?

    When the Scene Manager is used to organise your scene objects, it should update/add a MainCamera to your scene. Check your Hierarchy for this, and check that it has AC's MainCamera component attached to it.

    The Player positioning issue may be separate. You can check if it's an issue with the prefab itself by seeing if the 2D Demo game's Player prefab has the same problem. You can find him in /Assets/AdventureCreator/Demo2D/Resources/Brain2D.

    If you drop Brain2D into your scene file, he'll override the default one you have assigned in the Settings Manager. Does he have the same issue?

    If not, it's most likely an issue with your Player prefab - in which case, if you'd like to share screenshots of your prefab's root and sprite-child, I can take a look to try to spot what's wrong.

  • Thanks, there was no Main Camera in the scene, and sorting that out fixed both issues

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.