Hi All,
My game involves two main characters that the player switches between: a human and a cat. Some of the hotspots only make sense for one of my characters to be interacting with, and I was wondering if anyone knows of a way to have certain hotspots only enabled for certain player-characters. I know that I can have the interaction check for who the active player is and could differentiate the outcome that way, but this wouldn't affect the cursor changing when hovering over the hotspot.
Thanks so much,
Adam
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The OnSetPlayer custom event is triggered when you switch Player character - you can use this to determine if a given Hotspot should be turned on or off as a result:
Hi Chris,
Thank you so much for your help with this! I duplicated and pasted over a previous custom action you helped me with, but I am now getting this error message:
-> AC debug logger
UnityEngine.Debug:LogError (object,UnityEngine.Object)
AC.ACDebug:LogError (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:46)
AC.AdventureCreator:AddActionsFromFolder (AC.ActionsManager,string,System.Collections.Generic.List`1<AC.ActionType>) (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:589)
AC.AdventureCreator:RefreshActions () (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:522)
AC.ActionListEditorWindow:OnEnable () (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:145)
UnityEditor.WindowLayout:LoadDefaultWindowPreferences () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/WindowLayout.cs:84)
I am also wondering if I should be attaching the script to a given hotspot that I want to toggle on and off. I am still new to custom actions and scripting but wanting to improve so thanks again.
It's not a custom Action - it's a component script that needs to be attached to the Hotspot itself.
See the " : MonoBehaviour" at the top - this means that the script derives from Unity's MonoBehaviour class, which is the base class for components.
Any custom Actions folder you list in the Actions Manager needs to only contain Action scripts - you'll need to move this script out of the folder, and also rename the file to match the class name, PlayerSpecificHotspot.
You should then be able to drop it onto your Hotspot, and then assign both the Hotspot, and the ID number of the Player it should show for, in its Inspector.
Thanks Chris. Sorry but I'm running into one more problem, when I attach the component script to a hotspot to test, it turned off the hotspot for both characters. I wasn't sure when was mean by Player ID number, but I just added a Constant ID component to the player character (tried on both the highest and second highest game object), and set that as the "Enable for Player ID" but it hasn't worked yet. I'm guessing there's something about the ID that I'm not understanding.
Remove the Constant ID components - when using multiple Player characters, AC handles their save-states automatically.
The ID number of the Player is the number to the left of their entry in the Settings Manager - typically 0 for the first, 1 for the second, etc.
To debug the behaviour of the script, insert the following above the "if (playerID == enableForPlayerID)" line:
If it misbehaves when the ID is correct, what does the Console output?
This worked! Thanks so much for the help