@KuzyaFs

Не изменяется скорость передвижения (не в inspector(-е), не в коде) что делать?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerContorller : MonoBehaviour
{
    public float speed;
    public Animator animator;
    private Rigidbody2D rb;
    private Vector2 direction;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    void FixedUpdate()
    {
        direction.x = Input.GetAxisRaw("Horizontal");
        direction.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", direction.x);
        animator.SetFloat("Vertical", direction.y);
        animator.SetFloat("Speed", direction.sqrMagnitude);

        rb.velocity = new Vector2(direction.x, direction.y);
    }
}
  • Вопрос задан
  • 58 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Ente
Unity developer
Direction умножьте на speed
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы