Search Unity

Adventure Game Q&A

Discussion in 'Community Learning & Teaching' started by Adam-Buckner, Dec 21, 2016.

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This is the official thread for discussion, issues and Q&A for the Adventure Game project

    Please use this thread if you have any questions, issues or feedback on this project.

    Adventure Game is a learning project on our Learn Site:
    https://unity3d.com/learn/tutorials/projects/adventure-game-tutorial

    Originally shot at Unite LA 2016 Training day, the Adventure Game tutorial will teach you how to make a point and click adventure game. It is aimed at intermediate learners.

    When discussing, asking for help or reporting an issue, please tell us which phase you are referring to.

    Phase 1 teaches you how to build a click to move animated character using the EventSystem, NavMesh, Animator and Prefabs.

    Phase 2 teaches you how to build an inventory including building a UI and item management system for player inventory using Unity's UI System and some editor scripting.

    Phase 3 teaches you how to build an interaction system, focusing on conditions. We will create a system to check the current game state, discuss scripting patterns and use scriptable objects, generic classes, inheritance and extension methods.

    Phase 4 continues teaching how to build an interaction system focusing on reactions. We will create a system to perform actions based on condition state using polymorphism, further editor scripting and discuss serialization.

    Phase 5 continues teaching you how to build an interaction system, focusing on interactables. We will create a system to define what the player can interact with including interactable geometry, use the EventSystem and give an interaction system summary.

    Phase 6 teaches you how to create a system to load scenes while preserving game state using the Scene Manager, ScriptableObjects as temporary runtime data storage, delegates and lambda expressions.
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Thank you for this! I really enjoyed watching the series. :)
    I like that the learn site is featuring more and more content for intermediate/advanced users.

    Is there a reason for choosing Editors and SubEditors as shown in phases 3 and 4 over PropertyDrawers?
     
  3. ag_858

    ag_858

    Joined:
    Mar 28, 2014
    Posts:
    4
    In the video for making the Player prefab: phase 1b, when you playtest the character walking around for the first time (44:30) I get an error.
    I get the "SetDestination()/Resume() can only be called on an active agent that has been placed on a NavMesh" error and the character does not move.

    I've tried using more forgiving NavMesh settings, ensuring the NavAgent is touching the ground, checked through all the scripts , was sure to add in the UnityEngine.AI namespace since I'm using 5.5 but I'm still unsure of where I'm going wrong.

    Fantastic series, by the way! Loving the extra lengths you guys and gals went to on this training day.
     
  4. Cleite

    Cleite

    Joined:
    Dec 17, 2016
    Posts:
    4
    I'm just wondering whether I've understood the workings of the following line in the PlayerMovement script in phase 1b), in the function Moving().
    Code (csharp):
    1. transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, turnSmoothing * Time.deltaTime);
    If I read this correctly, then it doesn't actually directly turn the player from the initial rotation to the desired rotation over a set amount of frames, but rather, for each frame, checks the current rotation, and then rotates the player a certain fraction of however much is left in order to reach the desired rotation. Said fraction is given by the actual value of turnSmoothing * Time.deltaTime.

    So if, for instance, turnSmoothing is 15, and the framerate is 50Hz (which makes deltaTime 0.02), then for each frame the above line will turn the player 30% of the "remaining" distance to the desired direction. Mathematically, the player will actually never entirely reach the desired rotation, but rather close in on it exponentially (which means that for a computer working with floats, it will quite quickly become indistinguishable from the true desired direction).

    Is this right, or have I minsunderstood what is going on here?
     
  5. ag_858

    ag_858

    Joined:
    Mar 28, 2014
    Posts:
    4
    Yes, I think you're right. This produces a rotation that starts off relatively fast and slows down as it reaches it's target.
     
  6. ag_858

    ag_858

    Joined:
    Mar 28, 2014
    Posts:
    4
    Ah, silly me. I had a reference to the player prefab instead of the player instance in the event trigger.
     
  7. scottcoresvt

    scottcoresvt

    Joined:
    Jan 3, 2017
    Posts:
    1
    I'm about halfway through Phase 1b where you first test the player's movement, I have a problem that I think is related to the Animator Controller and haven't been able to troubleshoot it:

    When ClickToMove is selected as the Animator Controller, the player takes one step into the room and then stops. Subsequent clicks rotate but don't change her position.
    When 'None' is selected is the Animator Controller, the player floats around the room in the starting posture.

    Any advice on what I'm missing? Thanks.

    EDIT: Figured it out, I had the 'greater than' and 'less than' mixed up for player idle and walking states.
     
    Last edited: Jan 8, 2017
  8. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Hello there!

    TL;DR No functional reason. Editors are easier to teach and EditorWithSubEditors included some C# features I wanted to teach.

    There are some reasons why I chose to use Editors and Sub-Editors over PropertyDrawers, though nothing so substantial as "Editors are just better!" or anything like that! Using PropertyDrawers can be tricky when you're dealing with multi-line inspectors since you have to calculate the size required in advance. Combine that with having sub-PropertyDrawers and it gets more tricky. None of this is impossible of course, but it is difficult to teach. Using Editors also gave me the chance to introduce abstracts and generic classes which is something I find incredibly useful and something that I don't believe we've covered much before.

    Hope that helps. Glad you liked the training!
     
    Xarbrough likes this.
  9. Tris73

    Tris73

    Joined:
    Oct 1, 2016
    Posts:
    4
    Hi,

    I'm on phase 3/6. The PDF tells me to click the 'Add Collection' button of the 'Intractable' component, but I receive 4 errors in the console when I do this. Any assistance would be appreciated. I haven't had a chance to break down the code. I was going to do that after finishing up the PDF. I'm using Unity 5.41 if that matters. This was after downloading phase 3/6 install. I then downloaded phase 4/6 and it worked without any issues. I would just like to know for troubleshooting purposes on my own project. Error message 01 may not be relevant to the problem. I was trying out various things.

    ERROR MSG 01:
    NullReferenceException: Object reference not set to an instance of an object
    PlayerMovement.Start () (at Assets/Scripts/MonoBehaviours/Player/PlayerMovement.cs:44)

    ERROR MSG 02:
    NullReferenceException: Object reference not set to an instance of an object
    InteractableEditor.SubEditorSetup (.ConditionCollectionEditor editor) (at Assets/Scripts/Editor/Interaction/InteractableEditor.cs:39)
    EditorWithSubEditors`2[TEditor,TTarget].CheckAndCreateSubEditors (.TTarget[] subEditorTargets) (at Assets/Scripts/Editor/Abstracts/EditorWithSubEditors.cs:23)
    InteractableEditor.OnInspectorGUI () (at Assets/Scripts/Editor/Interaction/InteractableEditor.cs:47)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
    UnityEditor.DockArea:OnGUI()

    ERROR MSG 03:
    ArgumentException: Getting control 0's position in a group with only 0 controls when doing Repaint
    Aborting
    UnityEngine.GUILayoutGroup.GetNext () (at /Users/builduser/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:665)
    UnityEngine.GUILayoutUtility.DoGetRect (Single minWidth, Single maxWidth, Single minHeight, Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:410)
    UnityEngine.GUILayoutUtility.GetRect (Single minWidth, Single maxWidth, Single minHeight, Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:399)
    UnityEditor.EditorGUILayout.GetControlRect (Boolean hasLabel, Single height, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7316)
    UnityEditor.EditorGUILayout.GetControlRect (Boolean hasLabel, Single height, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7311)
    UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:193)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7296)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7278)
    InteractableEditor.OnInspectorGUI () (at Assets/Scripts/Editor/Interaction/InteractableEditor.cs:49)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
    UnityEditor.DockArea:OnGUI()

    ERROR MSG 04:
    NullReferenceException: Object reference not set to an instance of an object
    InteractableEditor.OnInspectorGUI () (at Assets/Scripts/Editor/Interaction/InteractableEditor.cs:53)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
    UnityEditor.DockArea:OnGUI()
     
  10. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    @Tris73 Hello there, I can tell you what caused the error but not how it came about I'm afraid. Errors 2, 3 and 4 are all caused by the same thing. SubEditorSetup is called whenever new subeditors are required by an editor that has subeditors. Specifically, the editor that is passed to the function is created using the CreateEditor function and can be null (as it is in your error) under the following circumstances:
    - the target for editor creation was null
    - there was a type mismatch between the created editor and the generic type it is cast to in EditorWithSubEditors
    - there was no potential editor to create for the given target
    Of these the most likely is that the target created was null so when looking into how it happened I suggest starting your search there.

    Have you edited the PlayerMovement script? Because according to my version there is no code to null ref on the line specified by your error code.

    Sorry I couldn't be more help.

    P.S. On a semi-related note, I recommend you use the PDFs for guidance and use the videos to follow the tutorial.
     
  11. Tris73

    Tris73

    Joined:
    Oct 1, 2016
    Posts:
    4
    James, thank you very much for the quick response and helping me to narrow down my search parameters. I'll take a look and post what I find.
     
  12. Tris73

    Tris73

    Joined:
    Oct 1, 2016
    Posts:
    4
    @JamesB Thanks. You were right about the target being null. I must have looked over the ConditionCollectionEditor script hundreds of times and missed the one line. I found it with a Diff tool :mad: So much for attention to detail. Well, if nothing else, I have a better understanding of how the scripts interact. I left this line out:

    conditionCollection = (ConditionCollection)target;

    Thanks again. I can sleep peacefully now :)
     
  13. AmuletGames

    AmuletGames

    Joined:
    Feb 10, 2016
    Posts:
    3
    Sorry, can I ask a question?
    In Phase 1, you used the "agent.desiredVelocity" to set the speed, what is agent.desiredVelocity?
    And what is the difference between agent.desiredVelocity and agent.speed?
     
  14. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    hey everyone,
    at phase 4 i have a bunch of questions.
    basically about the Editor.CreateEditor(); .
    my question is, when creating the condition collection, and condition sub editors (and i have used the same system for my own inventory too) (Inventory>Slots>Items){following this chain}. it appeared to me that, i always get null after casting the newly created editor with that function as {TEditor}. (EditorWithsubEditors Script)
    the fix to that, was using the second overload form of the Editor.CreateEditor(Object,TypeOf(TEditor)); after using it in this form, it worked perfectly.

    however, the issue i have faced when using this form, is simply because, this overloaded version of the function, is unable to create the Abstract Editor which is (ReactionEditor).
    this issue was solved by using the first overloaded form of the function which is Editor.CreateEditor(Object); where i do not specify the type.

    can any one please elaborate and give some detailed explanation on this issue? i mean, sure it worked, but i do not really deeply understand what is going on. perhaps i do believe the key thing lies within the Editor.CreateEditor function, but the manual is well.... does not say much really.

    would be really glad if someone helps, thanks guys..

    Edit: i'd just like to say, when i download the package it works fine without any changes, but what i am doing is trying to create these systems from scratch and put them in my game. and so, while im doing that, this is the trouble i came across.

    so do i just make it a rule inside my mind? when creating abstract editor that needs to be overridden i use the first form, other wise i use the second form?.

    an explanation would be really appreciated. thanks in advance again everyone.

    Edit2: after this long post i'd like to say, that, if i want to use the first form i must put an attribute on the top of the class, but if i want to use the second form, i can simply not put the attribute.

    so i guess it was solved :D
     
    Last edited: Feb 4, 2017
  15. DDAUDIOSOLUTIONS

    DDAUDIOSOLUTIONS

    Joined:
    Sep 5, 2015
    Posts:
    21
    Hi everyone, i try to remake the sound of this demo with Fmod, for now all works, but in the console, the fmod send me a message about some dlyb that in the other demos not appear. Are there some incompatiblity?

    thanks
     
  16. Coolguy6316

    Coolguy6316

    Joined:
    Oct 20, 2013
    Posts:
    2
    Hi all loved the series
    Just wanted to ask how would I do proper saving? so you can close game and carry on later
    I'm not too good at coding so please go easy on me :p

    Thanks :D
     
    JamesArndt likes this.
  17. rasert

    rasert

    Joined:
    Jun 28, 2015
    Posts:
    1
    Hi. I have started working on Phase 1 with Unity 5.5. Today I updated to Unity 5.6 and got some issues.

    When I try to edit the ReactionCollection of some interactables, the unity console shows me some errors like this:

    NullReferenceException: Object reference not set to an instance of an object
    ReactionCollectionEditor.OnInspectorGUI () (at Assets/Scripts/Editor/Interaction/ReactionCollectionEditor.cs:57)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1229)
    UnityEditor.DockArea:OnGUI()

    I think that this is some compatibility issue. But I don't really know. I am just a beginner.

    Other problem that I am facing, is with the pathfinding system. Every time I click on the ground, the character takes from 5 to 10 seconds to start moving towards the destination. I can't figure out what is wrong. I did every step like the videos. This problem was already present with unity 5.5.

    I hope that you guys can help me. I am very excited to learn everything I can from this tutorial so I can take one more step in my goal of being a game developer.

    Thanks in advance. =]
     
  18. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I would suggest that you double check the steps as I don't recognize these errors as being an upgrade issue.

    Perhaps @JamesB might know more.
     
  19. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    @rasert I've had a look into the code to see what could be causing your problems. The null reference you are reporting comes from having editors created for null objects. So in your case it seems like a null Reaction has been created somehow, then when the corresponding Editor is created, it is created as null as well. I'm not sure how this could come about but my recommendation to try and fix it would be to reset the component. This should clear out all Reactions, null or otherwise. From there you should be able to start afresh and have no more null Reactions or Editors.

    As for the Player taking a really long time to move anywhere... that's a really weird one. I honestly have no idea what could be causing that. My suggestion would be to Debug the code by attaching the code editor you are using to the Unity Editor. If you're not familiar with how to do that, try adding Debug logs to the code to see what is being called when. Do this by adding lines like:

    Debug.Log("OnGroundClick called.");

    When you have a few of these logs in the code, see when the various bits of code are being called by testing it. This should help determine where the delay is coming from.
     
  20. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    Everytime I open the "Persistent" scene, it's marked with an asterisk and asks me if I want to save the changes when I try to open another scene, as if it has been edited (it wasn't, just opening the scene leaves an asterisk). Anyone knows why is this happening? Is something like a corrupted asset or scene file causing this problem? Should I just save the scene and hope that will cause the problem to go away? I was changing the aspect ratio at one point, but I don't believe such changes and saved in the file of the current scene.
     
  21. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    @ZeRuc Are you loading the Persistent scene by itself or with other scenes loaded at the same time? Make sure that the scene is the only one loaded and make sure during the loading of the scene nothing is selected (so nothing is shown in the inspector). If nothing is selected does the asterisk still appear?

    Another possibility is that the lighting is getting baked (despite there being no lights) whenever the scene is loaded. Immediately upon loading the scene, check the bottom right hand corner of the editor for a blue bar. If this blue bar appears then the lighting is baking and this is the cause. If this is the case, turn off light baking.
     
  22. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    I wasn't even aware that you can have two scenes loaded at the same time. However, whenever I try to open another scene, I get a "Scene(s) Have Been Modified" dialog. The option to unload scene is greyed out, as you can see in the uploaded screenshot (taken just after Unity loads the project).
     

    Attached Files:

  23. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Have you confirmed that it's not lighting causing it?
     
  24. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    Yup, there was no blue bar in the bottom right corner.
     
  25. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Next step to finding out what's up is a bit more involved. Make sure your scenes are using text serialization and open them in a text editor (notepad++ or sublime) and compare before you open the scene to after. One of the values will have changed and this is what was causing the scene to dirty. This technique can also be achieved with VC merge software such as P4merge. If there are no differences between before and after in the scenes then it's a bug with Unity and you should report it.

    Hope this helps.
     
  26. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    I have compared scene files before and after opening and there are some differences. Since I can't figure out what is causing the differences, I am attaching both files to this post (renamed .txt, since the forum doesn't allow .unity extension).
     

    Attached Files:

  27. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Sorry, I don't have time to look through these myself. If you find the differences post them here and I will try and help you find the cause.
     
  28. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    There are differences in more than one place, so I can't realistically place them all in a post.
    For example lines 4-16 have the following data
    in "before"
    and
    in "after".
    Under NavMeshSettings, file "after" has the following line:
    agentTypeID: 0
    I coud go on...
     
  29. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    After saving does it revert?
     
  30. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    I have tried saving the scene manually and the data remains unchanged (the same as in Persistent.unity.after.txt), if that's what you mean.
     
  31. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    What I mean is, if you are required to save each time, something must change each time. Track down what is changing each time. My only guess would be that it's not updating the scene to the correct version of Unity or something, but honestly I'm not sure. There's not really much more I can advise you with.

    Find what changes with each save.
    Find the pattern.
    Determine what the pattern of changes mean.
    Either fix the pattern change or report a bug.
     
  32. ZeRuc

    ZeRuc

    Joined:
    Mar 3, 2017
    Posts:
    25
    I have not been prompted to save the scene on subsequent scene loads, only until I save the scene for the first time. However, I made no changes to the scene between opening and saving, so Persistent.unity.before.txt should be the same as Persistent.unity.after.txt. It's not a problem I can't live with - especially when it's happening in a tutorial project, but I thought it might be a known bug or issue.
     
  33. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    Hi,

    I was wondering who created the asset for the game as I love the art style. Can we use those assets in any commercial project?

    Thanks

    Jonathan
     
  34. MonetAudio

    MonetAudio

    Joined:
    Apr 17, 2017
    Posts:
    4
    Hi I downloaded the full game and have gotten so many errors. Is anyone else having this problem? Can anyone help me?
    @Tris73 Some of my errors are the same as yours. Were you ever able to fix it?
     

    Attached Files:

    Last edited: May 3, 2017
  35. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    Have you tried getting it from the assets store rather than downloading it? Also what version of Unity are you using?
     
  36. MonetAudio

    MonetAudio

    Joined:
    Apr 17, 2017
    Posts:
    4
    @jonny2027 I got it from the asset store. I have tried it on 5.6, and on the Unity version it was actually released on 5.0, and 5.4.3
     
  37. MonetAudio

    MonetAudio

    Joined:
    Apr 17, 2017
    Posts:
    4
    Hey quick question. Not sure if you can help me but I am new to unity and did not know that I need to run the persistent scene to play the game. I am currently trying to hook FMOD into the program to do my own version of audio. My question is do I complete this through the individual scenes, save them, and run it through the persistent scene? or do I have to do that through the persistent scene only?
     
  38. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You can use any assets that belong to Unity in any project, either commercial or non-commercial.

    You cannot distribute or resell these assets or pretend you are the owner or creator of these assets.

    You could, if you want to, simply publish and distribute an example or tutorial project without any modification - even for profit, but we recommend that you don't, as it will make you look a little foolish.

    The only exception I'd say to the "you will look foolish" rule is when you complete a tutorial or lesson and just want to show off that you have finished a tutorial project, in which case people should say "Fantastic!" and wait for your next great release.

    Assets owned and distributed by other authors on our sites, such as the asset store, wiki or forum, are under whatever license they decide to distribute them with.

    FWIW, a simple google will answer this question. (LMGTFY)

    This article may help as well: https://support.unity3d.com/hc/en-us/articles/211950043-Can-I-use-Unity-assets-in-my-game-
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Monet,

    Sorry, I missed this here... I don't normally lurk in this thread.

    I have successfully downloaded and run Adventure Game as expected from that link. I suspect you are not running the game from the starting or "persistent" scene.

    To find out more about this game's architecture, please complete the learning sessions related to this game. These are also available on the asset store!

    P.S.: Just to be clear, the "persistent" scene is not a "Unity" thing, but something specific to this particular game that was used to solve a specific problem - how to load scenes yet persist some data. To accurately understand why, you'll need to complete the training. Be aware that the "Adventure Game" is intermediate and there are better places to start (eg: Roll-a-Ball and Space Shooter) to get more beginner friendly content.


    If you need attention, please include @Adam buckner for me or @Mike-Geig for Mike.
     
  40. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Thanks for lending a hand!
     
    jonny2027 likes this.
  41. BanjoChris

    BanjoChris

    Joined:
    Feb 5, 2017
    Posts:
    1
    @Adam-Buckner

    Using Unity 5.6. I've worked my way up to the point where I'm testing the player movement. When I click a point the play "teleports" to that point without walking. I've compared my C# code against the code in the tutorial and don't see any differences, I'm pretty comfortable with C#. I've gone back and looked at the Animator "code" and it all appears to match, I am much less comfortable working with the Animator. Any thoughts on other places I might look?

    Thanks
    Chris
     
  42. schlrobe

    schlrobe

    Joined:
    Nov 2, 2015
    Posts:
    1
    Adam,

    I'm busy making my own little online cave exploration adventure game for the BLM in Idaho. I don't want to limit the intended audience to having only one character avatar for this. I've gotten all the systems described in the series written, wired up, and working well together (including modifying it from a click to move to a 1st / 3rd person controller). Now I'm fighting with the character selector. I've sorted out how to load the selected character models from the game resources, but the various scripts for the player always break. Especially the intractable scripts.

    Do you have any suggestions, or can you point me to a solution? Whatever you can do for me will be greatly appreciated!

    Robert.

    P.S. Yes, I have searched through the forums, and Google... I've found nothing that has worked yet...
     
  43. ICE_DragonM

    ICE_DragonM

    Joined:
    Feb 14, 2017
    Posts:
    7
    Hii Adam,

    "when I download and inport the asset from the asset store I get this error:
    Lighting data asset ‘LightingData’ is incompatible with the current Unity version. Please use Generate Lighting to rebuild the lighting data. Realtime Global Illumination cannot be used until the lighting data is rebuilt."

    how can I fix i't?
     
  44. effirmaevei

    effirmaevei

    Joined:
    Jan 30, 2017
    Posts:
    1
    @ICE_DragonM

    The problem on LightingData being incompatible should be solved if you go to Window->Lighting->Settings and press the Generate Lighting.

    This project uses Mixed lighting so... that means there are lightmaps (file containing lighting data).

    ----------On the other hand

    @Adam-Buckner @JamesB

    I followed along Phase1A and the lighting in my scene is different from the one in the live training.

    I suspect you set to static or non-static some stuff. I read the Precomputed GI but things weren't clear enough so I'm not sure why my scene is like 3 times darker than yours even after baking. It was about 5 times darker before baking due to the incompatible lighting.

    I am using the assets that come from the download at the asset store Parte 1/6
    https://www.assetstore.unity3d.com/en/#!/content/76783

    I believe this is because of some info that wasn't included in the video. Because all you did in the training session, I did it to. Static ticking the securityEnviro, Navmesh baking, Colliders, EventSystem, Animator and BlendTree, Player setup...

    Illustrating the problem:

     
  45. mitselen

    mitselen

    Joined:
    May 28, 2017
    Posts:
    1
    On Unity 2017.1.0f3, On phase 3/6 (Inventory), I receive these errors:
    1)
    Assets/Scripts/ScriptableObjects/Interaction/Reactions/DelayedReactions/LostItemReaction.cs(5,10): error CS0246: The type or namespace name `Inventory' could not be found. Are you missing an assembly reference?
    2)
    Assets/Scripts/ScriptableObjects/Interaction/Reactions/DelayedReactions/PickedUpItemReaction.cs(5,10): error CS0246: The type or namespace name `Inventory' could not be found. Are you missing an assembly reference?
    How to fix them?
     
  46. Axiochus

    Axiochus

    Joined:
    Jul 27, 2017
    Posts:
    3
    I've been having a difficult time trying to make it so you can reorder condition collections in the custom inspector. I don't even want to do drag-and-drop; I just wanted to simply put buttons on each ConditionCollection editor that could move them up or down in the array.

    First I added this method to the Assets\Scripts\Editor\Extensions\SerializedPropertyExtensions.cs at the bottom of the class:
    Code (CSharp):
    1. public static int GetIndexFromObjectArray<T> (this SerializedProperty arrayProperty, T elementToGet) where T : Object
    2. {
    3.     if (!arrayProperty.isArray)
    4.         throw new UnityException("SerializedProperty " + arrayProperty.name + " is not an array.");
    5.     if(!elementToGet)
    6.         throw new UnityException("Getting the index of a null element is not supported using this method.");
    7.    
    8.     arrayProperty.serializedObject.Update();
    9.    
    10.     for (int i = 0; i < arrayProperty.arraySize; i++)
    11.     {
    12.         SerializedProperty elementProperty = arrayProperty.GetArrayElementAtIndex(i);
    13.  
    14.         if (elementProperty.objectReferenceValue == elementToGet)
    15.         {
    16.             return i;
    17.         }
    18.     }
    19.    
    20.     return -1;
    21. }
    Then, in Assets\Scripts\Editor\Interaction\Conditions\ConditionCollectionEditor.cs, I added this to OnInspectorGUI() right before the "Remove Collection" button:
    Code (CSharp):
    1. if (GUILayout.Button("^", GUILayout.Width(25f)))
    2. {
    3.     int currentIndex = collectionsProperty.GetIndexFromObjectArray(conditionCollection);
    4.     if(currentIndex > 0)
    5.     {
    6.         collectionsProperty.MoveArrayElement(currentIndex, currentIndex - 1);
    7.     }
    8. }
    I actually made a SerializedPropertyExtensions.cs function for this part as well (to make it a 1-line statement) but wanted to keep the post shorter.

    The problem: It works, but in order to see the changes I have to deselect the object and then reselect it so the inspector redraws all of the editors. I've tried manually calling repaint on the editor and the base script. I've tried making a "isDirty" flag and forcing the editors to be remade. I've tried using Unity's SetDirty, RecordObject, etc. I've also tried doing Updates and ApplyModifiedProperties on the sub-serialized objects. Nothing seems to work EXCEPT for going to "EditorWithSubEditors.cs" and commenting this out
    Code (CSharp):
    1. if (subEditors != null && subEditors.Length == subEditorTargets.Length)
    2.             return;
    But obviously that's a horrible solution because it means we're destroying and recreating all of the subeditors every frame.
    Why do the Add and Remove methods work, while moving elements won't? Do all of the subeditors really need to be recreated just so it'll redraw them?
    I've tried so many things and I just can't seem to get it working. How can I make the inspector redraw everything correctly without having to deselect the object?
     
  47. Axiochus

    Axiochus

    Joined:
    Jul 27, 2017
    Posts:
    3
    I found a way to do it, but it feels so wrong...
    Within the file \Assets\Scripts\Editor\Interaction\InteractableEditor.cs and in the OnInspectorGUI method...

    I changed this:
    Code (CSharp):
    1. for (int i = 0; i < subEditors.Length; i++)
    2. {
    3.     subEditors[i].OnInspectorGUI ();
    4.     EditorGUILayout.Space ();
    5. }
    To this:

    Code (CSharp):
    1. for (int i = 0; i < subEditors.Length; i++)
    2. {
    3.     subEditors[i].OnInspectorGUI ();
    4.     if(GUILayout.Button("^", GUILayout.Width(25f))) {
    5.         collectionsProperty.MoveUpInObjectArray(collectionsProperty.GetArrayElementAtIndex(i).objectReferenceValue);
    6.         serializedObject.ApplyModifiedProperties();
    7.         CleanupEditors();
    8.         return;
    9.     }
    10.     EditorGUILayout.Space ();
    11. }
    And in \Assets\Scripts\Editor\Extensions\SerializedPropertyExtensions.cs, I only needed to add this method:

    Code (CSharp):
    1. public static void MoveUpInObjectArray<T> (this SerializedProperty arrayProperty, T elementToMove) where T : Object
    2. {
    3.     if (!arrayProperty.isArray)
    4.         throw new UnityException("SerializedProperty " + arrayProperty.name + " is not an array.");
    5.  
    6.     if(!elementToMove)
    7.         throw new UnityException("Moving null elements is not supported using this method.");
    8.  
    9.     arrayProperty.serializedObject.Update();
    10.  
    11.     for (int i = 0; i < arrayProperty.arraySize; i++)
    12.     {
    13.         SerializedProperty elementProperty = arrayProperty.GetArrayElementAtIndex(i);
    14.  
    15.         if(elementProperty.objectReferenceValue == elementToMove) {
    16.             if(i > 0) {
    17.                 arrayProperty.MoveArrayElement(i, i - 1);
    18.             }
    19.             return;
    20.         }
    21.     }
    22.  
    23.     throw new UnityException("Element " + elementToMove.name + "was not found in property " + arrayProperty.name);
    24. }
    This is for moving elements up; to also move them down you would make another extension method or simply pass an additional parameter to the "MoveUpInObjectArray" method (you'd rename it to MoveInObjectArray) which would tell it when the up button or down button were pressed and handle it accordingly.

    I'm sure there's a better way to do this...
     
  48. Axiochus

    Axiochus

    Joined:
    Jul 27, 2017
    Posts:
    3
    Here is my final addition on this weird way of doing it, in case anyone wants it.
    This is what my inspector for condition collections within interactables looks now:



    Within the file \Assets\Scripts\Editor\Interaction\InteractableEditor.cs, here is my OnInspectorGUI method:
    Code (CSharp):
    1. public override void OnInspectorGUI() {
    2.     serializedObject.Update();
    3.    
    4.     CheckAndCreateSubEditors(interactable.conditionCollections);
    5.    
    6.     EditorGUILayout.PropertyField(interactionLocationProperty);
    7.  
    8.     for (int i = 0; i < subEditors.Length; i++) {
    9.         subEditors[i].OnInspectorGUI();
    10.  
    11.         EditorGUILayout.BeginHorizontal();
    12.         if(i > 0) {
    13.             if(GUILayout.Button("^", GUILayout.Width(25f))) {
    14.                 collectionsProperty.MoveUpInObjectArray(collectionsProperty.GetArrayElementAtIndex(i).objectReferenceValue);
    15.                 serializedObject.ApplyModifiedProperties();
    16.                 CleanupEditors();
    17.                 return;
    18.             }
    19.         }
    20.         else {
    21.             GUI.enabled = false;
    22.             GUILayout.Button("^", GUILayout.Width(25f));
    23.             GUI.enabled = true;
    24.         }
    25.  
    26.         if(i < subEditors.Length - 1) {
    27.             if(GUILayout.Button("v", GUILayout.Width(25f))) {
    28.                 collectionsProperty.MoveDownInObjectArray(collectionsProperty.GetArrayElementAtIndex(i).objectReferenceValue);
    29.                 serializedObject.ApplyModifiedProperties();
    30.                 CleanupEditors();
    31.                 return;
    32.             }
    33.         }
    34.         else {
    35.             GUI.enabled = false;
    36.             GUILayout.Button("v", GUILayout.Width(25f));
    37.             GUI.enabled = true;
    38.         }
    39.         EditorGUILayout.EndHorizontal();
    40.  
    41.         EditorGUILayout.Space();
    42.     }
    43.  
    44.     EditorGUILayout.BeginHorizontal();
    45.     GUILayout.FlexibleSpace();
    46.     if(GUILayout.Button("Add Collection", GUILayout.Width(collectionButtonWidth))) {
    47.         ConditionCollection newCollection = ConditionCollectionEditor.CreateConditionCollection();
    48.         collectionsProperty.AddToObjectArray(newCollection);
    49.     }
    50.     EditorGUILayout.EndHorizontal();
    51.  
    52.     EditorGUILayout.Space();
    53.  
    54.     EditorGUILayout.PropertyField(defaultReactionCollectionProperty);
    55.  
    56.     serializedObject.ApplyModifiedProperties();
    57. }
    And within \Assets\Scripts\Editor\Extensions\SerializedPropertyExtensions.cs, here are the two methods I added to handle it

    Code (CSharp):
    1. public static void MoveUpInObjectArray<T>(this SerializedProperty arrayProperty, T targetElement) where T : Object {
    2.     if(!arrayProperty.isArray) {
    3.         throw new UnityException(string.Format("SerializedProperty {0} is not an array.", arrayProperty.name));
    4.     }
    5.     if(!targetElement) {
    6.         throw new UnityException("Null elements are not supported using this method.");
    7.     }
    8.  
    9.     arrayProperty.serializedObject.Update();
    10.    
    11.     for(int i = 0; i < arrayProperty.arraySize; i++) {
    12.         SerializedProperty elementProperty = arrayProperty.GetArrayElementAtIndex(i);
    13.         if(elementProperty.objectReferenceValue == targetElement) {
    14.             if(i > 0) {
    15.                 arrayProperty.MoveArrayElement(i, i - 1);
    16.             }
    17.             return;
    18.         }
    19.     }
    20.  
    21.     throw new UnityException(string.Format("Element {0} was not found in property {1}.", targetElement.name, arrayProperty.name));
    22. }
    23.  
    24. public static void MoveDownInObjectArray<T>(this SerializedProperty arrayProperty, T targetElement) where T : Object {
    25.     if(!arrayProperty.isArray) {
    26.         throw new UnityException(string.Format("SerializedProperty {0} is not an array.", arrayProperty.name));
    27.     }
    28.     if(!targetElement) {
    29.         throw new UnityException("Null elements are not supported using this method.");
    30.     }
    31.  
    32.     arrayProperty.serializedObject.Update();
    33.    
    34.     for(int i = 0; i < arrayProperty.arraySize; i++) {
    35.         SerializedProperty elementProperty = arrayProperty.GetArrayElementAtIndex(i);
    36.         if(elementProperty.objectReferenceValue == targetElement) {
    37.             if(i < arrayProperty.arraySize - 1) {
    38.                 arrayProperty.MoveArrayElement(i, i + 1);
    39.             }
    40.             return;
    41.         }
    42.     }
    43.  
    44.     throw new UnityException(string.Format("Element {0} was not found in property {1}.", targetElement.name, arrayProperty.name));
    45. }
    Sorry for the spam. You can delete my other posts if you want.
    Also if there's a cleaner way of doing this please let me know.
     
  49. DrGonzosGame

    DrGonzosGame

    Joined:
    May 1, 2017
    Posts:
    12
    Hi,
    I really enjoyed the tutorial! Great material.

    I have a question regarding the player movement script in phase 1;

    While the overall player movement works very well, I do see some animation snapping from time to time when the player stops moving.
    I guess this has to do with the stopping distance calculation in the script and the subsequent animation blending (or the lack of it) to the idle state.

    Is there a way to simplify the script to omit the transition just before the idle animation is payed, to remove that occasional jerking motion of the player?
    I am still a Unity scripting novice, so the solution is not immediately apparent to me when I look at the script.
    Any help would be appreciated.

    Thanks!
     
  50. DrGonzosGame

    DrGonzosGame

    Joined:
    May 1, 2017
    Posts:
    12
    I can supply a clip of the problem if needed. Although I've seen this on different PCs, so I doubt that it is a hardware issue.

    Or is this thread here just dead..?