I've looked thoroughly and I am almost certain that I cannot do this from an Action List currently, What I'm requesting is to addon these actions:
Player walkSpeedScale Var
Player runSpeedScale Var
Player InstantVelocity/MovementSpeed Var (I'm not sure if this one exists now, but basically I want to change the players movement from 10 to 2 immediately as if some super brakes kicked in
To be able to change from an action, that way I can call upon my desired action at anytime whether I want to restore the speed to a default factor or change it to something else.
Thanks
Comments
"Parameter name" refers to the Mecanim variable that AC will update with the character's speed. This is useful if you want to play a different walk animation, for example.
Luckily, this is only a visibility issue. I'll have a fix in 1.38, but in the meantime you can simply change your Input method to Mouse And Keyboard, check the option, then change back to Touch Screen. The option won't be visible, but it'll still be checked.
{
[System.Serializable]
public class ActionCharChangeSpeed : Action
{
public int parameterID = -1;
public int constantID = 0;
public bool isPlayer;
public Char animChar;
public float speed;
public ActionCharChangeSpeed()
{
this.isDisplayed = true;
category = ActionCategory.Character;
title = "Change Speed";
description = "Change the Walk Speed of the character.";
}
override public void AssignValues (List parameters)
{
animChar = AssignFile(parameters, parameterID, constantID, animChar);
speed = AssignFloat(parameters, parameterID, speed);
if (isPlayer) {
animChar = KickStarter.player;
}
}
override public float Run ()
{
if(animChar) {
if (isPlayer) {
animChar.GetComponent().walkSpeedScale = speed;
} else {
animChar.walkSpeedScale = speed;
}
}
return 0f;
}
#if UNITY_EDITOR
override public void ShowGUI (List parameters)
{
isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
if (isPlayer) {
if (Application.isPlaying) {
animChar = KickStarter.player;
}
else if (AdvGame.GetReferences().settingsManager) {
animChar = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
}
}
else {
parameterID = Action.ChooseParameterGUI("Character:", parameters, parameterID, ParameterType.GameObject);
if (parameterID >= 0) {
constantID = 0;
animChar = null;
}
else {
animChar = (Char)EditorGUILayout.ObjectField("Character:", animChar, typeof(Char), true);
constantID = FieldToID(animChar, constantID);
animChar = IDToField(animChar, constantID, true);
}
}
speed = EditorGUILayout.FloatField("Speed for Walk:", speed);
AfterRunningOption ();
}
#endif
}
}