In the Hierarchy i have two ThirdPersonController The script is attached to each one of them
Then i went to the ThirdPersonController script and changed the speed variable to be public:
[SerializeField] public float m_MoveSpeedMultiplier = 1f;
Then in my script top i did:
public float walkSpeed = 10f;
private ThirdPersonCharacter[] thirdPersonCharacter;
Then in the Awake
void Awake()
{
thirdPersonCharacter = new ThirdPersonCharacter[2];
for(int i = 0; i < thirdPersonCharacter.Length; i++)
{
thirdPersonCharacter[i] = GetComponent<ThirdPersonCharacter>();
}
}
Then in the Update
void Update()
{
thirdPersonCharacter[0].m_MoveSpeedMultiplier = walkSpeed;
thirdPersonCharacter[1].m_MoveSpeedMultiplier = walkSpeed;
}
But when the game is running and i'm changing in one of the ThirdPersonController in the Inspector in the script the walkSpeed value from 10 to 1 or from 10 to 20 it's effecting only one of the characters. Why it's not effecting both of them ?
Since it didn't work i tried:
public ThirdPersonCharacter[] thirdPersonCharacter;
Then in the Start function removed the code before. And just dragged the ThirdPersonController and the ThirdPersoncontroller(1) to the Inspector in the script after changed the size of thirdPersonCharacter to 2. The script now is attached only to the ThirdPersonController.
And still when changing the speed value while the is running it's effecting only one of them only the ThirdPersonController.
My general goal is to be able to controll both ThirdPersonController and ThirdPersonController(1) same speed in real time while the game is running and then also to be able to controll each one speed in seperate. So i will have later 3 values of speed. One for both and two for each one. But i can't yet make them both speed to be changed.