#🖱️┃input-system

1 messages · Page 32 of 1

quasi chasm
#

any help with this please?

austere grotto
#

Use the event system for all your touch interactions instead of handling them manually like this and you'll get this behavior for free

quasi chasm
austere grotto
#

And all of those things could be handled with the pointer and drag events

quasi chasm
#

Also, how's multitouch handled in this solution?

austere grotto
#

is multitouch a requirement?

quasi chasm
#

Like pinch or something. Would I be able to detect it?

#

I mean it'd be nice to be able to add it someday

#

And not lock myself out architecturally

austere grotto
#

it can be done this way, but multitouch is best handled with the enhanced touch API. It definitely complicates things.

quasi chasm
#

Either via input system, or via touch api

austere grotto
quasi chasm
#

Is there a convenient way to detect if a touch clicked on some ui element? Take a screen position and do a IsRaycastableUIAtThisPosition

austere grotto
#

Or what if one finger is on UI and one not

austere grotto
#

the cheapo way is EventSystem.IsPointerOverGameObject but that's not going to cover your multitouch use cases well either

austere grotto
#

yeah that cheapo way also doesn't work if you use the event system for anything other than UI

quasi chasm
#

Where can I read more about this? I always did just normal raycasts

#

How do I do a ui-specific raycast

quasi chasm
#

Thanks

#

Hopefully doing it a few times a frame is fine

minor pasture
#

Hello. I am development a game for mobile, but when I play in Play mode in Unity, the game runs good. But when I make the build for android. The game goes slowly and the movements are not the same that in Unity… what have I to do?

tribal moth
half herald
#

Is there a way to navigate title screen buttons with keyboard and mouse ?

drifting sandal
#

After the scary email today, when anyone updated their version of Unity, did you have issues of inputs no longer working? Because that is my current issue

austere grotto
drifting sandal
austere grotto
#

Check your input system settings

drifting sandal
#

I tried quitting unity and reopening. inputs still aren't working

austere grotto
drifting sandal
#

yeah. inputs work in the debugger

#

I'm also using the PlayerInput component if that matters

austere grotto
#

then it's probably something like a control schemes issue

#

And/Or - you have more than one PlayerInput in the scene

drifting sandal
#

it wouldn't be that, because it worked this morning before doing the Unity Version update. SO something broke during/after updating the Unity version to one of the new patches

#

i'm manually updating the input system just to see if that 'wakes it up' or something (i see there is an update available)

#

YAY! updating the insput system fixed it!

half herald
# austere grotto yes

The issue I am having is I have to click on the button in order for the game to register the keyboard. I would like to know how I can make this immediate? I have set it so that when the keys are selected they change to red. I also have the inspector set up like this for the event system.

#

Here's a video demo of my issue. I have to actually click on the buttons for it to allow me to move up and down with the w,s and up and down arrow keys.

#

I could really use the help im not too familiar with how to set this up properly

minor pasture
austere grotto
ornate star
ornate star
half herald
#

I have to click on the button first before I can move with my keyboard and mouse I would like it to do so without me having to use my mouse to register the keyboard?

floral hearth
crisp cape
fierce compass
#

!input

cobalt mossBOT
# fierce compass !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

misty breach
#

Hello, I have two scenes with one being my main scene and one being a minigame scene that I wanted to load using LoadSceneMode.Additive. The two scenes have PlayerInputs in them with different action map and I'm having trouble understanding how do I manage this system. Do I only keep one player input and have the minigame subscribe to it's action map events and then switch it ?

#

Here are the two player inputs with their Unity Events

austere grotto
#

You can initialize it in a bootstrapping scene.

But if this game is not local multiplayer you can use another workflow

misty breach
#

I see thank you ! I'll just subscribe with the Fishing Pole minigame then

light belfry
#

hi

#

i think its a input problem

#

not about the input system itself but...

#

i made a custom joystick (its old i made it like 5 years ago i think)
its not the first time i use it so i know its not the issue here,

for the games i made it, i was using either third person or 2d directly so i never have this problem.

im taking on a new project with some things on going and one of the things that was pissing me off its the character moving very off from the previous joystick...

i switched to my then i realized that i get a new problem

#

the game is 2.5D and the movement are calculated in a more raw way

#

so the problem is.
i need to change my input from x(-1,1) y(-1,1) (circle since its normalized) to a eliptical shape

#

how can i calculate it?

austere grotto
# light belfry so the problem is. i need to change my input from x(-1,1) y(-1,1) (circle since ...

Explains how to perform two different types of projections of a point onto an ellipse.

  • If you would like to support me to make these videos, you can join the Channel Membership, by hitting the "Join" button below the video, and making a contribution to support the cost of a coffee a month. It would be very much appreciated. Or by clicking he...
▶ Play video
light belfry
#

tks

austere grotto
#

Though to be honest I'm not sure I understand why you need this

tranquil gale
#

Hi guys, I didn't have this channel on my list for some reason, but I'm having an issue (explained here: #💻┃code-beginner message and i'd love some experienced brains to take a gander. TIA

austere grotto
tranquil gale
#

!code

cobalt mossBOT
tranquil gale
#

https://paste.mod.gg/xtcmnocztjja/0 I think thats all the relevant scripts. I initialize the game, which sets the windows/ pause state etc. when pause is pressed it fires off an event, pause manager switches states, ui panels turn on and off based on state

austere grotto
#

Enabling or disabling action maps on that copy is not going to have any effect on the InputActionReferences

#

Because they refer to the original asset

#

If you did for example pauseAction.action.actionMap then you'd get the map that InputAction is a part of

tranquil gale
#

oh... that's, confusing lol. Thanks, I appreciate you taking a look. I'll go check the documentation again, I must have misunderstood unity's tutorial video.

light belfry
# austere grotto Though to be honest I'm not sure I understand why you need this

there was a distortion when the input as been transfering the vector2 (hud joystick) to the player (on 2.5d) i thought it as the distortion of the 2.5d was messing of the right direction...
actually it was the projection...
i was using the camera (right and forward) to point the direction... but the camera itself was inclinetad... so thats is the source of the shit.
bcs the camera was inclinated, the forward and backward was "retuning 1 or -1" when translating to the player movement but something around 0.7 or -0.7.

so insted of moving and rotating in a circle... it was moving and rotating on a eliptical shape... and i was trying to correct it
(since now i know what was happening i already solved it, but tks anyway)

woeful verge
#

I am building some menu based controls, and I want to know there preferred design pattern. Do you make one click handler for everything and route based on the button name (fewer files but more messy), or one click handler class per button (tons of files, but each has only one purpose)?

lyric shoal
#

Is there a way to fix that I can't press buttons made with OnGUI whenever vr is on?

digital lantern
#

Hey! Is it possible to make a static Player Input Manager class with the new input system or does it have to be a MonoBehaviour?

#

Please ping me if you respond

austere grotto
light belfry
#

hi

#

(lately im been asking a lot of things, wtf is happening🤣 )

fierce compass
#

https://nohello.net , just open with your question
(you can tack those things to the end if you want)

light belfry
#

i have a problem with the editor input read (i think thats it at last)

so i have 2 scripts that derivates from the same script for my input system (a mobile script (for touch and custom joystick) and a pc script (for axis and mouse click))
currently im using the old input system in the script (im used to the old one)

(for the settup of the project im using both input systems)

today i was testing responsivity of the screen and i realized that the pc script stops reading the axis when i swith the game view from game to simulator

still trout
#

you are most likely just reading Input.mousePosition without enabling touch simulation

#

Set Input.simulateMouseWithTouches to true or use Input.touches[] instead of mousePosition

light belfry
#

i removed my check for the device type in the scrips and in my player settings for mobile are all set to both input system handles

light belfry
#

the mobile simulation is working fine

#

the problem is my normal/pc stops working

#

even if i force the pc read

still trout
#

So it works on a device but not in the simulator tab?

light belfry
#

i didnt connet the device yet, just the editor

#

wait

still trout
#

Yes, then please read the text again

light belfry
#

im explaning it badly

still trout
#

you are now getting touches instead of mousePositions

light belfry
#

ok, again.

my input for mobile (touches and mouse) are working fine

#

my problem is

light belfry
#

the engine base inputs (get axis ("horizontal")-get axis("vertical")-get button("custom")) stops working

still trout
#

you usually trigger them by pressing WASD?

light belfry
#

yep

still trout
#

can you show the code where you read them?

light belfry
#

sure

#

you want both scrips or just the not readying one?

still trout
#

Both would be perfect, if its much code please post like described in !code

#

!code

cobalt mossBOT
light belfry
cobalt mossBOT
light belfry
#

oh

#

this is good

#

!code
using UnityEditor;
using UnityEngine;

public class PC_PlayerController : PlayerControlManager
{
void Start()
{
print("PC ON");
//if (SystemInfo.deviceType == DeviceType.Desktop)
//{
PlayerScript.player.input = this; //forces as main input
//}
}

void Update()
{
    movementDirection = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).normalized;

    print("pc"+movementDirection);//no update //displaying x0.y0


    isInteracting = Input.GetButtonDown("Fire1") || Input.GetButton("Fire1");

    cameraRotationDirection = new Vector2(Input.mousePositionDelta.x, Input.mousePositionDelta.y) * cameraRotationMultiply;

    AddZoom(Input.mouseScrollDelta.y);
}

public override void Callback()
{
    return;//faz nada
}

}

