Hi
I'm trying to move the player via a scripted actionlist. However the player turns to face the object, but doesn't move to the marker specified, doesn't move at all, other than turning to face it. The player does move if I use an actual action list, via the GUI node editor. Same action, same marker, same settings.
My script has this in it;
ActionList actionList = GetComponent<ActionList>();
if (actionList == null)
{
actionList = gameObject.AddComponent<ActionList>();
}
actionList.actions = new List<Action>
{
ActionCharPathFind.CreateNew(KickStarter.player,hotspot.walkToMarker,PathSpeed.Walk,true,true,true),
//ActionCharAnim.CreateNew_Mecanim_ChangeParameterValue(KickStarter.player,"Mining",true),
//ActionPause.CreateNew(3),
//ActionEvent.CreateNew(spawnEvent),
//ActionEvent.CreateNew(removeEvent),
//ActionCharAnim.CreateNew_Mecanim_ChangeParameterValue(KickStarter.player,"Mining",false),
};
//KickStarter.stateHandler.EnforceCutsceneMode = true;
actionList.Interact();
All the other commented out lines in that actionlist, if uncommented, work fine. It's just the ActionCharPathFind action that doesn't work as expected. The walkToMarker of the hotspot is set with a valid marker, and the same marker works in the GUI version of the same command.
Any ideas why?
Unity 6 6000.0.34f1
AC 1.82.5
Olly
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Is the ActionList itself set to "Run in background"? Depending on your settings, AC may not be able to control the Player outside of cutscenes.
I have tried setting the game state to cut scene via code prior to defining and running the action list, but that didn't work either. Neither did moving the player via code via setting a direction for the navmesh agent on it. However everything works via the gui in an action list.
If the Player doesn't move when the ActionPause is added, though, then it'll be down to something else.
Do any Console warnings appear, and does the Player's "blue movement line" appear when selecting them in the Scene window?
Thanks Chris. That didn't solve the problem I'm afraid.
There's no blue line. At least, if there is, it must come and go quicker than I can see it. However the player does turn to the hotspot, and the only thing that I have in that code block that does that is the pathfind action.
There's nothing in the console and I have the AC settings set to Show Logs always.
Thanks Chris. I think I found the issue, though it's raised others.
In order for the Button parameter, that is passed by the OnHotspotInteract event, to have a non-null figure, I had to create a new Use Interaction on that hotspot. The values in the Use Interaction are ignored as I'm coding a response, but without that, the Button value is blank.
That Use Interaction had "Player Stop Moving?" set to true. This overwrote the anything I put in the OnHotSpotInteraction event, even when creating a new actionlist. Unticking that box made the newly coded ActionList work as expected.
Sorry, I don't think I'm following too well. If there's still an issue, can you share screenshots?
Ok. The box in this image was the issue. Unticking it caused my coded actionlist to move the player. This is down to my understanding of the workflow, that is I assumed that my coded actionlist would overwrite the settings on the Interaction entry on the Hotspot.
https://drive.google.com/file/d/1oj7i6UrJh6ozHQ8JtcRuWSar3mcUdMif/view?usp=sharing
That being said, I've found that I have to have an interaction in the Hotspot, even if I don't actually use it. Otherwise the Button reference passed by the OnHotspotInteract event is null. Which doesn't feel right. Not sure though.
https://drive.google.com/file/d/1lxWzjIPKnGHudhuze0dCbHV9WT1T0uwJ/view?usp=sharing
If you know why that might be, that would be great, but don't worry too much. I'm not articulating this well and context is everything.
There's potentially more to it based on other settings, but the Interaction in your screenshot is for "Use" mode, rather than "Inventory". If you're using an Item on the Hotspot at this time, it'll be the Inventory interaction - or Unhandled, if none found - that gets run.
If you want to get the selected item without reading the Button's invID property, you can use: