- Home /
How to controlling an object using built-in button?
need help guys...
i already create a character that can move and jump by following some unity tutorial... but how to change the control button from keyboard (like up, down, left, & right) to built-in button?
it's really confusing, do i need to pass the value from script on the button to the script on the character? or what should i do exactly to be able controlling the character with built-in button?
this is the script for moving my character, i simply follow this tutorial to do that
void FixedUpdate () {
move = Input.GetAxis ("Horizontal");
grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
anim.SetBool ("Ground", grounded);
anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);
if (grounded)
loncat = false;
anim.SetFloat ("Speed", Mathf.Abs(move));
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
if (move > 0 && !facingRight) {
flip();
}
else if(move < 0 && facingRight){
flip();
}
}
and Thanks before for anybody that willing to help me...
sorry, if its confusing... i mean, i want to create button inside my scene, so ins$$anonymous$$d of using the keyboard button, its use the button i create to control the object inside... but i dont find anything helpfull in the internet...
@robertbu, i've edit my question, there's my script to moving the character to left and right...