Hi all,
I tryied to follow the manual and the Variable Linking Example but I cannot understand how to convert the sprite direction string from a custom script to a global variable in AC.
My script:
public string currentDir;
void Update()
{
string currentDir = AC.KickStarter.player.GetSpriteDirection();
I have a Global Variable set as String with ID token 32... how can I make it change relying on currentDir?
Thanks for any help.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Are you trying to transfer the sprite direction to the variable, or use the variable to control the direction?
If you're just trying to update the variable, you can do so without "linking" and just add the following to your Update function:
Yep, just trying to update the variable.
But...
The AC string var 32 is still on "_R" and the integer 33 is still on "2", while "hello" on the console is writing hello a lot of times... so the script is working but is not refreshing the var value.
Am I missing something? It is checking the main player movement, right?
SCRIPT ActionCheckDirection.cs:
public class ActionCheckDirection : MonoBehaviour
{
AC.GlobalVariables.SetStringValue(32, AC.KickStarter.player.GetSpriteDirection());
AC.GlobalVariables.SetIntegerValue(33, AC.KickStarter.player.GetSpriteDirectionInt());
Debug.Log("hello");
}
}
Thanks
Should be - alter your Debug.Log statement to check:
Make sure that you revert your variable's Link to property back to None.
Variable already reverted to None.
With the Debug.Log as you wrote, I still have _R forever on the console, even if I press the down button (I have the Direct method).
And my Player is tagged as Player... maybe the "Allow player switching" can cause this issue?
Does the character visibly change direction?
The Player's tag isn't relevant in the latest release, but you can determine which character is actually being read with:
Clicking that message in the Console will "ping" the Player in the Hierarchy.
Ok, I have identified the issue and solved it, thanks!
But there's a way to write on the string all the current movement?
Like "Walk_R" and not only "_R"? Because I need to know if it's running or walking.
Many THANKS! It works perfect!