0
Hallo Ich habe ein Problem in der Einheit 5, bewegt sich mein Charakter überhaupt nicht. Wenn ich rechts oder "D" drücke, startet mein Charakter die laufende Animation. Kann jemand meinen Code ansehen, um zu sehen, was falsch ist? Vielen Dank!Mein 2D-Zeichen bewegt sich nicht
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
Nein meine maxSpeed ist nicht 0. – Tom
Es tut mir leid, dass ich nicht schnell reagieren konnte Ich war für ein paar Tage weg – Tom
Aber ich denke nicht, dass der fehlende Avatar das Problem ist, weil es die Animationen richtig spielt Es bewegt sich einfach nicht über den Bildschirm. – Tom