using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.VisualScripting;
using UnityEngine;
public class CharacterCtrl : MonoBehaviour
{
public int Speed;
public int JumpForce;
public GameObject Character;
public GameObject Coin;
public Rigidbody2D rb2D;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
{
rb2D.velocity = Vector2.left * Speed;
}
if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow) | Input.GetKeyDown(KeyCode.RightArrow))
{
rb2D.velocity = Vector2.right * Speed;
}
if (Input.GetKeyDown(KeyCode.Space))
{
rb2D.velocity = Vector2.up * JumpForce;
}
void OnCollisionEnter2D(Collision collision)
{
Debug.Log("d")
}
}
}
Here’s my full code for context