Write code to control the character on android, it works. But poser (
1 at the clamping button (gui imagine) operates only as a click and whatever character was going on, you need to click again. How to make or modify a script that would be when clamping keys, he walked up to the point is I did not let go?
2-character animation. When a character is played animation idle (because the variable “Speed” in the animator is to “0.0”). As soon as it begins to move the animation changes to the walk (as the variable “Speed” in the animator moves to “1.0”), but as soon as the button is no longer valid, ie, we let go of it (but so far she is released), the variable does not change. It was 1.0 and remained, but sometimes a couple of seconds back to 0.0. Help what to do?
Here’s a script.
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
public class CharacterController2 : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent ();
}
// Update is called once per frame
void FixedUpdate () {
}
public void Walk(int InputAxis)
{
float move = Input.GetAxisRaw (“Horizontal”);
move = InputAxis;
anim.SetFloat (“Speed”, Mathf.Abs (move));
GetComponent().velocity = new Vector2 (move * maxSpeed, GetComponent().velocity.y);
if (move > 0 && !facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}
void Flip() {
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}