Hi Chris, I've finally upgraded to 1.60.5, but I've got a little issue.
If I click on a hotspot while being in 'Free' walk/run mode, and then switch to 'Always run', the player character starts running toward the hotspot and interacts with it after reaching it. That's great.
But if I do it the opposite way ('Always run' to 'Free') I have the same behavior as before: the character stops on its path and the Use or Examine action runs as if he already reached the marker.
Could you modify also that action so it behaves the same, please?
Oh well... problem is I don't manage to get my head around those Unity Input thingies... It's one of those topics that even reading and reading about it, I just can't. So that's why I'm using PlayMaker Key Down actions...
But if that is the way it is, then I'll make an effort. Thanks. :-)
So I'm adding full point & click navigation to my game and am about finished. I decided the last thing I wanted to do was get the run toggle to work. Followed the steps in this thread and got it working with the exception of the issue that Anaxtasia had where my movement is interrupted when hitting the "Free" movement type.
Using Active Inputs. I'm not on the current version of AC because I don't want to introduce anything else into my game as it's already out in the wild.
Here's the main Active Input actionlist:
I'm also doing a check on scene load to make sure it keeps the toggle value from scene to scene:
Everything is triggering properly and saving it's state when moving from scene to scene. It's just that the movement gets interrupted when "Free" is hit. It works fine if I set it to "Always Walk" but then, as you are aware, that makes me lose the double-click to run functionality and I want to give the player both options.
When I press the toggle button while running, it will trigger the "free" constrain and the player will stop moving. I would expect the player to keep progressing on their way but just transition back to walk.
Unfortunately no. Now it seems to wait until I've reached my click point to actually toggle back to walk. It'll still toggle to run in the middle of my path but if I click it back to return to walking, the player continues to run until it reaches the click point and then the next time I click, the player is walking.
The issue is more to do with the fact that you want to force the Player to walk, despite the "Free" option allowing him to do both. Best to rely on a custom Action for this - and it also means you can do without the need for a Global Variable:
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace AC
{
[System.Serializable]
public class ActionTogglePlayerRun : Action
{
public ActionTogglePlayerRun ()
{
this.isDisplayed = true;
category = ActionCategory.Player;
title = "Toggle running";
}
public override float Run ()
{
if (KickStarter.player == null)
{
LogWarning ("No Player found!");
return 0f;
}
if (KickStarter.player.runningLocked == PlayerMoveLock.AlwaysRun)
{
KickStarter.player.runningLocked = PlayerMoveLock.Free;
if (KickStarter.player.IsPathfinding ())
{
KickStarter.player.GetPath ().pathSpeed = PathSpeed.Walk;
KickStarter.player.isRunning = false;
}
}
else
{
KickStarter.player.runningLocked = PlayerMoveLock.AlwaysRun;
if (KickStarter.player.IsPathfinding ())
{
KickStarter.player.GetPath ().pathSpeed = PathSpeed.Run;
KickStarter.player.isRunning = true;
}
}
return 0f;
}
#if UNITY_EDITOR
public override void ShowGUI ()
{
AfterRunningOption ();
}
#endif
}
}
Very cool!
I am getting some compiler errors with this action, though:
Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(36,5): error CS0103: The name `LogWarning' does not exist in the current context
Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(40,27): error CS1061: Type AC.Player' does not contain a definition forrunningLocked' and no extension method runningLocked' of typeAC.Player' could be found. Are you missing an assembly reference?
Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(42,24): error CS1061: Type AC.Player' does not contain a definition forrunningLocked' and no extension method runningLocked' of typeAC.Player' could be found. Are you missing an assembly reference?
Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(52,24): error CS1061: Type AC.Player' does not contain a definition forrunningLocked' and no extension method runningLocked' of typeAC.Player' could be found. Are you missing an assembly reference?
I did get one last compiler error:
Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(35,5): error CS0103: The name `Debug' does not exist in the current context
I commented it out and I'm able to at least get it to run, although not sure if that's the best course of action. Functionality works great, though! Thanks man!
Comments
Try using Active Inputs if you're not already, and if you still have an issue, post the ActionLists involved so we can see what's missing.
THREAD NECROMANCY!
So I'm adding full point & click navigation to my game and am about finished. I decided the last thing I wanted to do was get the run toggle to work. Followed the steps in this thread and got it working with the exception of the issue that Anaxtasia had where my movement is interrupted when hitting the "Free" movement type.
Using Active Inputs. I'm not on the current version of AC because I don't want to introduce anything else into my game as it's already out in the wild.
Here's the main Active Input actionlist:
I'm also doing a check on scene load to make sure it keeps the toggle value from scene to scene:
Everything is triggering properly and saving it's state when moving from scene to scene. It's just that the movement gets interrupted when "Free" is hit. It works fine if I set it to "Always Walk" but then, as you are aware, that makes me lose the double-click to run functionality and I want to give the player both options.
Any tips?
I should point out that I'm on AC v1.65.1
I'm not clear on what you mean by this. What's the exact behaviour you're getting?
When I press the toggle button while running, it will trigger the "free" constrain and the player will stop moving. I would expect the player to keep progressing on their way but just transition back to walk.
This is caused by the instance of:
on line 160 of ActionPlayerLock.cs. Does commenting out give you the behaviour you're looking for?
Unfortunately no. Now it seems to wait until I've reached my click point to actually toggle back to walk. It'll still toggle to run in the middle of my path but if I click it back to return to walking, the player continues to run until it reaches the click point and then the next time I click, the player is walking.
All right - I'll attempt a recreation.
Thanks Chris!
The issue is more to do with the fact that you want to force the Player to walk, despite the "Free" option allowing him to do both. Best to rely on a custom Action for this - and it also means you can do without the need for a Global Variable:
Very cool!
I am getting some compiler errors with this action, though:
AC.Player' does not contain a definition for
runningLocked' and no extension methodrunningLocked' of type
AC.Player' could be found. Are you missing an assembly reference?AC.Player' does not contain a definition for
runningLocked' and no extension methodrunningLocked' of type
AC.Player' could be found. Are you missing an assembly reference?AC.Player' does not contain a definition for
runningLocked' and no extension methodrunningLocked' of type
AC.Player' could be found. Are you missing an assembly reference?Right - forgot you're using an older release.
Try this instead:
Chris = Legend.
I did get one last compiler error:
Assets/AdventureCreator/Scripts/Actions/ActionTogglePlayerRun.cs(35,5): error CS0103: The name `Debug' does not exist in the current context
I commented it out and I'm able to at least get it to run, although not sure if that's the best course of action. Functionality works great, though! Thanks man!
No harm.
Ace. Thanks again. You rule.