Hello everyone.
Ill cut to the chase.
So, I was wondering what was the best practice when using GUI.
I want to move a player using a button.
But when Im testing it on my device I get small glitches…So I came to you guys and tell me what would be the ideal way of doing this?
Should the function be called from within the button? or Keep it as Im doing(update function)?
Also when Im calling for Animations, where should be better? When Moving? or When Pressing the button?(inside the move function or once the button is pressed.
Thank you for your time and help!
////EDIT
Here’s the scripts:
GUI:
void OnGUI(){
_downButton = DownButtonClicked();
}
private bool DownButtonClicked(){
return GUI.RepeatButton(DownArrowRect,"", "Dpad_ArrowD");
}
update(){
CheckDownButtonClicked();
}
void CheckDownButtonClicked(){
if (_downButton){
_animManager.SetDirection(2);
_animManager.SetMoving(true);
_playerController.MoveDown ();
}
Now, here’s the tricky part.
The PlayerObject has 3 attached gameObjects with their individual animations.(simulating clothes).
The idea is that:
A)The animations of the 4 gameObjects(player + clothes) don’t unsync when clicking multiple times the repeat button.(which they do on my mobile device…)
Heres _animManager:
public void SetMoving(bool isMoving){
//This one sets the body animation.
_anim.SetBool("isMoving",isMoving);
//This one sets the shirt animation.
if(_shirtController != null)
_shirtController.SetMoving(isMoving);
///You get the picture.
if(_legsController != null)
_legsController.SetMoving(isMoving);
if(_hairController != null)
_hairController.SetMoving(isMoving);
}
So my question is, am I doing this the proper way?
Thanks again.