cobalt mossBOT
light belfry
#

wait

still trout
#

dump question, have you clicked into the simulator once before trying wasd? sometimes it doesnt properly get focus

#

use
```cs
CODE
```

light belfry
#

i didnt have clicked before,
but today i was making a screen fit check... spended some time then i got that what is breaking the input

green socket
#

Hi everyone, I’m not sure if this is the right place to ask, but I’m trying to create a settings section in my GUI where the player can choose their keybinds. I’m using the new Unity Input System and I’m not really sure how to do it. Could someone help me, or maybe point me to a good tutorial?

fierce compass
#

that kind of thing you should just google to start yourself tbh

severe narwhal
#

yeah those were the first 3 videos type shi

green socket
severe narwhal
#

"unity rebind controls" was what I searched for 👍

#

maybe "unity allow player to change button mapping" is more specific prompt

green socket
fierce compass
#

"unity input system rebind menu" gives plenty of results

fierce compass
severe narwhal
#

my YouTube stopped recommending crappy Unity channels lol 🤷‍♂️

silk wyvern
#

Input Manager. What will a key or pad button return?
I know a Vector2 binding will return Vector2, but a key? A bool, or something else?

EDIT: The exception said, it's a "float" - but could I have known in advance?

fierce compass
fierce compass
silk wyvern
# fierce compass also, that's not the inputmanager - that's the old system, your screenshot (and ...

I was mixing things up in my head then. I meant the new input system.
Though... my button press detection suffers from bouncing.
I get them from the input system (from active action map) with:

        pauseInputVal = inputActionPause.ReadValue<float>();

        if(1f == pauseInputVal) // Button presssed?
        {
            toggglePause();
        }

Using ESC or a controller "start" button shows clear bouncing, toggling my pause screen on and off unreliably.
Is there a better way to avoid picking up physical button bouncing?

fierce compass
#

