public void Move(int InputAxis){
directionInput = InputAxis;
rigidbody.velocity = new Vector2(playerSpeed * directionInput, rigidbody.velocity.y);
}
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
public class CharacterController2 : MonoBehaviour {
public float playerSpeed;
public bool facingRight = true;
public int directionInput;
public int InputAxis;
public Rigidbody2D rigidbody;
bool BoolSpeed;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent ();
rigidbody = GetComponent();
}
// Update is called once per frame
void FixedUpdate () {
if (directionInput > 0 && !facingRight)
Flip ();
else if (directionInput < 0 && facingRight)
Flip ();
}
public void Move(int InputAxis){
directionInput = InputAxis;
rigidbody.velocity = new Vector2(playerSpeed * directionInput, rigidbody.velocity.y);
}
public void Walk(int InputAxis){
anim.SetBool ("BoolSpeed", true);
//Включает анимацию ходьбы
BoolSpeed = true;
}
public void Idle(int InputAxis){
anim.SetBool ("BoolSpeed", false);
//Включает анимацию пакоя
BoolSpeed = false;
}
void Flip() {
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
public class CharacterController2 : MonoBehaviour {
public float playerSpeed;
public bool facingRight = true;
public int directionInput;
public int InputAxis;
public Rigidbody2D rigidbody;
bool BoolSpeed;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
rigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void FixedUpdate () {
if (directionInput != 0) {
Move();
}
if (directionInput > 0 && !facingRight)
Flip ();
else if (directionInput < 0 && facingRight)
Flip ();
}
public void Move(int InputAxis){
directionInput = InputAxis;
rigidbody.velocity = new Vector2(playerSpeed * directionInput, rigidbody.velocity.y);
}
public void Walk(int InputAxis){
anim.SetBool ("BoolSpeed", true);
//Включает анимацию ходьбы
BoolSpeed = true;
}
public void Idle(int InputAxis){
anim.SetBool ("BoolSpeed", false);
//Включает анимацию пакоя
BoolSpeed = false;
}
void Flip() {
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}