Simple Acceleration Based Movement in Unity

I am new to Unity and wanted to create a simple acceleration-based movement system that mimics an ice skater’s movement on an ice rink where the player uses keyboard input to change the direction of their movement and accelerate. But for some reason, this code doesn’t work even though the idea was very basic.

using System;
using UnityEngine;

public class Movement : MonoBehaviour
{
    private float _mouseSensitivity = 3f;
    private float velocity = 0;
    private double vangle = 0; //velocity vector angle
    private float fangle = 0; //angle player is facing
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }
    Vector2 Avector(float angle) { //generate a vector2 with magnitude 1 pointing in the angle direction
        float rad = (float)Math.PI/180;
        Vector2 v = new Vector2((float)Math.Sin(angle*rad),(float)Math.Cos(angle*rad));
        return v;
    }
    // Update is called once per frame
    void Update()
    {   
        float rad = (float)Math.PI/180;
        float timeDelta = Time.deltaTime;
        //decceleration by 1/sec
        if (velocity < timeDelta) {
            velocity = 0;
        } else {
            velocity -= timeDelta;
        }
        float z = 0;
        float x = 0;
        //keyboard input
        if (Input.GetKey(KeyCode.W)) z += 1f;
        if (Input.GetKey(KeyCode.S)) z -= 1f;
        if (Input.GetKey(KeyCode.D)) x += 1f;
        if (Input.GetKey(KeyCode.A)) x -= 1f;
        Vector2 v = new Vector2(velocity*(float)Math.Sin(vangle*rad),velocity*(float)Math.Cos(vangle*rad));
        Vector2 v1 = 4*z*Avector(fangle);//accelerate by 4/s^2
        Vector2 v0 = 4*x*Avector(fangle+90);
        v+=(v1+v0)*timeDelta;//update velocity vector
        velocity = v.magnitude;
        vangle = Math.Atan2(v.y,v.x)*180/Math.PI;
        if (velocity > 8) { //cap velocity at 8
            float scale = 8f/velocity;
            v.x*=scale;
            v.y*=scale;
            velocity = 8f;
        }
        Vector3 move = new Vector3(v.x, 0, v.y);
        transform.position+=move*timeDelta; //move player
        float mouseX = Input.GetAxis("Mouse X") * _mouseSensitivity;
        fangle += mouseX;
        transform.localEulerAngles+=new Vector3(0,mouseX,0);
    }
}

The problem arises when I try to move, it seems that the velocity vector isn’t updating as it should and the direction associated with each key does not align with the local coordinate axis. This might be a consequence of the main problem, but the directional change of the velocity vector also isn’t smooth, the change in direction only happens once the velocity nears 0. I don’t know if this is a problem on my part or just a bug in the way movement works in unity.

The vangle and fangle are both relative to the forward direction (Y axis), so when calculating the angle with atan, the parameters should be swapped:

Math.Atan2(v.x,v.y)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật