0
こんにちは私はユニティ5で問題があります、私のキャラクターは全く動かない。私が右または "D"を押すと、私のキャラクターは動いているアニメーションを開始します。誰かが私のコードを見て、何が間違っているのか見てみましょうか?ありがとう!私の2Dキャラクターは動かない
using UnityEngine;
using System.Collections;
public class CharacterControllerScript : MonoBehaviour
{
public float maxSpeed = 100f;
bool facingRight = true;
public Rigidbody2D rb;
Animator anim;
// Use this for initialization
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void FixedUpdate()
{
float move = Input.GetAxis ("Horizontal");
anim.SetFloat("Speed", Mathf.Abs(move));
rb.velocity = new Vector2(move * maxSpeed, rb.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;
}
}
Here is an image with the character selected
いいえ私のmaxSpeedは0ではありません。 – Tom
私は素早く反応できなかったことを申し訳なく思っています。私は数日離れていました。 – Tom
アニメーションが正しく再生されるので、欠けているアバターは問題ではないと思いますそれは画面上を移動しません。 – Tom