© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
4 replies
n305

what is wrong with this code?

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

public class UkkelinLiike : MonoBehaviour
{

    public float moveSpeed;

    public Rigidbody2D rb;

    private Vector2 moveDirection;
    
    // Update is called once per frame
    void Update()
    {
        ProcessInputs();
    }
    void FixedUpdate()
    {
        Move();
    }
    
    void ProcessInputs()
    {
        float moveX = Input().GetAxisRaw("Horizontal");
        float moveY = Input().GetAxisRaw("Vertical");

        moveDirection = new Vector2(moveX, moveY).normalized;
    }

    void Move()
    {
        rb.velocity = new Vector2(moveDirection.x * moveSpeed, moveDirection.y * moveSpeed);
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UkkelinLiike : MonoBehaviour
{

    public float moveSpeed;

    public Rigidbody2D rb;

    private Vector2 moveDirection;
    
    // Update is called once per frame
    void Update()
    {
        ProcessInputs();
    }
    void FixedUpdate()
    {
        Move();
    }
    
    void ProcessInputs()
    {
        float moveX = Input().GetAxisRaw("Horizontal");
        float moveY = Input().GetAxisRaw("Vertical");

        moveDirection = new Vector2(moveX, moveY).normalized;
    }

    void Move()
    {
        rb.velocity = new Vector2(moveDirection.x * moveSpeed, moveDirection.y * moveSpeed);
    }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ What is wrong with this code???
C#CC# / help
17mo ago
what is wrong with this code
C#CC# / help
2y ago
what is wrong with this?
C#CC# / help
4w ago