Ā© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
43 replies
Luna šŸŒ™

2D Movement

I am trying to make a code that moves left and right for unity in a 2D project, but there is a weird error occuring. Can someone help?

using UnityEngine;

public class Movement : MonoBehaviour
{
public float moveSpeed = 3f;
public float jumpHeight;
private KeyCode lastHitKey;

void Start()
{
}

void Update()
{
if(Input.GetKeyDown (KeyCode.D))
{
if(lastHitKey ==KeyCode.D)
{
movement.x = (transform.rightTime.deltaTime-moveSpeed).x;
}
}
if(Input.GetKeyDown (KeyCode.A))
{
if(lastHitKey ==KeyCode.A)
{
movement.x = (transform.rightTime.deltaTimemoveSpeed).x;
}
}
}
}
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

ā” 2D player movement
C#CC# / help
3y ago
ā” 2D top down movement issue
C#CC# / help
3y ago
ā” 2D Dictionary
C#CC# / help
3y ago
easy movement
C#CC# / help
4y ago