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, rather than this
something like
if(cheeseburger){jump}if(cheeseburger){jump}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;
}
}
}