use WasPressedThisFrame for the check (and if you do need to check if it's currently pressed, use IsPressed instead of the == 1f check)

silk wyvern
fierce compass
silk wyvern
#

New input system is so nice with being able to seamlessly support a controller and KB/M.

boreal ruin
#

Hey, i have a system which shows in UI, some keybinds hints like "[E] Interact", and when I rebind my key, (if the hint is disabled, next time it'll show up and show the correct keybind. However, if the player is close to the point where the hint is displayed, if he just rebind while he's standing in front of the hint, the hint won't be updated unless the player go away and go back to the "hint point".

I tried to do some event in the RebindActionUI class, however this event can't be subscribe from a script from my namespace, so it doesn't work at all
Does anyone know a solution ?

boreal ruin
#

Nevermind i found a solution to refresh all UI enabled when menu is closing, it's very easier

digital lantern
#

How can I check to see if I have a controller connected? Please ping me as soon as possible

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerInputManager : MonoBehaviour
{
    public InputActions InputActions { get; private set; }
    public bool HasController { get; private set; }
    
    public static PlayerInputManager Create() => new GameObject("[Player Input Manager]").AddComponent<PlayerInputManager>();

    private void Awake()
    {
        DontDestroyOnLoad(gameObject);
        InputActions = new InputActions();
        InputActions.Player.Enable();
        InputActions.UI.Enable();
        
        InputSystem.onDeviceChange += HandleDeviceChange;
    }

    private void HandleDeviceChange(InputDevice device, InputDeviceChange deviceChange)
    {
        if (deviceChange == InputDeviceChange.Added || deviceChange == InputDeviceChange.Enabled | deviceChange == InputDeviceChange.Reconnected)
        {
            HasController = true;
        }
        else if (deviceChange == InputDeviceChange.Disconnected || deviceChange == InputDeviceChange.Disabled ||
                 deviceChange == InputDeviceChange.Removed)
        {
            HasController = false;
        }
        print(HasController);
    }
}
peak delta
#

I want to migrate fully to the New Input System in my solitaire game
the problem is when I want to use it for UI and GameObjects and both of those are enabled, it just doesn't detect interactions for GameObjects

    public class Card : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler {
        // ...
        private void OnMouseDown()
        {
            // OLD LOGIC with old Input system
            Debug.Log("OnMouseDown {name}");
            // Create stack if suitable
            if (!Revealed || !Slot.IsStackable(this) || Manager.DisabledInteractions) return;
            Slot.OnStackGrab(this);
            // _stack = Slot.OnStackGrab(this);
        }

        public void OnPointerDown(PointerEventData eventData)
        {
            Debug.Log($"OnPointerDown! {name}");
        }

        public void OnPointerEnter(PointerEventData eventData)
        {
            Debug.Log($"OnPointerEnter! {name}");
        }
}

once I disable UIDocument with overlaying GUI, it detects those interactions with GameObjects
how to set this input system and ui toolkit that it would let those events pass through the ui layer

cinder crown
#

Can someone help me translate this code to Unity 6? Just upgraded my project and struggling to find the updated way to do this:

peak delta
austere grotto
#

double check wherever you're copying this from

cinder crown
cinder crown
#

right, sorry for the typos

austere grotto
#

this may just be a case of your IDE not being synced properly

#

what errors if any are in the Unity Console

cinder crown
#

Ah you're probably right about that. There's been a few of those already. Crap that makes me realize a lot of the "fixes" i've been making this morning might be breaking my project more. Better fix the ide. Thank you

cinder crown
#

yup, when I updated the project, my editor in the project preferrences was no longer set to VS Code. I regenerated project files and then CTRL + Z'd the last 3 hours of nonsense (notlikethis ) and we are functioning in Unity 6. Thanks again @austere grotto

gusty sonnet
#

is there any way to get a generated c# input action class to use the project wide asset instead of instantiating a new asset from json?

gusty sonnet
#

ah, that's a bummer

calm locust
#

i wanna make my player jump shorter on light tap but i still jump in same jumpForce

#

anyone knows solution?

cobalt mossBOT
fierce compass
#

you're only lowering the force when you're still on the ground

calm locust
#

i cant fix it

#

i need help on variable jump height

carmine cedar
#

if you put 3 little tick marks ` it makes ur code
easier to read

calm locust
#

ohhh

carmine cedar
calm locust
#
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed = 6f;
    public float jumpForce = 6.5f;
    Rigidbody2D rb;
    float moveX;
    
    public Transform groundCheck;
    public  LayerMask groundLayer;
    public Vector2 groundCheckSize = new Vector2(0.5f, 0.05f);

    void Start()
    {
        rb=GetComponent<Rigidbody2D>();
    }

    
    void Update()
    {
        rb.linearVelocity=new Vector2(moveX * moveSpeed , rb.linearVelocity.y);
    }
    public void Move(InputAction.CallbackContext context)
    {
        moveX = context.ReadValue<Vector2>().x;
    }
    public void Jump(InputAction.CallbackContext context) {


       if(isGrounded()) {
            if (context.performed)
            {
                rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
            }
            else if (context.canceled)
            {
                rb.linearVelocity = new Vector2(rb.linearVelocity.x, rb.linearVelocity.y * 0.5f);
            }
        }
    }
    private bool isGrounded()
    {
        if (Physics2D.OverlapBox(groundCheck.position, groundCheckSize, 0, groundLayer)) {
         return true;
        }
        return false;
    }
    private void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.darkRed;
        Gizmos.DrawWireCube(groundCheck.position,groundCheckSize);
    }

}``` im trying to do variable jump height mechanic i need help
#

thank you i didnt know that :D

carmine cedar
oblique raven
#

you´d need some kind of time based function, keypress and keyrelease to determine how long the key has been down, after keyrelease you can perform your jump and multiply with that small timer

upbeat dragon
#

Hi please help me understand what all of the ForceMode things are for

#

im not sure which one to use for regular movement and jumping

#

i tried ForceMode.Force for movement but my player isn't moving

carmine cedar
upbeat dragon
#

ok

oblique raven
#

i agree, it has to be something else.

upbeat dragon
austere grotto
upbeat dragon
#

whats that

austere grotto
#

it's the place to do physics

#

If you do physics in Update your game will play differently at different framerates

upbeat dragon
#

ohh okay

austere grotto
#

as for why your object is not moving it could be all kinds of things

#

start by showing the inspector of the object in question

oblique raven
#

probaly using the new input system but using code for the old input

upbeat dragon
#

ohh shoot thats probably the issue

#

i changed it but sometimes it goes back to the new input system

#

let me check rq

oblique raven
#

you should have many warning and errors in the console though

upbeat dragon
#

nope it isnt that

#

it just says the field Movement.force is nevr used

#

as a warning

oblique raven
#

if you are planning to use with WASD you should consider making use of Horizontal and Vertical axis instead

upbeat dragon
#

wdym

austere grotto
#

we should focus on the "why isn't the object moving" part before changing other things

#

Show us the inspector please

oblique raven
#

true sry

upbeat dragon
austere grotto
#

even better would be the whole uncropped unity window with that showing, tbh

upbeat dragon
#

here

austere grotto
upbeat dragon
#

yeah it is

#

nothing happens

austere grotto
#

can you run the game with the console window open and you pressing the W key, and show a screenshot of that?

upbeat dragon
#

ok

#

nothing happens

austere grotto
#

show the full window

upbeat dragon
austere grotto
#

and show what's set there

upbeat dragon
austere grotto
upbeat dragon
austere grotto
#

Also are there any other scripts in the scene?

upbeat dragon
#

no

austere grotto
#

Can you try changing rb.AddForce(Vector3.forward * 2, ForceMode.Force); to rb.AddForce(Vector3.forward * 2000, ForceMode.Force);?

upbeat dragon
#

ok

austere grotto
#

Oh also make sure you've actually saved your code changes

upbeat dragon
#

wth it works but it went wayy too fast

#

but if i do like 4 or smth it doesnt work

austere grotto
#

right - so now, move your Update code into FixedUpdate and put force instead of 2000, then you can modify it in the inspector

#

you probably also want it to be float force not int force so you can have decimals

upbeat dragon
#

ok where do i find it

#

the force variable in inspector

#

aha got it

upbeat dragon
#

hi i have another problem im not sure how to make a good jump mechanic where it has the momentum from moving and also jumps

#

if i try to make a simple jump mechanic it starts moving in the air

#

and doesnt come down

upbeat dragon
#

if(jumped == false)
{
if (Input.GetKeyDown(KeyCode.Space) && isGrounded())
{
rb.AddForce(Vector3.up*100, ForceMode.Impulse);
jumped = true;
}
}

if (jumped && rb.position.y>=5)
{
jumped = false;
}

#

public bool isGrounded()
{
return rb.linearVelocity.y < .01f; //if its 0 or almost 0 then its true
}

austere grotto
#

you will have a negative y velocity any time you are falling.

#

i.e. any part of the second half of the jump

upbeat dragon
austere grotto
upbeat dragon
#

so it is 0 when its on the ground

#

wait ohh but if its falling it would be negative

austere grotto
upbeat dragon
#

so the isGrounded check would go off even if its falling

austere grotto
#

Basically checking the y velocity is not a good proxy for a ground check

upbeat dragon
austere grotto
#

nope. You can have ground at any position presumably

#

unless your game design specifically precludes that

upbeat dragon
#

yeah im trying to make a platformer

#

so it will have some floors in the air

#

is there like a collide function or whatever

#

to check if it collides with cubes

austere grotto
#

Most people use physics queries to detect the ground

upbeat dragon
#

ooh whats that

austere grotto
#

things like Raycast or BoxCast for example

#

or OverlapBox

upbeat dragon
#

huuhh

#

oh wait i can just check if the velocity is exactly 0

#

if its grounded it wont slightly move

#

YESS it works

austere grotto
#

It will work 99% of the time though

#

but it won't work if your player can run up or down slopes

upbeat dragon
#

no it wont run up slopes atleast not for this one

#

ok now i just have to fix my actual jumping

upbeat dragon
#

hi im wondering something

#

so for isGrounded() im trying to use physics.raycast to check if it hits the floor but the problem is im not sure what the maxDistance should be

#

is there a way of finding it out

#

or should i just tinker with the numbers

austere grotto
#

for example if you start the raycast from the center of your player, and your player is 2 units tall, then you would expect the ground to be about 1 unit away from the center of the player when he's standing on the ground, right? So you would do a raycast of maybe 1.05 units long, to add a little padding

#

it all depends on from where you originate the raycast and how far that is from your player's feet

upbeat dragon
#

ohhh

#

so if i want it grounded then i would start the raycast at the bottom

#

so like .5

#

.05

#

for padding purposes

#

wait no

#

ohh i understand

#

so basically for demonstrations sake it shoots a beam down from the player
and then it checks if it encounters something in that distance

#

if it doesnt encountr anything then its airborne

#

otherwise its grounded

austere grotto
upbeat dragon
#

yess :DDD my jump works

#

only issue is like if i move while jumping it goes wayy farther than it would without jumping

digital lantern
#

Hey guys got a question. Please ping me as soon as possible but with the new input action, are you able to use it with Player pref settings to say, invert the Y axis of the look, increase/decrease sensitivity, etc? And what I mean by this is strictly set the processors to the player pref settings, or am I going to have to hard code them in??

toxic lintel
digital lantern
toxic lintel
digital lantern
green socket
#

Hi gyus, i have a little problem
I implemented the key rebinding system with the new input system and it works perfectly, i have only one problem, when i change a keybind and close the game, when i open the game the keybinds in the settings pnael shows the default keybind and not the one the user chose
do someone knows why?

btw i used this tutorial to implement it:
https://youtu.be/qXbjyzBlduY

Ty in advancee to anyone! 🙂

austere grotto
#

Presumably the tutorial doesn't cover that part, so you'll have to write it yourself

green socket
ruby glacier
#

I have an Xbox Wireless Controller paired through Bluetooth right? So how do I access it within Unity?

#

Gamepad.all does not show any results

#

I've tried various Input wrappers including OpenXR and it just doesn't show up.

ruby glacier
#

The Input System doesn't even see the GamePad (Xbox Controller)

#

Holdup the YXBA buttons work.. but not the joysticks

#

I think InputAction.ReadValue<T> is broken on Android because the PlayerInput Component works but not my other code.

#

Nope, for some reason the gamepad is disabled while my vr controllers are active.

#

Great job unity or meta

upbeat dragon
#

hi i have another problem

#

so my jumping and moving works pretty well

#

only thing is that theres a bit of momentum

#

like it keeps moving even after I let go

#

how do i stop that from happening

waxen geyser
#

I have a setup in Unity where, in the main menu, devices are connected and for each device a GameObject is created with a PlayerInput component, which is bound to that device. The problem is that when I load a level, there is already a character with a PlayerInput component, and it can no longer be controlled because the device is only bound to the GameObject created in the menu. What is the best way to handle this?

austere grotto
#

It's 1:1 PlayerInput to human

#

Often it's best to just have a "stub" object with the PI and use some glue code to modularly connect it to stuff as needed such as menu controls, player characters, etc

waxen geyser
austere grotto
#

Each PI is tied to a human

#

If you're going to have persistent ones from a bootstrap scene, don't spawn new ones in the new scene

#

You could/should use PlayerInputManager to spawn them BTW

opaque gorge
#

got a question on the Input Actions Editor.

or rather an issue

#

the action properties panel is broken

#

interactions and processors dont pop up when i add them

#

i sent something on some discussions.unity.com but those are kinda slow and discord has always been faster for me

opaque gorge
# opaque gorge interactions and processors dont pop up when i add them

Im in the action editor,
action type: button.

Interactions is blank right now
but in trying to add a 'hold' interaction
i click the plus, click 'hold' when it appears
but nothing appears.

the dull message saying 'no interactions has been added' disappears, but nothing appears in its place

#

my teacher has said something about it bieng some 'NullReferenceException' though he couldnt help much because he isn't experienced with this new input system

#

and i have no clue whats relevant or whats happening because i am not a programmer, but just some design student brute forcing the programming with tutorials from youtube.

Any help would be greatly appreciated 🙏

fierce compass
opaque gorge
fierce compass
opaque gorge
#

these are the errors

fierce compass
#

so seems like it did create the interaction, since the "no interactions" thing disappeared. the errors seem to suggest that it's having trouble drawing the interactions.

save the asset, and then try restarting the editor

#

if that doesn't work then try a library reset

opaque gorge
#

no dice

#

library reset...?

#

is that deleting the library file and letting unity do its own thing?

fierce compass
#

close the project, delete the Library folder, and then reopen the project

#

it'll take longer to open since it has to rebuild the library

opaque gorge
#

o7

opaque gorge
#

that didnt fix anything unfortunately

#

also sorry if i reply late, im trying to finish a different assignment task atm @_@

#

got the same error when checking the location...

tropic tulip
#

why cant i bind a key here?

static hollow
#

@toxic lintel how can i add a 2d vector composite in Unity's input system?

static hollow
#

i don't have that either

toxic lintel
#

So you're not seeing the option?

static hollow
#

are these old features? i updated Unity a few mins ago

static hollow
toxic lintel
static hollow
#

I can't find the 2d vector composite, nor the up/down composite

toxic lintel
stable gust
#

Hello everyone, I'm new here and I came to ask a question!

#

I'm trying to find a way to transform an action on a UI button to a UI navigation event

#

On the left is a list of buttons (all UI) and the circle will be "selection wheel"

#

Basically, I want to be able to "scroll" that wheel and it triggers a Nivigation event on the button list, going up and down

#

Right now I have it setup and it works, but I'm not using the navigation and if I want to put another "menu" on the screen it will not work, so I want to make it "universal" to all my menus and navigate on this black screen

#

I have the new input system on, and I say there's a mapping for the UI navigation. Basically I want that my "OnScroll" event on the wheel translates to a "Up" or "Down" of the UI inpout mapping

#

Right now this is how it's setup

#

The wheel:

green socket
#

Hi guys, I'm trying to save the input the user chose so that the ui can be also updated, but i'm having some problems in importing the namespace, do someone knows why?
i imported the samples

fierce compass
#

adapt the code into your own work, don't use them in your actual project

green socket
#

or if i can solve in another way

fierce compass
#

you could copy that, but when i went through the samples to make my own rebinding UI, i copied mostly just the logic and handled the linking myself

green socket
fierce compass
#

the custom property drawer does that

green socket
#

okk ty

acoustic gull
#

Hello, do you know why i have this yellow msg ?

fierce compass
#

it's a warning that using the default input actions asset as the asset for a PlayerInput is not intended

#

it's not usually an issue

acoustic gull
#

i should create a new one to not have this message right?

fierce compass
#

no

#

you could just.. unassign the default input actions asset

#

or the alternative would be not using PlayerInput

#

you don't need to create a new one just to avoid the message

acoustic gull
#

Its a bit weird no? to have this msg cuz you are using default, but thanks for answer i'll just go throught

green socket
#

Ty to anyone in advance 🙂

#

this is my ActionMap

#

nvm, i fixed it

toxic lintel
#

Is anyone else seeing repeated input events being fired in the editor recently?
I suspect that these are no longer being cleared when exiting play mode.

#

I'm a bit puzzled on how to clear these

fierce compass
toxic lintel
#

Yep.

fierce compass
#

there's your issue

#

you have to clear these yourself if you don't have the domain reload doing it

toxic lintel
#

I'm trying that but Dispose doesn't work and I can't clear a lambda.

toxic lintel
#

I'm aware, yes 😄

fierce compass
#

ah wait it's an event isn't it

toxic lintel
#

Yeah it's an event

fierce compass
#

ok, rip that

#

why not make it into a method then, i guess?

toxic lintel
#

Because it's 30 input mappings

fierce compass
#

or make a reference for it

fierce compass
toxic lintel
#

It'd need 30 methods

#

As opposed to

fierce compass
#

it'd need 1 method

#

oh shoot, it's a closure

toxic lintel
#

Yeah, both mapping and context are different

#

Context, of course, we can pass. But not mapping

#

Currently experimenting with storing the lambdas

#

Right. This did the trick;

Action<InputAction.CallbackContext> callback = context => Invoke(mapping, context);
_callbacks.Add(callback);
                
action.performed += callback;
action.started += callback;
action.canceled += callback;
#

Weird how this started with .58f2

mortal slate
#

How to handle PlayerInput the right way?

Im spawning it during game scene and destroy on main scene loading

am i supposed to spawn PlayerInput in main menu scene and keep it DontDestroyOnLoad?
What is the right approach?

toxic lintel
verbal remnant
#

You can also opt to not use it at all.

mortal slate
#

Appreciate it 🤘

formal sand
#

Hello. For the game Battleops, what file contains the touch screen sensitivity configuration?

austere grotto
austere grotto
formal sand
tulip kraken
#

for mac os and unity 2022.3.8, how would you enable XRI RightHand Interactions for XR simlator? XRI RightHand Locomotion seem to be working though

#

nvm

vocal swallow
#

is there any issue with having one key do the same thing like this?

#

before rebinding and such theyr all set to the same binding

#

essentially doing the same action 3 different times?

#

is there any performance issue with this or smth

dense scarab
#

so i wanted to ask if nothing bad will come from having one input system on an object that is destroyed than that input system being transferred to anther obj (I have an egg that once destroyed will give you a playable character with the egg and player having an input system attached to them) the problem is when the egg is destroyed and the player is spawned I cant move the player at all.

austere grotto
#

It is a little unclear to me why you need 3 actions though

austere grotto
#

It's better to have a single, persistent, PlayerInput component per human player

vocal swallow
#

like jumping with scroll wheel or space bar

austere grotto
dense scarab
austere grotto
dense scarab
#

oh ok i think i get what you mean thanks for the help imma try to that now

vocal swallow
austere grotto
dense scarab
austere grotto
#

I see you're using Invoke Unity Events but your vidfeo has the Events thing collapsed

vocal swallow
#

ig i didnt need this

#

lmao

austere grotto
dense scarab
# austere grotto how did you hook your code up to the PlayerInput component?

i think im hooking it up normally right because i can still move in my other scene

public void OnMoveLR(InputAction.CallbackContext context)
    {
        horizontalMovement = context.ReadValue<Vector2>();
        if (GetComponent<SpriteRenderer>().flipX)
        {
            rb.linearVelocity = new Vector2(-horizontalMovement.x * moveSpeed, rb.linearVelocity.y);   
        }
        else
        {
            rb.linearVelocity = new Vector2(horizontalMovement.x * moveSpeed, rb.linearVelocity.y);
        }
        isSwiming = true;
    }```
austere grotto
dense scarab
#

oh ok i have them all in different scripts so should i just make one script that handles all of the player input

#

i have my movement script and my player hatch script that handle different inputs

dense scarab
digital lantern
#

Are there benefits to using external input packages, i.e InControl, over the input system? For me, it's the ease of code

distant raptor
#

I found AnyKey in the input actions Keyboard bindings.. but I'm also hunting for an equivilent for GamePad.. but i can't seem to find that

#

if its even possible.. any suggestions?

#

the only thing I know to do is use the .current

        private bool AnyInputPressed()
        {
            // Keyboard
            bool keyboard = Keyboard.current != null && Keyboard.current.anyKey.wasPressedThisFrame;

            // Gamepad
            bool gamepad = Gamepad.current != null &&
                           Gamepad.current.allControls.Any(c => c is ButtonControl b && b.isPressed);

            // Mouse
            bool mouse = Mouse.current != null &&
                         (Mouse.current.leftButton.wasPressedThisFrame ||
                          Mouse.current.rightButton.wasPressedThisFrame ||
                          Mouse.current.middleButton.wasPressedThisFrame);

            return keyboard || gamepad || mouse;
        }```
distant raptor
#

nevermind.. since i really dont understand Linq i've redone it in a for loop

   var controls = Gamepad.current.allControls;
    for (int i = 0; i < controls.Count; i++)
    {
        if (controls[i] is ButtonControl button && button.wasPressedThisFrame)
        {
            gamepadLoop = true;
            break;
        }
    }``` it'll work for now
hardy abyss
#

I'm using the new input system for mouse "OnLook", it does work when i play on "Maxmized" screen but not on focused! any idea?

austere grotto
#

and what you mean by "working" and "not working"

hardy abyss
hardy abyss
#

not even logging on focused mode. the mouse input doesnt seem to work at all

kind vault
#

Hi! I'm having an issue with the new input system when I try to control the button up (released) state.
"InputActionPhase.Canceled" is supposed to tell when the button is released, but it is triggered too if any other button is pressed.

Anyone knows if this is a bug or if I should setup the inputaction mappings any different?

distant raptor
#

im still at teh very infancy of my input-system education.. so i can't suggest solutions... but maybe the 2-cents above helps out a little 🍀

#

ohh also check ur cursor's state.. Cursor.lockState = CursorLockMode.Locked;
if its locked or something it may not get its delta's

kind vault
distant raptor
# kind vault I'm not sure what you mean about composites. The use case is: I hold "Y" button ...

composite inputs is a single Input Action but its made up of multiple controls..

like combining multiple buttons or axes into one logical input
for example WASD keys -> Move vector would be a solid example Unity treats it as one action but internally watches four seperate keys..

each control in a composite can start/stop the action independently
pressing one key may cancel the previous key's contribution..

#

im testing right now.. tho to confirm my suspicions.. (im still very much learning so i wouldn't take my advice completely to heart.. instead take it w/ a grain of salt..)

i think theres a way to log which button/ input triggers the Performed and Cancelled callbacks

distant raptor
hardy abyss
#

brand new project

distant raptor
#

ohh wait.. i totally mixed up two different issues

#

chan's message right after yours seemed almost identical to me

hardy abyss
#

haha i can see why now

distant raptor
#

does the issue still persist even after clicking on it?

hardy abyss
#

yep

#

btw i have installed recently

distant raptor
# hardy abyss btw i have installed recently

im on 6000.0.60.. im not sure if that really matters... unless it does and its a bug.. but imma test real quick once my project finishes loading up.. (its blank for the most part) so imma just test w/ a maximized and minimized game window for ya and just report back my findings) 👍

hardy abyss
#

@distant raptorsame problem on 6.0

distant raptor
#

is it just the mouseDelta?

#

you have the correct Input Handling selected correct?

hardy abyss
distant raptor
#

one of them mornings for me too

hardy abyss
#

keyboard input does work tho

distant raptor
#

interesting..

hardy abyss
hardy abyss
distant raptor
hardy abyss
#

i went to Input Debugger

distant raptor
#

when testing I always click onto the Game window before expecting any of my inputs to work correctly..

#

but it always does.

hardy abyss
#

and found this while Play was active

hardy abyss
distant raptor
distant raptor
#

now you know what you could use to research further..

#

thats the difference between ur test and mine

hardy abyss
#

do u have that device simulator touchscreen as well?

distant raptor
#

soo its possible thats the culprit.. can't say for sure tho

hardy abyss
distant raptor
#

When the Device Simulator or a touchscreen is enabled, Unity may disable other pointer devices to avoid conflicting input.

hardy abyss
#

does it tell how to disable it? cz when i "Play" it always returns

distant raptor
#

maybe in the PlayerInput / actionmap thingy?

#

im not sure in honesty..

#

im learning as i go 😅

hardy abyss
distant raptor
#

thats another thing i was going to mention.. is making sure you had the correct components in the scene.. im not 💯 what those are tho

#

usually the EventSystem is related in some way or fashion

#

ahh nevermind.. quick search says that stuff is more about the UI driven stuff (buttons, sliders, etc)

#

shouldn't interfere

kind vault
#

well, finally I came to a very dirty solution to keep track if a button is pressed, no matter if any other buttons are being pressed or released:

Gamepad.current.buttonNorth.ReadValue();

Will return 1 if the button is pressed and 0 if not. I would have extected context.ReadValue<int>() to return the same value, but it doesn't

fierce compass
austere grotto
kind vault
#

"it should be ReadValue<float>" and return >0.5 if pressed, but it returns 0 too

context.ReadValueAsButton() also returns false while the button is still pressed.

I believe Unity is pre-processing something between the raw button push, which is captured directly from the gamepad, and the callback. Sadly I can't find in the Unity's doc what is causing this behaviour.

stable oriole
#

I'm planning to create a prototype, where I can switch between a RC car, drone and a regular character. How do I architect the whole Input system.

Obviously I plan to use the newinput system with the generated class.

fair wigeon
stable oriole
#

Obviously

#

But how do I decentralise all the movement logic for entities and communicate with something like a central manager?

austere grotto
austere grotto
stable oriole
fair wigeon
austere grotto
#

Just exposing the generated class instance

#

The generated class already exposes all the actions etc. no need to duplicate that

austere grotto
stable oriole
#

Or we could just make the generated class a singleton and get its reference wherever needed? Wouldn't this be more simple @austere grotto ? Why just create a manager class just to expose the reference of the generated class.

#

Did you suggest the creation of Manager class as it is preferred to not modify the generated class?

austere grotto
kind vault
# austere grotto Can you share more about your setup? What workflow are you using?

It's pretty basic setup. Just the input actions system action I sent above, and a "Invoke Unity Events" Behaviour on the Player Input component. The code is pretty basic too:

public void GrabAction(CallbackContext context)
{
//TODO: find another aproach to this!!
float buttonNorthValue = Gamepad.current.buttonNorth.ReadValue();

if (context.phase == UnityEngine.InputSystem.InputActionPhase.Started)
{
    grab = true; 
}
if (context.phase == UnityEngine.InputSystem.InputActionPhase.Canceled && buttonNorthValue == 0)
{
    grab = false;
}

}

hardy flare
#

How can I update this to the "new" input system

fair wigeon
#

well you just make an input action with the space, c and j bindings

#

and subcribe to its performed event

hardy flare
#

input.action["jump"] isnt a boolean apperantly

fair wigeon
hardy flare
#

nevermind i figured it out, i needed to have it read the value .ReadValue<>()

fair wigeon
#

yeah

hardy flare
#

How can I do GetKeyDown/KeyUp with the new input system?

fair wigeon
hardy flare
#

Thanks

austere grotto
#

Or use WasPressedThisFrame and WasReleasedThisFrame

hardy flare
#

InvalidOperationException: Cannot read value of type 'Single' from composite 'UnityEngine.InputSystem.Composites.Vector2Composite' bound to action

#

Did i convert this wrong?

#

ughhh the new stuff is so confusing

fierce compass
#

if so, you'd read a Vector2 from it

fair wigeon
hardy flare
#

thanks for the help

#

🤦‍♂️ 😆

severe narwhal
#

⭐ hello, can anyone help with Layout Overrides, specifically how to access Gyroscope/Accelerometer of a Gamepad?

Just being able to see everything the Gamepad reports would be fine too. (SwitchProControllerHID)

I've looked into previous posts here, and online, but I can't seem to get any data coming in. But the Layout Override works fine (see image)

vale zodiac
severe narwhal
vale zodiac
severe narwhal
#

For sure yeah not knowing how to use it can lead to some issues

vale zodiac
vale zodiac
#

not working

vale zodiac
#

there is no working toturial

vale zodiac
# severe narwhal It's pretty straightforward for most things. No?

using UnityEngine;
using UnityEngine.InputSystem;

[RequireComponent(typeof(CharacterController))]
public class Player : MonoBehaviour
{
private InputAction _move_Action, _jump_Action;
private CharacterController _characterController;

[Header("Movement Settings")]
public float moveSpeed = 5f;
public float jumpHeight = 2f;
public float gravity = -9.81f;

private Vector3 velocity;
private bool isGrounded;

private void Awake()
{
    _move_Action = InputSystem.actions.FindAction("Move");
    _jump_Action = InputSystem.actions.FindAction("Jump");

    _jump_Action.performed += Jump;
    _characterController = GetComponent<CharacterController>();
}

private void Jump(InputAction.CallbackContext context)
{
    if (isGrounded)
    {
        velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    }
}

private void Update()
{
    // Check if grounded
    isGrounded = _characterController.isGrounded;
    if (isGrounded && velocity.y < 0)
    {
        velocity.y = -2f; // Small downward force to keep grounded
    }

    // Movement
    Vector2 moveVector = _move_Action.ReadValue<Vector2>();
    Vector3 move = transform.right * moveVector.x + transform.forward * moveVector.y;
    _characterController.Move(move * moveSpeed * Time.deltaTime);

    // Apply gravity
    velocity.y += gravity * Time.deltaTime;
    _characterController.Move(velocity * Time.deltaTime);
}

}
no way that is not complicated

severe narwhal
# vale zodiac using UnityEngine; using UnityEngine.InputSystem; [RequireComponent(typeof(Char...

Nice use of [Header], that’s cool. And well, that’s like the bare minimum right there. I don’t even see any animator related stuff etc, it gets more complicated Unity
Remember that with configuration stuff like gravity jump height etc, scriptable objects can be great. For 2 main reasons - being able to save/duplicate/etc an entire config, easily switch at runtime, and changes stay after Play mode exits.
A cool motion matching asset called MxM uses that “scriptable object config” stonks

severe narwhal
#

I’d give this a read asap too

https://gameprogrammingpatterns.com/state.html

and object pooling next if you want to work with projectiles / “creating” and “deleting” game objects at runtime in general - Unity has a built in one

fierce compass
#

you have a PlayerInput set to SendMessages - an event-based approach, but you aren't actually receiving any messages and you're polling one of the actions and attaching events to another

#

so you're combining 3 approaches here

#

that's more complex than it should be

coral jasper
#

is pinch zooming on smartphones has direct component that can read it and utilize it directly? like on-screen stick or on-screen button

#

i had an UI like this, that bunch of button is within a grid layout

#

what i want , is being able to zoom in on that part

#

or i still need to read input and calculate the value and use it myself

#

ok i think im making progress now

verbal remnant
# coral jasper is pinch zooming on smartphones has direct component that can read it and utiliz...

gestures (like pinch) are not something you can do with InputSystem alone, modifiers won't get you there. you need to implement the gesture from multiple pointer inputs yourself. Or use Fingers (asset) https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076

Get the Fingers - Touch Gestures for Unity package from Digital Ruby (Jeff Johnson) and speed up your game development process. Find this & other Input Management options on the Unity Asset Store.

coral jasper
coral jasper
#
public static float ZoomAction(this InputManager manager)
{
    if (Touch.activeTouches.Count < 2)
    {
        return 0; //single input , ignore
    }

    Touch touch0 = Touch.activeTouches[0];
    Touch touch1 = Touch.activeTouches[1];

    if (touch0.phase != TouchPhase.Moved && touch1.phase != TouchPhase.Moved)
    {
        return 0;
    }

    if (touch0.history.Count < 1 || touch1.history.Count < 1)
    {
        return 0;
    }

    return Mathf.Clamp(Vector2.Distance(touch0.screenPosition, touch1.screenPosition) - Vector2.Distance(touch0.history[0].screenPosition, touch1.history[0].screenPosition), -1, 1);
}```
#

i used enhanced touch to make my own pinch gesture

#
    private void Update()
    {
        float ZoomInputValue = InputManager.Instance.ZoomAction();

        BatchPlanMap.enabled = ZoomInputValue == 0;
        
        if (ZoomInputValue < 0)
        {
            Debug.Log("shrink");
        }
        else if (ZoomInputValue > 0)
        {
            Debug.Log("zoom");
        }
    }```

and i let any UI that need to listen the gesture to call and listen the function
#

BatchPlanMap is a scroll rect , because pinching two finger actions might have conflicts with dragging/moving grid layout , that will cause glitches

#

so , if pinching action is detected, disable the scroll rect to remove conflicts

#

if pinching is not detected, enable the scroll rect

#

it works tho, not that performant i think?

meager zephyr
#

Hello, I'm new to Unity and I'm trying to make a rhythm-based action mechanic like the one in Crypt of the NecroDancer, but I don't know how to use the Input system or how I should use it for such a mechanic

fair wigeon
meager zephyr
verbal remnant
# meager zephyr I barely understand anything 💀

you are not alone, the input system documentation is terrible at giving you a good idea how it is supposed to work. Some of the recommendations in it are terrible (particularly the recommendation to use the singleton accessor + Find("ActionName")*). And nobody knows why they are maintained. Regardless it is a system worth learning. But nobody can give you a recipe for how to use it that allows you to skip understanding its many options to use it competently.

*).Find() should be replaced by serialized InputActionReference fields.

supple crow
#

InputActionReference is my preferred way to go

#

you neatly assign references to the actions you need

toxic lintel
#

I use FindAction(string) so I can bind them to an enum

#

There was a reason for this thinkies

coral jasper
#

my way is to have a dedicated manager to store the asset reference

#

i know enhanced supports cant be used with input action on same behavior

#

i just make sure theyre not conflicting

bright stump
#

This FindAction stuff?! Can you not reference actions in the Inspector at least instead of grabbing them by string in code? I suppose you could serialize the strings but still bad...

fair wigeon
bright stump
fair wigeon
bright stump
#

Is the documentation wrong about mouse input - InputSystem.Mouse.current.leftButton.isPressed - Mouse is not present

fair wigeon
#

actually, i think you need either UnityEngine.InputSystem.Mouse.(...) or just Mouse if you have the using statement

fierce compass
#

Mouse exists in the UnityEngine.InputSystem namespace, so as cookie said

#

InputSystem is also a class in that same namespace

bright stump
#

OK thanks - its just the docs showing the namespace in the statement when should start Mouse... I think that is bad docs really

#

Also from microsoft: DO NOT use the same name for a namespace and a type in that namespace.

fierce compass
fierce compass
#

ah, yep, that's definitely wrong in the docs

bright stump
#

It was a poor decision to add a class with same name as namespace, but is there other docs?

fierce compass
#

Keyboard and Gamepad have the same issue

bright stump
#

yeah, I shall report!

fierce compass
#

the scripting api docs, rather than the manual

fierce compass
bright stump
#

Do touch devices emulate mouse input by default in new system? There seems no option in new API

stable oriole
#

Vector2 lookInput = inputSystemActions.Player.Look.ReadValue<Vector2>();

Is giving me a huge value during the start and rotating my camera to a random rotation. But other than that it's fine.

I've tried flushing the input on the first frame, but it still starts with pointing to a random rotation on the start.

fair wigeon
stable oriole
#

yes

fair wigeon
#

if you start playing using a hotkey instead does that still happen

stable oriole
#

I'll try that

stable oriole
bright stump
#

anybody handle both mouse and touch and combine them into 1 down/move/up type mapped system? It would seem annoying to setup separate systems for basic mouse-first games. You can simulate touch but seems both ways not just touch to mouse which maybe is fine though not sure what happens behind scenes

bright stump
#

was it really needed to have .current for things like a keyboard? Could they not have had Keyboard.commaKey.wasPressedThisFrame which would return false if no keyboard?!

austere grotto
bright stump
#

well technically current can be null though

#

But for typing's sake I am using a function now - hopefully compiles down!

fierce compass
#

(also, what praetor suggested is also technically a function)

bright stump
#

Is there something like sensitivity, gravity, snap for actions in new system?

austere grotto
#

No gravity one at the moment though

bright stump
#

Yeah I made a custom processor now for sensitivity and snap as per the old one, but can not handle gravity as no callback if no input!

dawn sapphire
#

Hi everyone my name is Ming I'm new here

fierce compass
#

if you have a question, feel free to ask

austere grotto
# bright stump Yeah I made a custom processor now for sensitivity and snap as per the old one, ...

something like gravity is tricky if you're using an event-based workflow because it involves changing the input value on a synthetic cadence without the actual hardware input changing

If you're willing to eschew events you can write a processor with the EvaluateOnEveryRead caching policy: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.15/api/UnityEngine.InputSystem.InputProcessor.CachingPolicy.html

Otherwise I recommend just implementing gravity in Update outside the input system with MoveTowards.

clever pilot
#

I want to build something small for altctrlgdc, and was curious if anyone has experience with using gyroscopes in unity? I tried using a wii remote with an api (wiimote api) but it wasnt the most polished considering it's like 15 years old, and want to look into alternatives. The wii remote is actually the perfect size fit for the alternate controller we're sticking it in, and while Ive seen some people use their phones somehow, a phone is just too big atm (might use it anyway but again, wanna see alternatives due to size). Are there specific pieces of hardware I could use that will work with unity? I literally just need to access the rotation of it so I can create the controller, and im not sure where to look/start

quiet spoke
#

Does anyone know how to enable gyroscope as an input method in 2d?

#

i want to get it working like it's a mouse but for some reason it just doesn't let me, not to mention that ll the tutorials are about mobile phones and not controllers

austere grotto
#

but what kind of controller do you mean

vale zodiac
#

hi does someone know any tutorial about how to do first person movement form scratch using new input system

fierce compass
#

try googling around

vale zodiac
fierce compass
#

googling can give you a ton of results much faster

#

do you want us to just google for you

vale zodiac
#

the only 2 i found one feels like it came out of hell and the second one 3 hours video and the he editing anouther script with old input system thet it's tutoria is 2 jours

#

and i am not doing that

fierce compass
#

have you tried different keywords or just scrolling further

#

i found several 10ish minute tutorials from a single search lol

vale zodiac
#

i trievrything

#

chatgpt

#

even deepseek

fierce compass
#

im not gonna spam 20 links here, so here's the search terms i used
"unity inputsystem first person controller"

fierce compass
vale zodiac
fierce compass
#

remember, googling effectively is a skill too

vale zodiac
vale zodiac
#

using UnityEngine;
using UnityEngine.InputSystem;
public class PllayerMove : MonoBehaviour
{
[SerializeField] float speed = 10f;

Vector2 moveinput;

Rigidbody rb;

private void Start()
{
    rb = GetComponent<Rigidbody>();
}

private void Update()
{
    run();
}

 public void run()
{
    Vector3 pleyvelocity = new Vector3(moveinput.x * speed, rb.linearVelocity.y, moveinput.y * speed);

    rb.linearVelocity = transform.TransformDirection(pleyvelocity);
}


public void OnMove(InputValue value)
{
    moveinput = value.Get<Vector2>();
}

}
why i cannot add it to the inpector

cobalt mossBOT
austere grotto
#

Add what to the inspector?

vale zodiac
austere grotto
#

what are you trying to add

vale zodiac
austere grotto
#

CallbackContext is the parameter type as you can see here

vale zodiac
austere grotto
#

You seem to have mixed up two different workflows here

vale zodiac
austere grotto
#

then you can assign it in the inspector properly

vale zodiac
#

but what is the diff between callback ans send message which one is better

austere grotto
#

You mean the difference between UnityEvents and Send Messages?

#

UnityEvents you assign in the inspector

austere grotto
#

The biggest difference is assigning it in the inspector vs using the name to call it automatically

onyx sandal
#

Hope it's right channel to ask about input actions. I got hit with a bug? that my keyboard input for some reason didn't read while it worked fine with both mouse and gamepad. Then i made new exactly same copy of broken map and it's working just fine
I can't figure out what's the problem and perhaps how to avoid this in future. Top screen is old and bottom is new

verbal remnant
onyx sandal
#

Thank you, for some reason old map used path: dpad instead of Vector2, even tho i've tried to change it few times in inspector

vale zodiac
#

void OnShoot(InputValue value)
{
if (value.isPressed)
{

    if (isauto)
    {

    }
    else
    {
        shoot();
    }
}

} can some tell me like whow to make the function spamble i mean like wehn i keep holding it keeps shooting

austere grotto
plucky pecan
#

Can someone help me understand how to use this? Like dm me or just send it right here? Because im trying to start my dream project but I need to learn basics first 😭 I just want to know if I use InputAction or InputActionMap for movement and what not. Im desperate help me

fair wigeon
# plucky pecan Can someone help me understand how to use this? Like dm me or just send it right...

an input action is an individual thing you can do, which has bindings
an input action could be something like movement, shooting, etc etc - each of them can have one or multiple keys bound to it

while an input action map is a collection of input actions, which you can toggle on and off, so you can have one for, say, walking around, one for when you're driving a vehicle, one when you're swimming, and so on

#

input actions are what you'd use to actually read input

plucky pecan
#

Like examplere yk?

fair wigeon
# plucky pecan Thanks. But like. How do I use it?

many ways, the (imo) easiest is just creating some actions (double click the input actions thingy in your file system - should be there by default in newer versions), then in code you can serialize an InputActionReference, which lets you assign the correct action in the inspector

#

then, you can access the InputActionReference's .action property, which is the actual input action

#

that has events, like .performed, .canceled and some others

plucky pecan
#

Sick

fair wigeon
#

which you can subscribe to

plucky pecan
fair wigeon
#

you can also use action.ReadValue<Type>(), which returns the value for it (the most common use case is when you have a composite (2d, like a joystick) action, for which the type would be Vector2)

plucky pecan
plucky pecan
#

Now I just need to remember this

fair wigeon
#

i mean subscribe to the events, which means make a method get called when they're invoked

plucky pecan
#

Yippee

fair wigeon
plucky pecan
#

Plus I need to remember how to make stuff from scratch

#

And other crap

fair wigeon
#

a lot of the tutorials i've seen for it wildly overcomplicate it tbh

plucky pecan
#

I have a course in code4fun

#

But I just forget it all

#

Cause I dont practice

#

Im so good at this stuff ngl

fair wigeon
#

the input actions also have other properties and methods, which you can read in the docs

plucky pecan
#

I tried reading the documentation

#

Too many words

#

And, well, im a dumbass sooo

fair wigeon
#

reading docs is pretty much essential to almost any form of programming, so it's definitely something you'll have to learn at some point

plucky pecan
#

yeah

#

I know

#

I should be fine right?

#

Right?

fair wigeon
#

i believe in you

plucky pecan
bright stump
#

Do people really keep the "Use Physical Keys" setting on? Because how can you tell people which key does what if 'q' does not always map to q - it is just the key to right of tab?

verbal remnant
warped yoke
#

Is it possible to create a SmoothDamp Processor? Or some kind of damping effect to the input system itself? I can do this easily in a movement script, but I'd have to manage different damping for different control methods where it seems logically better for the input system to handle this.

verbal remnant
#

you probably cant use them for a smoothdamp though because they need to be stateless

vale zodiac
fierce compass
#

if OnShoot is supposed to receive messages from a PlayerInput, you aren't supposed to call it yourself

vale zodiac
fierce compass
#

set a press & release interaction, then in the message, you can check if it was pressed (you'll receive a message when it's released too) to update a state accordingly

vale zodiac
#

back

fierce compass
#

could you clarify what you mean by that

#

make sure you've saved the asset

vale zodiac
vale zodiac
fierce compass
vale zodiac
fierce compass
#

the hold interaction makes it do a different thing once it's been held down for a period of time

fierce compass
#

a press & release

vale zodiac
fierce compass
#

did you make it press & release

#

it's an option of the press interaction

vale zodiac
#

i want to be able to hold it

fierce compass
#

that's what press & release will let you detect

vale zodiac
#

i wanna change this but i can't

#

when i press enter it return to defult

fierce compass
#

you don't need to change that

#

just leave it default

vale zodiac
#

do you get me

fierce compass
#

i do not

vale zodiac
#

i am working on shooting system and i want to when i hold it keep printing

fierce compass
#

what do you think press point does

#

it's unrelated to detecting holding a button

#

it's just for analog inputs, it's the threshold to consider the button "pressed"

vale zodiac
#

ok but i am aking to keep printing when i keep holding and that is not what i got

fierce compass
#

if you have it set to press & release, you will get 2 OnShoot messages. once when you press the button, and once when you release the button. you can check which one it is via the InputValue, with the isPressed field

then, based on those messages, you have to keep track of a state yourself

#

you could alternatively do polling for this action specifically, but that kinda goes against using the playerinput

#

pseudocode:```cs
bool held

Update() {
if (held) {
// currently being held
}
}

OnAction(InputValue x) {
if (x.isPressed) {
// was pressed this frame
held = true;
} else {
// was released this frame
held = false;
}
// you could also do
// held = x.isPressed;
}

vast comet
#

Is there a way to use Left Trigger [Gamepad] and Right Trigger [Gamepad] as axes, like with the old input system? I tried setting the action to Value/Axis, but it only returns 1 or 0 when I try to get the value as a float.

#

^Nvm. My controller can switch between controller types, and it was in Switch mode which only outputs digital Triggers. Switched to Xbox mode and it started working as expected.

lilac breach
#

My play testers have told me that the standard Unity Character Controller feels awful. I need a kinematic one and have tried KCC in the asset store but I can't retro fit it into my game (which is FPS and the controller is setup as 3rd person). Anyone know of any other kinematic character controllers they would recommend? Many thanks!
https://assetstore.unity.com/packages/tools/physics/kinematic-character-controller-99131

Get the Kinematic Character Controller package from Philippe St-Amand and speed up your game development process. Find this & other Physics options on the Unity Asset Store.

austere grotto
lilac breach
austere grotto
#

So? You're talking about a camera difference. The movement of the character wouldn't change

#

/ input change

#

What kind of game is this anyway

verbal remnant
lilac breach
lilac breach
ivory jacinth
#

Is it just walking, jumping, crouching and sprinting?

#

If so on my profile banner I have a link to youtube channel and one of the last videos is about FPS movement. I just don't want to spam videos here, but it literally shows step by step, in a short tutorial how to implement all of that using CharacterController component. While it is not handling crazy use cases for most FPS games it should be enough

lilac breach
ivory jacinth
#

Do you have any specific feedback? Because saying the controller is 'aweful' is not really helpful - is it possible to try the game somewhere?

vale zodiac
#

does someone know how to make my shoot action work like wehn i hold shoot it keep shooting when i stop holding it stops shooting cuz i am trying for a llike 7 days and i can't

sullen pebble
#

hey guys, so Im just using the stock UI.Navigate (Pass throigh Vector2) Action and trying to navigate through a menu with that. Im binding to .performed and it works fine with keyboard and dpad.

However, when i move the joystick It fires like a million times. Huh? I could do something quick and dirty to handle it myself but there must be a way to make this work within the input system

#

.started and .cancelled seem to do nothing when its pass through

austere grotto
austere grotto
sullen pebble
#

the default is kind of a pain

#

i just want a simple menu to scroll through

#

dont wanna deal with what happens when u deselect stuff or use the mouse

#

and ive had issues before with having to micromanage navigation connections

#

this is just a number that goes up or down

austere grotto
#

Is there a rason you need to use an event-based workflow here?

#

I would just use Update

sullen pebble
#

how

austere grotto
#

wdym?

sullen pebble
#

if I read the input from update it will switch every frame

#

right

austere grotto
#

Only if you code it very naively

#

the default navigation handles this stuff, but yes you would need to inplement your own timers etc.

#

you will need to do that anyway

#

even if you're using the event based workflow

sullen pebble
#

the event workflow was supposed to be easier but performed acts weirdly

#

alright

austere grotto
#

The event workflow is not well suited for all tasks

austere grotto
sullen pebble
#

its for a little thing just thought maybe it would be something I missed

austere grotto
#

for passthrough it will fire every time the input device actuation changes

#

if we're talking about a joystick yeah that will often be pretty much every frame

sullen pebble
#

it just says like

#

“performed it fired when the action is performed”

austere grotto
#

Pass-Through

Pass-Through Actions bypass the conflict resolution process described above for Value Actions and don't use the concept of a specific Control driving the Action.*** Instead, any change to any bound Control triggers a callback with that Control's value***. This is useful if you want to process all input from a set of Controls.

sullen pebble
#

ok i just missed that

austere grotto
#

when performed happens depends on the interaction you have set on the action

sullen pebble
#

man where was any of this when I was trying to research

#

thanks

#

last question is there any way to use the default navigation system that isn’t using buttons being selected and setting up all the transitions individually

#

id just like to extract out the direction the user wants to move in

austere grotto
#

the automatic navigation mode works pretty fine.

but uh - if you're having trouble with the passthrough default action why don't you just make your own input action for it

sullen pebble
#

like as a button action type

#

or just change the default action

austere grotto
#

not a button. As a Value/Vector2

sullen pebble
#

i maybe wasn’t clear mean editing the input action was mostly what I was asking for help with

#

even after years I still feel like such a noob with this system

#

could you outline what the input action would be and how the script would handle it?

#

cuz idk what you mean just by that

austere grotto
#

i mean the script will depend on your workflow for handling input in the first place

#

but the action itself would just be:
Action Type: Value
Control Type: Vector2

#

bind it to whatever you want to bind it to

sullen pebble
#

then would you read it or get an event or what

austere grotto
#

you would read it however you want

#

like I said it depends on your current workflow

sullen pebble
#

then what are you suggesting even

austere grotto
#

since you wanted to rely on .performed etc

sullen pebble
#

hold on lemme remind myself what value even means again

sullen pebble
#

ok

#

changing it to value and using the started event does exactly what I wanted

#

no extra handling needed

vale zodiac
vale zodiac
austere grotto
vale zodiac
austere grotto
#

Show code

vale zodiac
#

SEC

vale zodiac
austere grotto
# vale zodiac void OnShoot(InputValue value) { Debug.Log("shoot"); }

yeah so - you'll want to use update and a timer. Basically this:

[SerializeField]
float shotInterval = 0.2f;
bool shooting = false;

float timer = 0;

void Update() {
    if (shooting) {
        timer += Time.deltaTime;
        if (timer >= shotInterval) {
            timer -= shotInterval;
            Shoot();
        }
    }
}

void Shoot() {
  Debug.Log("Firing");
}

void OnShoot(InputValue value)
{
    shooting = value.isPressed;
}```
vale zodiac
austere grotto
#

it's like 8 lines of code

#

yes, if you want to shoot repeatedly, you need a timer

austere grotto
vale zodiac
austere grotto
#

Remember the input system is a system for processing input

#

not for driving your game logic

#

You could make this simpler if you used a different workflow

#

but you';re using PlayerInput with Send Messages mode

#

so you have to work within how that works

#

For example you could read the input directly in Update:

[SerializeField]
float shotInterval = 0.2f;
bool shooting = false;

float timer = 0;

void Update() {
    if (InputSystem.actions["Player/Shoot"].IsPressed()) {
        timer += Time.deltaTime;
        if (timer >= shotInterval) {
            timer -= shotInterval;
            Shoot();
        }
    }
}

void Shoot() {
  Debug.Log("Firing");
}```
#

but most of this logic is here for the consistent timer for shooting over and over again.

#

which you will need no matter what

vale zodiac
vale zodiac
austere grotto
austere grotto
#

!code

cobalt mossBOT
austere grotto
#

(not with screenshots)

vale zodiac
#

IT IS ABOVE THE LIMIT I CNA'T SEND

austere grotto
vale zodiac
austere grotto
#

Why did you just paste the HTML for the blazebin website here lol

#

I need to see your C# unity script

vale zodiac
austere grotto
#

use one of the linked services

austere grotto
#

And what behavior are you seeing exactly?

#

Btw completely unrelated but this:

        float mouseX = lookInput.x * sensitivity * Time.deltaTime;
        float mouseY = lookInput.y * sensitivity * Time.deltaTime;```
Is incorrect. You need to take Time.deltaTime out of there, or your looking around will be jittery
vale zodiac
#

then

vale zodiac
austere grotto
#

And tell me what it prints when you are pressing/releasing it

austere grotto
vale zodiac
austere grotto
#

I'm aware of what you want

#

I'm trying to help you debug it

austere grotto
#

show me

vale zodiac
austere grotto
austere grotto
vale zodiac
austere grotto
#

again I'm fully aware of what you're trying to do, I'm trying to help you debug

vale zodiac
austere grotto
#

so we can get there

austere grotto
#

it doesn't print anything else?

vale zodiac
austere grotto
#

show how you set up the "Shoot" action

austere grotto
#

Ok this is why

#

you added this Press interaction and set it to Release Only

#

delete this whole interaction

#

By presing this "-" button here

vale zodiac
austere grotto
#

once you do that, you should save the asset

#

and then you uncomment the "Fire" Debug.Log and it should work properly

vale zodiac
vale zodiac
austere grotto
#

that is not there by default

vale zodiac
austere grotto
#

nah, you just don't understand it

#

yet

#

But you messed with part of the system you don't understand (the Press interaction)

#

so you got burned

fierce compass
#

you can't go around blaming other stuff for failing to read instructions yourself

latent sapphire
vale zodiac
vale zodiac