Handling Movement - Animations

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!

Here’s the scripts:


void OnGUI(){
_downButton = DownButtonClicked();

private bool DownButtonClicked(){

		return GUI.RepeatButton(DownArrowRect,"", "Dpad_ArrowD");



void CheckDownButtonClicked(){
if (_downButton){
			_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.
             //This one sets the shirt animation.
		if(_shirtController != null)
		///You get the picture.
		if(_legsController != null)

		if(_hairController != null)


So my question is, am I doing this the proper way?

Thanks again.

OK I see what it is, unfortunately I’m working in 3D animations not 2D but that said animation is animation.

How does the 2D sprite animation system handle things does it set frame 1 then frame 2 and so on?

I think you could maybe, and this is just speculation as I haven’t done any work in 2D sprite animation, do this.

Leave your _shirtController _legsController etc. to handle what your character currently looks like, then have a _playerMovementController script the runs the animations for all items in the character. That way all the animations are called together.

Or if you can reference individual frames in the 2D sprite setup then make sure all animations are on the same frame.


Sorry for the extra work for no benefit, and sorry for the delay (was night time where I am).

OK I don’t know how the 2D animation system works but is this a workable solution…

You call the animation to show the sprite of the feet/legs of the body even though the trousers and shoes completely cover the legs and feet. Is it a workable solution to simply stop the lower animation if the higher animation covers it?

Or a better way would be to make the animation so it only has to call one frame for that body part. For one thing it would save a whole heap of animations from being called. For example if the body part == legs and wearing trousers then only display the trousers not bare legs as well. If wearing shorts combine the sprite for each frame of animation with the legs so you just get one image.

Depends on how you have the game setup. If you have to keep the current method how are your layers setup, is the body set to be further back?