Hey,
I’m making a top down mobile game and was wondering if is was possible to let the character face the direction it is walking in. The camera will remain at the same position, it is a child object of the character so it will follow him along. I have animation attached.
I’m using virtual controls suite as the joystick and then transform the character to walk in the direction the joystick is pointing.
Here is my code so far (not that big :D)
public GameObject player;
public float moveSpeed = 5.0f;
void Update () {
VCAnalogJoystickBase joy = VCAnalogJoystickBase.GetInstance("stick");
//move the player character according to the joystick, arguments of translate are x,y,z
if (joy != null){
player.transform.Translate(moveSpeed * Time.deltaTime * joy.AxisX, 0.0f, moveSpeed * Time.deltaTime * joy.AxisY);
}
//play the animations
if (joy.AxisX == 0.0f && joy.AxisY == 0.0f){
animation.CrossFade("Run");
animation.Play("Idle");
}
else{
animation.CrossFade("idle");
animation.Play("Run");
animation["Run"].speed = 15.0f;
}
}
}
I've tried a little coding, and maybe i'm dumb or something but since i'm fairly new I don't seem to get it. Can you explain in more detail? Thanks in advance
– GijsP