© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•14mo ago•
5 replies
moonbat

Is there a way to make this a shorter phrase.

I was wondering if i was able to put both input under the same name.
something like
if(cheeseburger){jump}
if(cheeseburger){jump}
, rather than this
using System.Linq.Expressions;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class Playerjump : MonoBehaviour
{
    [SerializeField] private float _velocity = 1.5f;
    private Rigidbody2D _rb;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        _rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Mouse.current.leftButton.wasPressedThisFrame)
        {
            _rb.linearVelocity = Vector2.up * _velocity;
        }

        if (Keyboard.current.spaceKey.wasPressedThisFrame)
        {
            _rb.linearVelocity = Vector2.up * _velocity;
        }
    }
}
using System.Linq.Expressions;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class Playerjump : MonoBehaviour
{
    [SerializeField] private float _velocity = 1.5f;
    private Rigidbody2D _rb;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        _rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Mouse.current.leftButton.wasPressedThisFrame)
        {
            _rb.linearVelocity = Vector2.up * _velocity;
        }

        if (Keyboard.current.spaceKey.wasPressedThisFrame)
        {
            _rb.linearVelocity = Vector2.up * _velocity;
        }
    }
}
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

❔ Is there a way to make this neater?
C#CC# / help
3y ago
is there is a way to make this faster
C#CC# / help
3y ago
❔ Is there a way to make this more cleaner?
C#CC# / help
3y ago
Is there a better way to do this
C#CC# / help
3y ago