#🖱️┃input-system

1 messages · Page 7 of 1

tame oracle
#

But I also have some things that'd be semiautomatic.

#

So I also needed WasPressedThisFrame as well.

#

Many thanks! 😄

#

Wow, this whole thing is really cool! 😄

tame oracle
#

How do I get mouse movement to work with the new input system?

#

This is what I have thus far...

public class PlayerCam : MonoBehaviour
{
    public float xSens, ySens;
    public Transform orientation, aimDir;
    float xRot, yRot;
    public FR_Inputs controls;

    private void Awake()
    {
        controls = new FR_Inputs();
    }
    // Start is called before the first frame update
    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    // Update is called once per frame
    void Update()
    {
        // Get mouse input
        Vector2 mouseVec = controls.Player.Look.ReadValue<Vector2>();
        float mouseX = /*Input.GetAxisRaw("Mouse X")*/ mouseVec.x * Time.deltaTime * xSens;
        float mouseY = /*Input.GetAxisRaw("Mouse Y")*/ mouseVec.y * Time.deltaTime * ySens;
        xRot -= mouseY;
        xRot = Mathf.Clamp(xRot, -90f, 90f);
        yRot += mouseX;

        // Cam rotation/transformation
        transform.rotation = aimDir.rotation = Quaternion.Euler(xRot, yRot, 0);
        orientation.rotation = Quaternion.Euler(0, yRot, 0);
    }
}
#

If multiplying by Input.GetAxisRaw("Mouse [X/Y]"), it works perfectly... but it doesn't work with this new scheme yet. 🤔

idle monolith
#

How to I get the value of an Input Action in script? I made an Input Action and I want that value in my script

#

I've googled this for an hour and can't find it

#

I have an Input Action Vector2 called MoveLily, how to i get that value in script

austere grotto
austere grotto
idle monolith
#

I am reading the documentation and I don't understand it

#

How do I pull the input action value into my player script

austere grotto
#

Again it depends which approach you're taking

idle monolith
#

I don't even know what you mean by that

austere grotto
#

There are many ways to use the input system

idle monolith
#
    {
        MoveLily = MoveLily.current
        LilyMovement = MoveLily.ReadValue<Vector2>();
    }```
#

I'm trying to do this

austere grotto
#

depending on which way you are trying to use it, the code to get the value is different

idle monolith
#

reference the action I made

austere grotto
idle monolith
#

I made an Action called MoveLily

austere grotto
#

How?

#

show what you did

idle monolith
#

in the input system

austere grotto
#

Obviously...

idle monolith
#

I made an action

austere grotto
#

be more specific

#

yes

#

You mde an action

idle monolith
#

I have no idea how to describe it to you

austere grotto
#

Screenshots

#

code

idle monolith
#

How do I get that value

#

that's what I'm asking

idle monolith
#

so MoveLily = InputActionReference?

#

I don't know the syntax

austere grotto
#
public InputActionReference MoveLilyAction;```
#

Then you will need to assign the action in the inspector

idle monolith
#

ah

austere grotto
#

then in your code you can do MoveLilyAction.action.ReadValue<Vector2>();

idle monolith
#

ok that's what I was looking for

austere grotto
#

Note again this is just one of many ways to do it

idle monolith
#

I'll try to make it work, thanks!

austere grotto
#

One thing you might have to do is enable the input action asset before that works though, don't remember off the top of my head

idle monolith
#

yea the public action isn't showing up in inspector

#

I just made InputAction, does it have to be InputActionReference?

austere grotto
#

InputActionReference would be to refer to an InputAction you defined in an input action asset somewhere

#

And if the slot doesn't show up in the inspector you probably have a compile error

idle monolith
#

ok I get it

austere grotto
#

Did you define a public InputAction MoveLily;?

#

Or did you make an action in an input actions asset?

idle monolith
#

InputAction is if I'm making a new one in script

austere grotto
#

That's why I'm asking

#

to be specific

#

those are very different things

idle monolith
#

I didn't know enough to answer your question

#

reference is what i need

#

testing it now

austere grotto
#

You don't know if you wrote the code public InputAction MoveLily;?

#

Input Action Assets look like this:

idle monolith
austere grotto
#

You either defined your input action in one of these^
Or you did it directly on a script

idle monolith
#

I made an InputAction in the Input System

#

I didn't define one in script

austere grotto
idle monolith
#

in the picture yea

austere grotto
#

ok yes then InputActionReference will work with it

idle monolith
#

ok in that code is there anything wrong? because the input value isn't working

#

LilyMovement = MoveLily.action.ReadValue<Vector2>();

austere grotto
#

in what way is it not working

idle monolith
#

when I move the left stick on my controller it's not changing the values

austere grotto
#

Ok so yeah it might be as I suspected, you might need to enable it

idle monolith
#

I assigned the left stick as the vector2 in the Input Window

austere grotto
#

One thing you can do is, in Start, Awake, or OnEnable, you can do MoveLily.action.Enable();

idle monolith
#

ok it works now, I just want the player to move the same forward as the camera

#

not the player object's forward

#

I thought I did that with LilyCam.transform.forward

austere grotto
#

If you want Translate to work in world space you need to add a second parameter:

transform.Translate(LilyMovement.y * LilyCam.transform.forward * walkSpeed * Time.deltaTime, Space.World);```
idle monolith
#

I did that and player is still moving it's forward and backwards

austere grotto
#

show what you wrote, and show what "LilyCam" is assigned to

idle monolith
#

LilyCam is assigned to the Cinemachine Free Look Camera I made

austere grotto
#

not the FreeLook

#

the FreeLook (especially the top level object) is not going to move

idle monolith
#

ah ok

#

that worked thank you

midnight summit
#

I currently have a problem with the Input System: I am using this 2d vector for the WASD Controls, "Keyboard" is a digitally normalized 2d vector composite. If I press W or S, and try to read the vector, it tells me that both axes are zero. Only when I press A or D simultaneously, the y axis(W/S) updates correctly. This doesn't happen with the x axis(A/D), it always updates correctly without further button presses. I am just really confused here, is this a Unity bug or did I miss something?

fiery ermine
#

hey is the function SwitchCurrentActionMap() still available? my editor doesn't seem to recognise it

sharp ingot
#

Arent onpointer events and checking for raycast hit from a mouse identical at least for 2D Games? Are there any performance benefits?

austere grotto
#

The main benefit is your UI will seamlessly work with clicking on game world stuff

azure cairn
#

I've added a second canvas, and now it doesn't seem to recognise when I press button components, No idea why, it's still registering the clicks and I've tried a few things like changing the Graphics Raycaster settings but no luck.

austere grotto
normal parcel
#

Where 2D input?

#

I have right clicked on movement but there is just 1D movement

austere grotto
supple rapids
#

Hello Guys,
we are developing a tower defense game and facing the problem, that our cursor is leaving the screen when scrolling to the edges if people using multiple monitors.
We tried different cursor lock methods but they doesnt seem to work correct.
I think this problem should be solved very easily but i cant find the correct way right now.
Is someone here who can share his/her knowledge with this? 🙂

tame oracle
#

please please please PLEASE someone help i have been working on this for almost 4 days

jagged wyvern
#

Go to player settings and for input chose both

swift lance
#

Hi there, let's say I wish to have a different event if:
-the button was tapped.
-the button was hold.
-the button was released.

Also I wish to know if:
-the button is currently being held

What is the "intended" way of doing this with the new input system ? Multiple interaction Or Multiple Actions ?

The aim is to have:
-Tap: WeaponSwap with Previous one
-Hold: WeaponWheel
-Realease: Close the wheel

austere grotto
austere grotto
swift lance
#

You mean Started Performed and Canceled ?

austere grotto
#

And started/cancelled/performed subscriptions

#

And IsPressed() to check if currently held

swift lance
#

Because Performed would be Hold
Cancled Would be the Tap

austere grotto
#

Try it

#

Worst case you add a second action

swift lance
austere grotto
#

No tap would be different

#

Sorry didn't really see the tap part of your question

azure cairn
worn egret
#

how can i make unity request class if class doesn't implement MonoBehavior?

austere grotto
#

Well for one if it's abstract you're going to need to use [SerializeReference] on the array

#

for two, your class needs [Serializable] to be serialized

#

for three... you're not really going to be able to do this with an abstract class this easily.

#

not without some extra editor scripting

worn egret
#

it won't be abstaract, i just want put abilities inside unit, while all abilities implement Ability.class

austere grotto
#

Ability is abstract

#

so it will be abstract

worn egret
#
  • _ - it - will, implementations wont
austere grotto
#

obviously

worn egret
#

i feel dumb...

austere grotto
worn egret
tame oracle
#

Why is there an entire channel for the input system alone

#

🦈

jagged wyvern
#

because it's complex

nocturne nest
#

I posted this in another section before noticing the input system has its own channel. I am having an issue where my input system is not updating the C# script that it has generated. I have tried a refresh, a reimport, disabling auto save, manually saving, regenerating the C# script, but it will not add my new action map or any changes to the script.

austere grotto
#

If you changed the asset name it may be generating under the new name

#

Also of course check the settings on the asset

nocturne nest
austere grotto
#

check the settings

#

delete the existing script

nocturne nest
#

Tried deleting as well it refuses to automatically generate a new one

austere grotto
#

have you checked the settings on the asset?

nocturne nest
#

By the asset you mean? The input system package or the input handler? I have it set to auto-generated with the right location for the script.

austere grotto
#

The asset

#

As I said

nocturne nest
#

They match up. No missmatched names or anything

pastel pulsar
#

About the UI ToolKit, when I touch the textField, the keyboard of mobile did not pop up through Unity remote. Anyone knows how to pop up it, thank you.

pastel pulsar
#

Sorry,I misunderstood, this is the wrong channel.

native sedge
#

how do i use the new input system

zinc stump
delicate estuary
#

[Qick question]:
Can i get the playerindex from only the InputAction.CallbackContext?

#

i am subscribing the same function to multiple PlayerInputs but the invoke only has the InputAction.CallbackContext as a parameter and i dont know how to get the PlayerInput.playerIndex from there. Or is that not possible?

#

the function needs the playerId

austere grotto
#

in what context

#

is the subscribing object not itself unique per player?

delicate estuary
austere grotto
#

shouldn't the player input be handled on the players, and the players communicate with this script?

delicate estuary
# austere grotto shouldn't the player input be handled on the players, and the players communicat...

that is a question i asked myself as well... the script managing all players could exist and work fine on its own without the players knowing of it. I kinda like this solution because of that.
On the other hand there could be a player component script managing the input-otherScript connection and having clean access to the PlayerInput component. Then the functionality of the other script is coupled to the player components. Idk if i like that design. not sure. Any thoughts?

austere grotto
#

I'm imagining something like this on a script attached to the player:

public void HandleInput(CallbackContext ctx) {
  MySharedObject.Instance.SomethingHappened(this.playerInput.playerIndex, whatever);
}```
delicate estuary
#

the other script has its core functionality and struggling to get the playerinput. I could solve that struggle by handling the playerinput with a script on the player and coupling that with the other script. Kinda like you just wrote.
but it is very possible to keep everything on the other scripts and not change the player at all. The only hangup i got is the missing playerIndex which does not seem to come with the CallbackCOntext

austere grotto
#

to inverse the dependency

#

e.g.

public delegate void MyDelegate(int playerIndex, whatever else...);
public event MyDelegate MyEvent;

public void HandleInput(CallbackContext ctx) {
  MyEvent?.Invoke(this.playerInput.playerIndex, ...);
}```
#

Then have the "other" script listen to this event

delicate estuary
#

ahh, thats quite nice. so basically extending the callback with another delegate layer using additional parameters.

#

cool, ill try that. Thankyoou!

austere grotto
#

Rather than playerIndex it might be simpler just to pass this in the event too

#

up to you

tame oracle
#

However, after getting rid of the multiplication of Time.deltaTime, it still doesn't budge.

#

(Before you ask, I also tried setting the delta to Mouse instead of Pointer and got the same result too.)

digital mural
#

I'm trying to add a "sprint" mode for my character. I want you to be able to hold down space while any of the WASD keys are held down as well. How would I do this correctly? Can I use a modifier or something in my "Move" input action?

timber robin
digital mural
#

@timber robin Ye that's what I ended up doing, thanks

tame oracle
#

Input.mousePosition returns the mouse position on the screen, but I want to know the mouse cords as if it were a gameobject. Is it posiible?

austere grotto
#

"as if it were a gameobject" is vague

#

you presumably want to project the mouse position into the game world

#

but you need to be specific about the "depth" of that projection

tame oracle
#

for example if i created a circle on 4,4,0 and the mouse points on its center, the property would be 4,4,0

austere grotto
#

that's still kinda vague

#

do you want to know where the mouse is on the x/y plane where z == 0?

tame oracle
#

yep

austere grotto
#

Or do you want to know where the mouse is on whatever GameObject it happens to be hovering over

tame oracle
#

everything except the main camera has z as 0 in my game

austere grotto
#

that doesn't quite answer the question 😛

#

but I'll assume you mean the x/y plane then

#

Is your camera projection perspective or orthographic?

tame oracle
#

ortographic

austere grotto
#

ok then you can just use ScreenToWorldPoint

tame oracle
#

thanks

tame oracle
#

so just ScreenToWorldPoint(Input.mousePosition)

austere grotto
#

I'd say do this:

Vector2 mousePos = ScreenToWorldPoint(Input.mousePosition);```
#

that way you drop the z

nocturne nest
#

So I'm currently trying to run through the steps required to fix the input system issue that I am having. After going through everything recommended I tried to delete the C# script again, but it will not generate a new C# script, even with auto generate on.

#

I think I had a naming conflict. Deleting the input system and rebuilding it with a different name allowed it to work fine.

tame oracle
#

OK so new development...

I debugged my script like so:

    // Update is called once per frame
    void Update()
    {
        // Get mouse input
        Vector2 mouseVec = controls.Player.Look.ReadValue<Vector2>();
        Debug.Log("Mouse X: " + mouseVec.x + ", Mouse Y: " + mouseVec.y);
        float mouseX = /*Input.GetAxisRaw("Mouse X") * Time.deltaTime */ mouseVec.x * xSens;
        float mouseY = /*Input.GetAxisRaw("Mouse Y") * Time.deltaTime */ mouseVec.y * ySens;
        xRot -= mouseY;
        xRot = Mathf.Clamp(xRot, -90f, 90f);
        yRot += mouseX;

        // Cam rotation/transformation
        transform.rotation = aimDir.rotation = Quaternion.Euler(xRot, yRot, 0);
        orientation.rotation = Quaternion.Euler(0, yRot, 0);
    }
#

According to the debug, whenever I move my mouse, it's still returning 0 for both axes.

austere grotto
tame oracle
#

I'm such a dumbass.

#

In any case it works now!

#

HOLY SCHMIDT I gotta turn down the sensitivity now.

#

Thanks!

#

BTW... is there a way to interpolate the mouse movement now?

#

'Cuz it feels kinda rough.

tame oracle
#

Huh... I guess it wasn't as smooth before, either.

#

Sensitivity was just a bit too high still.

#

Would still be cool to know about interpolation for that, if it's possible... 🤔

austere grotto
#

lots of games use so-called "mouse acceleration" and I want to die whenever I play one

#

give me 1-1 mouse cursor to look rotation or give me death.

west bloom
#

Hey...
how can i remove the titlebar in unity or change its color to black ?? any ideas

#

or maybe just making it fullscreen ?

river osprey
#

does unity provide facilities to switch between different input contexts

#

like mouse controlling a mouse cursor in ui but player look when the menu is closed

#

or player movement with wasd in one mode but maybe moving a map view in another

#

or is that something I have to implement myself, like an input manager that different layers of my application can attach to or detach from

#

I suppose my input receiver manager could enable/disable inputs on various objects that have InputActionMaps

indigo finch
#

Halo all
I'm using IPointerClickHandler.OnPointerClick, which works, until at some point i add another unity physics scene

I'm doing multi unity physics simulation scene. Each sim scene has an EventSystem object, which gets disabled depending on which scene is the "focus"
Physics.Raycast also doesn't work, btw. Had to do the PhysicsScene.Raycast variant for it to work

So, is there any extra step i gotta do to make IPointerClickHandler work?

austere grotto
austere grotto
#

I've never actually thought about how this works with multiple physics scenes but my assumption is that the camera needs to be in the scene with the physics you want it to Raycast to

indigo finch
#

Yes that's already the case

#

Each phys scene is a replica of the others, already handled the dis/enabling all but the "active" one

#

It's ok tho, end up doing manual physScene.Raycast. A bit more work but reckoned will need the extra control in the future anyways

austere grotto
#

The robust way to handle this would be to make a custom raycaster that uses physics scene Raycast I suppose

final lava
#

Is there anyone here who might have a second to chat with me about a weird issue I'm having with the new Input System? It looks like the input system is not allowing player input (other than movement) when my game manager is in the scene. It's a very weird specific issue with no errors to guide me, and I'm wondering if I could get someone to just hop on a call and look at what I have going on and maybe there is something I'm just not doing

cobalt knot
#

Hey, how can i change in script the EventSystem first selected item ? thanks

neat hearth
#

help, i installed the input package and already have an error, it shows up every time i try to interact with input manager, input manager doesn't work too.

#

ah nvm fixed it

final lava
quartz wasp
#

Does the Input System have a simple way to detect last used device manufacturer? I'm trying to make UI icons that update automatically and the onDeviceChange event is not working the way I assumed it did.

ocean cedar
#

Hey everyone. I've got a bit of a problem. I need my input system to make an action on the button release.
What I do:

#

What I expect:
When I press escape, main menu should open

#

What I get:
The main menu opens and closes like thousand times in a row.

#

What am I doing wrong?

#

I'm using Player Input component in Send Unity Event mode

austere grotto
#
if (context.performed) {
  OpenMenu();
}```
#

note this will happen on button release with that interaction

ocean cedar
#

I don't have a code. I'm using Player Input component from the Unity Input System package. That will not work?

austere grotto
#

oh god you're using SendMessage?

#

don't do that

#

no that won't work

#

It's not PlayerInput that's the problem it's that you're using SendMessage

#

make a proper listener function and call that

#

Also that looks like a totally different action than the one you discussed above

ocean cedar
#

Oh, sorry, that's a bad example))) No, I'm not using SendMessage, I'm calling a function.

austere grotto
#

Then you do have code

#

why did you say you don't have code

ocean cedar
#

Sorry) I've meant I don't receive input through my own code, I'm using PlayerInput.

austere grotto
#

you do receive input in your own code

#

you receive it in the function

austere grotto
ocean cedar
#

Ok, I see. The function I call is input agnostic. It is called through multiple different methods, and it can't have any code related to the input. I was hoping PlayerInput would take care of that for me but apparently not. I'll try to write my own input receiver. Thank you!

idle monolith
#

Hey, I'm trying to do an equivalent to key pressed, I don't want to hold the button down, how my code works now is it takes my right gamepad stick press and I have it switch cameras, but it switches back and forth then I hold the button down, and I don't want that I only want it to detect the initial button press

#

it only takes the button value as a float which I must be doing wrong

#

it said it wouldn't take a bool

austere grotto
full rose
#

guys how do i create repeat script while holding key?

#

like
Mouse.current.leftButton.isPressed

lament glen
#

@full rose write it on update when ispressed true

idle monolith
gilded lion
#

mouse input works on Android phones, right?

hidden elm
#

Is there no way to get the Laptop's Trackpad horizontal/vertical/touches in Unity ?

austere grotto
#

Plenty of ways

#

Unity has full mouse/pointer device support

hidden elm
#

there's no way to detect it using mouse, only thing mouse detects is position click of 1 finger + scroll of trackpad

#

idk about pointer tho

austere grotto
#

What are you asking about

#

what is a "horizontal/vertical touch"?

hidden elm
#

i want to simulate the trackpad pich-zoom and twoFinger-drag of google chrome

#

but i cant detect neither in unity.

#

pinch-zooming in unity of trackpad is mouse wheel

#

nothing more.

austere grotto
# hidden elm pinch-zooming in unity of trackpad is mouse wheel

Learn how to use the new input system to detect pinching in mobile! I'll also show you how to zoom in and out.

📥 Get the Source Code 📥
https://www.patreon.com/posts/46446020

🤝 Support Me 🤝
Patreon: https://www.patreon.com/samyg
Donate: https://ko-fi.com/samyam

Disclosure: This post may contain affiliate links, which means we may receive a com...

▶ Play video
hidden elm
#

Not for mobile

#

For laptop

austere grotto
#

Pretty sure the touch stuff works for trackpad

hidden elm
#

nope tried it, doesnt work

austere grotto
#

idk then

hidden elm
austere grotto
#

I think you will basically need a native plugin per os

hidden elm
#

yea so unity doesnt support it for some reason.

drifting sandal
#

Is there a way to get an InputActionReference by name from an InputActionAsset? Looks like i can get the InputAction, but I want to get the InputActionReference.

austere grotto
#

it's just there to refer to an InputAction directly in the inspector

#

If you're not explicitly making one, it doesn't exist

tame oracle
#

Creating a new InputActions asset just creates a blank file. Here's what happens when I click on it

#

I'm using InputSystem 1.4.4 and Unity 2022.2.0b10

austere grotto
tame oracle
#

Facing a different issue now though

#

I’ve exposed InputAction as a field in some Monobehaviors and I can no longer set the binding form the Inspector

#

I have to click on Properties and do it from that window

fiery ermine
#

hi for some reason this script does not seem to work properly with regards to inpt master. i get a argumentnullexception

public InputMaster controls;



    // Start is called before the first frame update

    private void Awake()
    {
        controls = new InputMaster();
        //Subscribe to interact button press event
        controls.Player.Interact.performed += ctx => Output();
        
    }
    void Start()
    {
        
    }
    

    private void OnEnable()
    {
        controls.Player.Enable();
    }
    private void OnDisable()
    {
        controls.Player.Disable();
    }

Im not sure why it doesn't work as i set it up the same in other scripts

austere grotto
hidden elm
#

Hello, General question.

in unity, if a mouse click happened, would the event of press be dispatched in the next frame or the same frame ? would the event of release be dispatched in the next frame or the frame after it or the same frame?

austere grotto
#

Release will happen in the frame in which it's released

hidden elm
#

interesting. and how is that possible ?

#

does it mean that input is run in // ?

#

also what about mouse position ?

austere grotto
austere grotto
hidden elm
#

nothing nothing i got it thanks

#

( // = parallel 😄 )

austere grotto
#

No the input is basically gathered at the beginning of the frame and the state of it remains the same all frame

verbal idol
#

So I’m trying to implement the new input system, but I can’t find the player input component. I’ve tried three different versions of unity with no luck. Its just not there when I search for it

austere grotto
verbal idol
#

Didn’t know I needed to lol. I’ll get on that

#

Thanks!

misty crow
#

hello i don't know why this isn't working with the shooting method the code is down below

#

do i need to add something in here?

austere grotto
potent thicket
#

I was following Justin's tutorial and but at the moment of adding the XRI Default thing this popped out:

#

and also 20 errors

shadow gyro
#

hi folks i am trying to figure out why, in my blend tree for the animator, it correctly switches between up and down animations (when the y input crosses from negative to positive around zero), however for left and right animations, it sticks to right until hitting exactly -1 for the left

azure oyster
#

Hi guys, How can I rebind composite binding? In movement I have: Left/Right and I want button for each of directions

#

this is code I'm using for normal binding: rebindingOperation = action.action.PerformInteractiveRebinding(3).OnMatchWaitForAnother(0.1f)
.OnComplete(operation => RebindComplete()).Start();

austere grotto
merry parrot
#

Is there any way to use the Touchpad (on laptops for example) specifically? For example registering a two finger swipe gesture

#

I can only find support for Touchscreen

cunning grail
#

Can anyone help me with this?

austere grotto
#

doesn't seem input system related TBH thuogh

olive panther
#

HI! Can someone help me with touch controls? As in explain it to me like I was 5.

I'm trying to implement a simple "Tap this object" touch control. Nothing fancy. No swipes or anything like that. Apparently Unity discontinued the Mouse Click = Touch a while back and I didn't realize this. Anyone willing to help someone who does not understand these docs?

sick stratus
#

Has anyone been able to figure out how to get a "Hold and Release" Interaction to work with SendMessage input? InputValue for a button has literally zero ways of returning useful information except "isPressed" which isnt exactly helpful in determining if the Hold interaction is still held or not, since it only triggers true like, the frame that the Hold condition is met, but immediately becomes false. Can I convert the InputValue to an InputAction.CallbackContext in any way?

EDIT: Apparently, the fix is to set the Action Type to "Value" and the Control Type to "Any." Extremely unintuitive way of getting the value to return true when hold time is passed and return false when the button is released. But it works for me with InputSystem 1.4.4 and Unity LTS 2021.3.8f1, in case anyone else uses the search function to find a solution.

fallow prairie
#

Yo guys I am making a 3rd person shooter controller with the starter asset input package by unity I am trying to make aiming with holding right mouse button but it isn't working I tried by Debug.Log method but it isn't workin

#

I made this method as well on the Starter Asset

olive panther
#

AH! Ok my post was moved into input. Makes sense. I wasn't sure where to post my question. Anyone know about touch who's online?

cunning grail
#

@austere grotto I love you so much

light quarry
#

Hi people! I was wondering how to distribute Action Maps across Input Action Assets and where to attach those assets as components in the scene. For example is it a smart choice to make an Input Action Asset called "MainCharacter" and attach it to the main character prefab? Because I did this, but now I find myself in the situation that I need to disable the possibility to control the main character when the game menu is open and I am not sure what's the cleanest way to do this.

What you people usually do?

#

Should I make a generic Input Action Asset with the "MainCharacter" action map and the "Menu" action map and attach it to both the character and the menu?

lyric geyser
#

Guys can you please help me? I'm trying to make a game and I use Input.GetKeyDown to find out when button was pressed. But Unity keeps telling me nothing like GetKeyDown exists, refuses to run my code and I have no idea what to do. I have the odl player input enabled and it doesn't work.

austere grotto
# lyric geyser Guys can you please help me? I'm trying to make a game and I use Input.GetKeyDow...

Unity keeps telling me nothing like GetKeyDown exists
Read your error messages carefully, they contain important hints on how to fix your issue
refuses to run my code and I have no idea what to do
Again, the errors will likely give you hint. For example "Fix all compile errors before entering play mode"
it doesn't work.
Specific error messages and code etc. would be helpful. We can't help you with vague statements like this.

lyric geyser
#

Whole error message. Input is the script

austere grotto
timber robin
tame oracle
#

why isn't my mouse input being taken.... I am using a keyboard function and a mouse function and only the mouse isnt' working


            PI.PlayerMap.Menu.performed += MenuInput;
            PI.PlayerMap.Fire1.performed += ChangeTargetNext;
            PI.PlayerMap.Fire2.performed += ChangeTargetPrev;

only the first one is working well
as for the 2 functions ChangeTargetNext they'er not... first command i use in the 2 functions is debug... and it is NOT showing

#

this is how I set up the fire1

#

(same for fire2 except right mouse button)

tame oracle
#

anyone who can give feedback would be really appreciated

verbal remnant
tame oracle
#

sorry I was away @verbal remnant

#

I dont know why you're refering to nvidia and vr...
My code's problem is that the controls aren't being performed... only the menu.performed is getting invoked... I dont know what's the cause.. there's no error or anything when I run the game.. which makes it more confusing

verbal remnant
verbal remnant
tame oracle
verbal remnant
#

can you share the code where you enable the action?

tame oracle
#

sure

verbal remnant
#

you are only enabling the menu action

tame oracle
#

the inputmanaging is a game object that's in the scene and inputactions public

verbal remnant
#

call Enable() on the PlayerMap to enable all

tame oracle
verbal remnant
#

the last line in that screenshot enables the Menu InputAction

#

it does not enable the other InputActions

tame oracle
#

oh

#

💀 😒 I am blind... I saw it yesterday I thought it was the inputmap not the menu

#

thank you

verbal remnant
# tame oracle thank you

depending on what your EventHandlers do, you may want to use a more constrained event to detect action triggers, what you are doing there basically eliminates most of the configurability you have with the Input System. For example, if you use someAction.triggered, you can configure exactly how that trigger behaves in the editor.

tame oracle
verbal remnant
# tame oracle I am not sure what you mean... but the current goal doesnt require me to get the...

well, the main point of the Input System is to abstract away that notion of a "button" into a the generic concept of an InputAction. The idea is that your game-logic should not care-about how an action is physically triggered, (e.g. via a button press or joystick actuation or a shaking of the device). You need to clarify what the difference between a button press and a trigger signal would be and whether that is actually meaningful to your gameplay logic, It would probably make sense to make two separate input actions if you need to differentiate a half-press from a full-press or if you want to differentiate keyUp and keyDown.

tame oracle
#

oooooooooooh now I get what you mean.. @verbal remnant thank you

royal badge
# tame oracle

yo tryna learn off of other people's code, is InputActions a class inside of the InputManaging Class? also what is performed, is it using operator overloading?

tame oracle
rich beacon
#

does anyone know how to use a custom input action for "UI/Click" on the event system for basic menu controls?

#

on the event system when i got that warning regarding old/new input system i forgot what i clicked but this basically almost did the whole menu screen navigation

#

but i have another input action i have from another action map i want to put in the Click to basically click a button on my menu but i cant get it to work

austere grotto
random orbit
#

Can someone help me?
I am using the new input system, I have set 2 inputs; one is Vector2(value) for wasd and the other one is bool(button) for space. These inputs are bound to actions and work correctly in the editor. However when I build the game space works but wasd doesnt.

austere grotto
#

You can and should also debug your code in the build

random orbit
#

i will try to debug but are the details necessary when it properly works in the editor?

austere grotto
#

yes

#

they are

#

Some things that can cause differences between editor:

  • reliance on some specific script execution order which is not guaranteed.
  • framerate dependent code
  • reliance on the ordering of a collection returned from a Unity api method which is not guaranteed
    etc... which can only be deduced from looking at the code.
random orbit
#

ok so first of all i am using a state machine that selects a current state(which is a script) and enables it and runs its update methods

#

should i send the scripts?

random orbit
#

Not sure what the problem was but after some debugging and refactoring I managed to fix it. Thank you for the help!

rugged cobalt
#

Hey! Super general question about the "new" input system. Whenever I load a new prefab, I have to redo my PlayerInput Action Maps because they are using editor references.
I am guessing that whenever you spawn a player controlled character you just add to the Start script and update all the references for that correct? Or is there a simpler way to do it that I'm missing?

austere grotto
#

What do you mean by "editor references"

dull mirage
#

drag and drop into the field sort of references

dull mirage
rugged cobalt
#

Action Maps

#

Assuming you set them in C# script when you spawn the Character. Can't really find anything on it. Can you change these at run time? Like what is the correct way to set these?

dull mirage
#

you can assign to unityevents at runtime yes

austere grotto
rugged cobalt
#

What happens if the object they are referencing isn't created yet? Will it trigger an event, or if the object it references is destroyed?

austere grotto
dull mirage
#

its probably better to have a script that searches for this object and sets the unityevent up

#

or even better make a method on this script that gets called by these events inside the prefab

austere grotto
#

In a player input context it's really weird to need to worry about this

#

What are you trying to do

rugged cobalt
#

It's multiplayer. So these Prefabs are going to be spawned in. Setting them in the prefab beforehand will not work.

austere grotto
#

You should attach player input to the player prefab and assign everything to a script on the prefab

#

The playerInput should be part of the prefab

dull mirage
#

^

austere grotto
#

It will work

dull mirage
#

i think the issue is

#

main_Server object is inside the scene

#

thus the player prefab cannot reference it

austere grotto
#

What the heck is main server and why should playerInput care about it

dull mirage
#

in this case attach a script that retrieves a reference when spawned in

austere grotto
#

Is it a singleton

#

Just reference the singleton as usual through the static field

#

No need to hook playerInput callback directly to it

rugged cobalt
#

Oh wait that wasn't it. Can someone show me in Docs how you set those in code?

#

Ohhh I see why you guys are confused now, I'm not supposed to be using these to call functions on other prefabs. I can just have them all reference the PlayerController locally. And from there I can call out to other gameobjects.

tardy apex
#

Guys, I have a problem with Unity

#

Does anyone help me

#

<@&502884371011731486>

timber robin
#

@tardy apex Don't ping people or user groups, it's obnoxious. Ask your question like everyone else and anyone who wants to help, will.

tardy apex
#

Well, I'm sorry, but this problem has been with me for two days

#

When I start a new project it never wants to activate it

#

Tells me failed to create project

late pine
#

Hey im having issues with turning off Soft Keyboard on tmp input field, it's not accepting text at all

night dew
#

Question: I got a class generated from a inputAction-Asset. Can i create multiple instances of those or do these block or clear each others access to inputs?

austere grotto
night dew
ruby rock
#

so i added input system form the pakage manager and then set it as both in project settings but keeps giving me error for getkeydown methods and also evn if i click the old one only still same issue do any one knows whats happening?

ashen mica
#

Can i use the action map i already have for movement for one game object on another instead of creating a new one? Like with broadcast message

tropic dove
#

Hello everyone, not sure if it's the right channel but it's input related 😄

I'm trying to setup some script using the IPointerDownHandler interface.
My scene contains a game object with an Event System and a Standalone Input Module.
My main camera has a Physics 2D raycaster (also tried with the regular raycaster) and a CinemachineBrain (not sure if it impacts anything).
Also, the game object which i'm trying to click on and has the interface attached to has a polygon collider.

I do see my script Start Debug log but nothing ever comes into my public void OnPointerDown(PointerEventData pointerEventData) method.
Any ideas of what i'm missing ?

ashen mica
#

Standalone input module doesnt work with the new input system.thats for the old one

tropic dove
#

oh

ashen mica
#

The one you need is InputSystemUIInput Module

tropic dove
#

Is that a component ? can't find it

#

I got Touch and standalone module

#

oooh god I just saw it

#

It's always hitting the cinemachine confiner collider

#

🤦‍♂️

drowsy bough
#

hi

#

my gamepad goes offline after 2 seconds when i plug in

#

why?

#

i tried 2 different pc 2 different gamepads usb and bluetooth ones its same

#

it can recognize disconnected but i plug in again

#

it gives error about parsing data?

#

??

river osprey
#

I seem to have input actions that are mutually exclusive

#

in one place I create an instance from the codegen-ed IInputActionCollection2 derived class

#

then for a camera using cinemachine's CinemachineInputProvider I use an inputactionreference from the same asset

#

however, if I set autoenable on cinemachine, which enabled the inputaction the reference resolves to, I can no longer use the player movement from the codegen instance

#

if I do not autoenable it, camera movement does not work. if I enable the camera action from the codegen class it has no effect

#

I am wondering how this works

worn wave
#

Hi all!

So at the moment we're removing a certain control scheme from our InputActionAsset with the help of InputActionAsset.RemoveControlScheme
Now the thing is, is that the Unity Input System is still listening to the controls within that removed control scheme.

Is there anything we're missing here?

worn wave
#

@frigid kernel That will result in not executing the action at all, right?

#

Because I still need the action for a certain device.

frigid kernel
#

The action still exists and will handle button presses, it's just not part of the ActionMap anymore

worn wave
#

But then the binding to the action will still exist. OK, I'll get an example.

So we're having a "Mute" action connected to 2 ControlSchemes. XR & Generic XR.

In the XR Control Scheme, the primary button of Oculus is connected.
In the Generic XR Control Scheme, the grip button of a generic XR device is connected.

Now what we want, is that whenever an Oculus device is detected (which we already have made), the Generic XR ControlScheme needs to be removed and not be listened to at all anymore. This however doesn't happen and for some reason, the "Mute" action still has the Oculus grip button connected with it. (next to the primary button)

How is that possible?

remote field
#

this is quite a basic question, but after mapping inputs, how do i make the sprite move?

timber robin
austere grotto
strange lichen
#

What is the point of the Dpad control type vs Vector2 control type?

austere grotto
strange lichen
austere grotto
strange lichen
#

Ohh I see

wicked verge
#

Does anyone know why my controllers are giving constant events (like 500 a second) in the input debugger? Also, my PS4 controller is recognized as both a PS4 controller and an Xbox controller. I get 2 inputs for every key press. I don't use DS4 or any other driver.

austere grotto
#

Otherwise IDK that might just be how it works

#

Are you seeing any weird input data in your game?

wicked verge
#

In game mode, absolutely. If I build the game and run it via steam everything works perfectly. But in the editor, I get 2 separate inputs with my 1 controller

#

On top of that, my switch pro controller gives no input (despite the input debug screen looking identical to the PS4 one. Tons of events.) Works fine in steam though too

woeful cosmos
#

hi, i'm using the new input system, and it seems like the game can only detect 1 device at a time in the editor (the first one hit after pressing play) regardless of how many players are in the game or having auto-switch off. i even manually joined players with specific controls in mind so each stays, but they are still both controlled by the same controller:

var player1 = PlayerInput.Instantiate(player, controlScheme: "WASD", pairWithDevice: 
Keyboard.current);
var player2 = PlayerInput.Instantiate(player, controlScheme: "Controller", pairWithDevice: Joystick.current);

is there any way to make the system detect each device differently for each player? i've gone through several tutorials and i don't think i'm making any progress

split needle
#

Hi! im a student currently trying to debug my project(Level based maze game) , was wondering if i could get some help! Im using the joystick pack off the asset store and have encountered some very annoying issues such as , when i reload the scene like switching levels sometimes the joystick doesnt wanna move my player, the handle moves but my player stands still , theres very little code for this so im not sure what else to try change and ive run out of ideas as this is due monday. I tried setting the coordinate values to 0 in the start but this didnt change anything and made my player angle to one side. Any ideas would be amazing ty

night dew
plain pecan
#

Hi! I'm currently working on a game's UI system, more specifically on the main menu. I want to add button actions to navigate between menus. Most important functionality is when pressing "ECP" or "B" on the controller I would go back to a menu. I see that there is a "Cancel" event, but how can I connect actions or buttons to it? I'm really struggling with event handling in unity rn

split needle
night dew
#

So when you change the scene, none of the old objects stay? And there not multiple ones? Is Object.DontDestroyOnLoad used in the scripts?

split needle
#

the objects stay yes

#

nothing gets deleted

#

and no ive not used that function

split needle
split needle
#

thats the code for the movement itself if that helps

night dew
split needle
#

i just find it odd that it works completely fine the first time its loaded just never again after

chrome hornet
#

how do I use both input systems at the same time?

tardy belfry
#

Why is it greyed out

night dew
split needle
#

@night dew i fixed it! i just forgot to reset timescale back to 1 🤣 😅

night dew
austere grotto
tardy belfry
#

O tysm!

sharp sluice
#

Hey all, XR guys here, i'm messing around with things. I bought the VRIF from BNG, great tool!

Weird issue though, in editor when i play, my sprint control works fine, when i build, it doesnt sprint but seems it registers the input because i see a little skip in movement when its clicked down

#

but im stumped with it

chrome hornet
#

Can someone please help me I keep getting this argument to come up

ArgumentException: Input Button Cancel is not setup.
To change the input settings use: Edit -> Settings -> Input (edited)

ive looked threw my Project settings and can't figure it out

fresh kelp
chrome hornet
dreamy musk
#

Not sure if this is the right channel, but does anyone have a resource they could link that would teach more more about why aiming with a joystick typically "sticks" when the aiming direction approaches either of the four cardinal directions?

coral terrace
#

Hey. I got 2 Gamepads plugged in, but "Gamepad.all.Count" is still returning 0. Can someone help me?

#

The controllers in question do show up in "Devices" in the Input Debugger, but it doesn't change "Gamepad.all.Count".

tired oar
#

i want to run in my game using left shift and right trigger, i have that exept i dont know what right trigger is defined as

timber robin
#

When you're setting the input in the map, you can click the "listen" button and press the button on your controller.

timber robin
tired oar
timber robin
tired oar
coral terrace
dusk narwhal
#

So I'm having issues where my Spacebar is tied to skipping/continuing text in dialogue as well as interacting with objects. Currently, when I try to skip or continue dialogue in front of an NPC, it immediately re-triggers the dialogue by interacting with them.

Will switching to the new input system fix this?

night dew
# dusk narwhal So I'm having issues where my Spacebar is tied to skipping/continuing text in di...

That's a 40 year old issue and the input system can't solve that. You want the player to press space in rapid frequency without delays when he skips through dialogs, so limiting that on the input system level won't help. What you can do is just disable the key for a half second at the end of the dialog. In the new InputSystem you can Enable() and Disable() individual actions and keys easily.

night dew
#

Okay, i am relatively sure there was some debug visualization of the UI with lines that show in which order navigation by keyboard works. What is it called?

coral terrace
dusk narwhal
coral terrace
#

Can someone help me with my Gamepad detection issue?

woeful cosmos
#

sorry, i'm having issues too

drowsy bough
#

hey

#

i am using Joystick everything is good on UI but

#

i can not select anything, when i try with gamepad its select with "X" but in joystick i can not select anything

#

any idea?

#

i can navigate on ui but can not select

sharp geode
#

is there a version of InputField / TMP_InputField which correctly uses input system instead of IMGUI?

austere grotto
#

unless i'm misinterpreting what you're saying

sharp geode
#

because both classes use Event. which is an IMGUI class for gathering keyboard inputs

austere grotto
#

oh for the typing

sharp geode
#

i really need the wojack pulling eyes face

#

i don't understand how components everyone uses are not maintained for years

#

it's ridiculous that instead of using new input system, they use IMGUI instead.

austere grotto
#

IMGUI works everywhere

#

not every project has new input system

sharp geode
#

i mean they have code specifically for input system

#

but instead of wiring it up to the input system keyboard or something like that

#

it uses imgui

#

i assume this is actually because of IME

#

is there some kind of IME event layer for input system?

#

it does

#

so they have no excuse

sharp geode
#

was input system's multiplayer selections ever implemented?

#

like is it actually true that each user has their own selected object? how would you query the player's specific selected object?

#

it doesn't look like it is, it looks like vaporware

lusty perch
#

How do I get continuous input from a gamepad stick? Right now I'm just getting input when the stick is moving, but if I hold it in a set position then I stop getting events from it.

soft swift
#

Hello there!
I'm creating a 2D game which has local multiplayer. I'm using Mirror as well to support networking.
However the Unity Input System is playing up and being weird with split screen and controls
I have 3 Inputs I want to work at the same time locally: An XBox controller, a PS5 controller and Keyboard+Mouse.

When I create the first Player instance, no input is detected.
When I create the second Player instance, the PS5 controller will control it.
When I create a third Player instance, the PS5 controller also controls it.
When I create a fourth Player instance, the XBox controller controls it.

The keyboard input never works.

Each player object has it's own Player Input script, movement and character controller.

austere grotto
soft swift
#

Network.Spawn(gameObject)

austere grotto
soft swift
#

I have one

#

however it does not create my instances (still produces split screen)

#

as I need to instantiate them through Mirror

#

I have seen that there is some way to register my objects with the PlayerInputManager but I have been unable to find how to do this

austere grotto
#

Your player prefab should have playerInput component on it it'll wire it up for you automatically

#

That's the point of PlayerInputManager

#

You can have that prefab spawn the network objects separately and control them

uncut eagle
#

[Unit Test] so I want to simulate mouse click on buttons with this script


            _input.Move(Mouse.current.position, eventButton.GetComponent<RectTransform>().RectTransformToScreenSpace().position, queueEventOnly: true);
            InputSystem.Update();

            Debug.Log("Mouse pos room test: " + Mouse.current.position.ReadValue());

            _input.Click(Mouse.current.leftButton);
            InputSystem.Update();

but the button won't get clicked. is there something that I missed?

austere grotto
#

graphic raycaster on the camera?

uncut eagle
austere grotto
#

canvas

uncut eagle
uncut eagle
#

I've debugged the button position and mouse position. the result is close

austere grotto
uncut eagle
#

yes I know. I've converted it to screen space

#

that's for the mouse position

limber gull
lusty perch
lusty perch
austere grotto
lusty perch
#

Oh, something like this?

public InputActionAsset inputActions;
void Update()
{
    Vector2 input = inputActions.actionMaps[0].actions[0].ReadValue<Vector2>();
lusty perch
austere grotto
#

Would cache the action though

#

You can also use InputActionReference to make that cleaner

lusty perch
#

so reading the value like that in update will get the current position of the stick, even if it's not moving?

austere grotto
#

yes

lusty perch
#

sweet, thanks.

lusty perch
lusty perch
# austere grotto yes

I didn't delete the other actions, will they capture the mouse input and it won't be received by the new one I made? I did drag in the "Look" one to be used by my script.

#

nope, I deleted the others and it still isn't receiving the input.

tropic dove
#

Hello there, I'm trying to use the UI toolkit but I can't click on my gameobjects anymore since the ray always hit the PanelSettings. What did I not understood ? any help appreciated 🙂

#

I have my UIDocument on the UI layer and the raycaster attached to my camera has the "Interacables" event mask, which my gameobject are on

austere grotto
#

inputActions.Enable();

lusty perch
tropic dove
#

Aaaah nevermind, I just setp the pickmode to ignore on my transparent containers

uncut eagle
#

[Unit Test] I want to simulate keyboard buttons to show alphabet in input field


            _input.Press(Keyboard.current.qKey);
            InputSystem.Update();
            Assert.IsTrue(Keyboard.current.qKey.isPressed);
            yield return new WaitForSeconds(3);
            _input.Press(Keyboard.current.wKey);
            InputSystem.Update();
            Assert.IsTrue(Keyboard.current.wKey.isPressed);
            yield return new WaitForSeconds(3);
            _input.Press(Keyboard.current.eKey);
            InputSystem.Update();
            Assert.IsTrue(Keyboard.current.eKey.isPressed);
            yield return new WaitForSeconds(3);

the asserts returns true but for some reason I didn't see the alphabets in input field. why is that?

austere grotto
#

Meaning simulating input system keypresses won't do anything for an input field

uncut eagle
austere grotto
uncut eagle
#

basically I want to validate the instantiated message sent by user. and it requires typing and send so I think I also have to simulate keypresses

austere grotto
#

i would skip the whole ui/typing part of it

#

just send a string through your "SendChatMessage" function or whatever

#

and verify it ends up in the right place

uncut eagle
ashen mica
#

maybe its because i didnt add anything on the collision tile map yet?

austere grotto
#

don't drag things into the script inspector

#

drag them into the inspector of the GameObject that you've attached the script to

#

i.e. your player object

ashen mica
#

ok.i started from the beginning.created the input actions map again and will apply everything again.everything should work just fine.thanks for answering me

#

@austere grotto

gray cedar
#

Has anyone encountered such a problem in Unity "In the Unity editor everything works, but in the build the inputmenager does not work both old and new ?"

#

i need help because i create game to end university 😦

austere grotto
#

To diagnose your specific problem you will have to do some debugging

gray cedar
#

Is it possible to debug the code in build ?

austere grotto
#

yes

#

As long as it's a development build you can:

  • use Debug.Log
  • attach a debugger
gray cedar
#

thank you very much

#

I'm going to look for the problem 😄

night dew
#

Hey. Whats the AZERTY-Version of WASD controls? The same key positions just different keys?

#

If that's the case, the InputSystems ability to set a key position instead of a key should be enough.

wintry dragon
#

I am trying to make simple twin stick shooter controls in 2D

#

the gamepad controls work flawlessly

#

but when i use the keyboard/mouse controls, using WASD or the arrow keys, the movement x/y values randomly reset to 0

#

the same thing happens to the mouse coords, with the character turning to face the origin of the screen (0,0). i've fixed the turning issue, but not the movement stuttering

#

the only solution i've heard of so far is to change the Update mode in the input system package to "process events in dynamic update", my project is already set to this however

#

any tips?

#

wow i fixed that rather quickly. the problem was that in my input actions script, the WASD/arroy key's action type was set to pass through, i set it to button, the mouse pointer i set to value, everything is working fine now

radiant vortex
#

can someone help me with the failed to resolve project template, Failed to decompress.

worldly breach
#

Does the new input system have some built in lerping of value from button presses?

opal rock
#

Hi guys, I've been trying to implement controller/mouse rotation on my playersprite for a while and I've finally done it. Now im just running into the problem, that when i let go of the controller stick, the sprite just rotates to a random(?) rotation and i can't figure out why it's doing that... im using Inputactions Here is my Code:


        lookDirection = value.Get<Vector2>();
        Vector2 objectPosition = (Vector2) Camera.main.WorldToScreenPoint(transform.position);
        Vector2 d = (lookDirection - objectPosition).normalized;

        rotation(d);
    }

    void OnRotationC(InputValue value) {
        controllerPos = value.Get<Vector2>();
        if (controllerPos.x != 0 || controllerPos.y != 0) {
            // Debug.Log("x: " + controllerPos.x + " y: " + controllerPos.y);
            rotation(controllerPos);
        }
    }

    void rotation(Vector2 d) {
        if (d.x != 0 || d.y != 0) {
            float angle = Mathf.Atan2(d.y, d.x) * Mathf.Rad2Deg;
            // Debug.Log(angle);
            transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle-90));
        }
    }```
obsidian skiff
#

is there a easy way to make it so when i press both left and right buttons at the same time, the player moves to left instead of staying still, and the same for upwards and downwards?

silk marsh
#

Ig u could also get player key inputs and then choose what axis to apply force too

obsidian skiff
austere grotto
#

Pretty sure you can do things like "left wins"

obsidian skiff
obsidian skiff
#

i managed to do it with 2 1dAxis things

wintry widget
#

Is there any way to convert a single digit int to a key code?

#

I know that's not how enum's work but there must be some way

austere grotto
#

If that's what you mean

gilded marlin
#

How do I make an action that is on multiple maps? My use case is this: I have inventory button that opens the inventory, and I'd like the same button to close it too, but since turning on the menu disables the Player action map, it doesn't register the Inventory action anymore. I tried just copying the action to both UI and Player maps, but disabling the Player map for some reason also disables the Inventory action on the UI map:

austere grotto
gilded marlin
austere grotto
#

I mean that's clearly not normal

#

Most likely a bug in your code

#

Although depending on how you are setting things up, all of the actions are expected to start out disabled

gilded marlin
#

The only actions that start out disabled for me are any I add to UI or another map

austere grotto
#

Like I said it depends how you're doing things

#

If you're using the PlayerInput component that's expected

gilded marlin
#

I am, but haven't found a way to enable more than one map

#

Ok, finally got it working, apparently the maps are under PlayerInput.actions

mellow wave
#

Hi. Hey. I wanted to program the dualsense gamepad and I can not find property for the arrows on the controller. Most of other keys are there, but those are missing. What is the way to read the input of it? (Using Gamepad.all[0])

mellow wave
#

Ok, solved. I had to use DualShockGamepad. current

ashen mica
#

i did animations with transitions but not in code.could it be thats why the wasd keys and arrow keys are not working?

slender cairn
#

Hey so i have a simple 2d character controller that i got off a video no youtube, the thing is it uses the old input system, what are the things I would have to change exactly for it to work with the new input system??

west oracle
slender cairn
#

thanks! ill check it out

sharp geode
#

how can i get the default keyboard repeat on a keyboard binding for an action? i am fixing tmp input field / input field to use input actions instead of IMGUI events even when in input system is the only backend selected, and i would like a way to elegantly bind to the various input field keyboard control actions. my obstacle is that holding left arrow, for example, does not cause performed to be called as the left arrow repeats on the keyboard

vocal jay
sharp geode
#

let's say i have an action that looks like this

#

it's a pass through key control binding

#

now, let's say i press and hold left arrow

#

i observe this action will only be performed twice: once when it is pressed (key down) and again when it is released (key up), with wasPressedThisFrame wasReleasedThisFrame along with times

#

i expect that the keyboard action will be performed many times: once when it is pressed, again after the short delay until repeating according to the system keyboard repeat delay, and then as frequently as the keyboard is configured to send inputs on repeat according to system repeat rate (i.e. frequency), and then once when the key is released

sharp geode
#

i tried googling and there's just so much noise

#

it's impossible to find a straight answer

vocal jay
#

So you want to have the key keep performing the interaction when held?

#

With some kind of repeat interval

sharp geode
#

i would want it to use the system repeat behavior, which it does correctly for text and not for things like arrow keys

#

but beggars can't be choosers huh

sharp geode
#

but i think i can achieve that using unirx

#

i can fake the repeat... i'm wondering if there's a way to do this correctly

vocal jay
#

If you want to do it with the input system you can write a custom interaction

sharp geode
#

looking at the input debugger it doesn't send repeating events for non-text keys

sharp geode
#

interactions

#

i mean is this stateful? i guess not

#

i can use the start time

#

but i don't get multiple events

#

so i don't think it will work

sharp geode
#

they cannot "select many" on events

vocal jay
#

I wrote a repeat interaction ages ago, and that seems to work with the arrow key as well from testing just now

#

But you are right, it doesn't send repeat events in the input debugger for the arrow keys

sharp geode
#

do modifier bindings work in 1.4.4?

#

they look like they're broken

#

the modifier is ignored

vocal jay
#

You mean like shift + L or something?

sharp geode
#

yes

#

in this case, ctrl+A

#

on a mac

#

which is command a

#

pressing just A causes the action to be performed

vocal jay
#

Hmm, seems to work for me

sharp geode
#

🤦‍♂️

#

does it though

vocal jay
#

It does 😅

#

Do you have another action also bound to a?

sharp geode
vocal jay
sharp geode
#

what version of input system are you using?

vocal jay
#

1.4.4

sharp geode
#

i'm not holding control... this is a nightmare*

vocal jay
#

That doesn't look like your action though? Or is this just formatted weirdly

sharp geode
#

what do you mean it doesn't look like my action?

vocal jay
#

Is OnNext not the action name?

sharp geode
#

no

#

onnext is from unirx

#

are you on a mac?

vocal jay
#

Windows

#

Ctrl + a also works for me

sharp geode
#

oh my god

#

it's calling action.performed with phase disabled

#

🥺

sharp geode
vocal jay
#

I'm hooking up my listener to performed

sharp geode
#

no i'm still seeing a performed phase

#

so maybe it's a macos bug

vocal jay
#

Is your action marked as PassThrough? Because that will basically ignore everything

sharp geode
#

yes

#

what should i choose instead

vocal jay
#

It needs to be Button for the binding to work

#

PassThrough will just pass the state of all registered inputs to the event

sharp geode
#

the composite?

vocal jay
#

So it would trigger on both a ctrl or an a press

sharp geode
#

or the action

#

the action right

vocal jay
#

Only the action should have the InputActionType field

#

Button and Value both run the input through the processing chain, PassThrough ignores it

sharp geode
#

i'm saying should i have this

#

or

#

okay

vocal jay
#

I'm actually not sure what the difference is, I had it set to One Modifier

sharp geode
#

well

#

actually it may have just broke it standby

#

no just breaks it

#

i think this is a mac bug

#

some options make A always trigger Ctrl+A

#

other options make the action never performed

#

regardless of whether i use Command or Ctrl

vocal jay
#

For example?

sharp geode
#

it's a clusterfuck

#

left system is display name for left meta and left command is left meta
One Modifier, modifier left meta, action type passthrough, control type key: "a" fires when left meta not pressed
Button Modifier, modifier left meta, action type passthrough, control type key: "a" fires when left meta not pressed
Button Modifier, modifier left meta, action type button: never fires (meta+a and a and meta do not fire)
One Modifier, modifier left meta, action type button: never fires (meta+a and a and meta do not fire)
One Modifier, modifier left meta, action type value, control type key: never fires (meta+a and a and meta do not fire)
@vocal jay

#

i'm going to try restarting unity

#

okay

#

@vocal jay i resolved the issue

vocal jay
sharp geode
#

apparently the left command key on macOS is actually right system

#

i clicked through Listen

#

man. "build the cube."

#

the correct choice is One Modifier, modifier right system, action type button

#

every time i run into an excruciating unity bug, should i send them a postcard with a picture of the cube in central park with the contents "build the cube"?

#

do you think they'd get it @vocal jay ?

#

lol. what if the cube had the unity logo on it

#

would they get it

#

it would be like the unity cube, but meat colored

vocal jay
sharp geode
#

no, that's how i found out it was right system

#

i hit left command, it gives me right system

vocal jay
#

Ah yeah, that's what I meant, by it "binding" correctly

sharp geode
#

lol

vocal jay
#

So the naming is just off

sharp geode
#

ah yes

#

well it found some key

vocal jay
#

Yeah usually it works pretty well, odd that it is "right system"

sharp geode
#

it did indeed bind and finally work

#

i think because it's an external windows keyboard.

#

like a gaming keyboard

#

ironic

vocal jay
#

Yeah, I don't even have that in my keyboard bindings 😅

sharp geode
#

an even more surprising detail... onTextInput repeats for some text keys, and not others

vocal jay
#

The repeating should only matter if the key is set to PassThrough, if you want to "simulate" repeating keys you should be able to do it with an interaction

sharp geode
#

i managed to simulate repeating for arrows

#

SOME text keys work

vocal jay
#

I can send you my repeat key interaction if you like, I wrote it ages ago so no idea if it's still the "correct" way to do it

#

I tested it earlier though and it still seemed to work

sharp geode
#

for example e does

#

i got the simulated part working

#

e isn't bound to any actions afaik

#

i'm talking about only in InputSystem.onTextInput +=

#

on macos

#

bizarre!

#

i and l do

#

why why why why

vocal jay
#

@sharp geode I'm guessing the keys that are bound to an action don't work?

sharp geode
#

it's random

vocal jay
#

You can try turning input consumption off if it's on

#

See if that changes anything

sharp geode
#

input consumption?

sharp geode
sharp geode
vocal jay
sharp geode
#

uh

vocal jay
#

Project Settings -> Input System Package

#

There's also a long blurb about what it does

sharp geode
#

yeah

#

it breaks the working bindings o..

#

i nixed that

#

the appmana virtual keyboard repeats, whereas the macos native keyboard only repeats on some text letters

vocal jay
#

Hmm, not sure then why InputSystem.onTextInput doesn't work for you...

sharp geode
#

probably IMGUI Event repeats correctly

#

for all characters

#

i'm not sure iether

#

i'm sure if i didn't enable any of htese actions nothing would change

vocal jay
#

Is only the repeating part broken?

sharp geode
#

yes

#

and if i don't enable the actions nothing changes

#

i think it might be a real bug

vocal jay
#

You could try with a custom interaction on a binding that actuates on <Keyboard/Any>

sharp geode
#

yeah but i need the event for the character

#

i might listen for every event

#

and recreate onTextInput and see what happens

vocal jay
#

I guess you could also add all letters to the binding 😅

vocal jay
#

That sounds like a UI question, not an input system question

opal rock
#

Hi guys, I've been trying to implement controller/mouse rotation on my playersprite for a while and I've finally done it. Now im just running into the problem, that when i let go of the controller stick, the sprite just rotates to a random(?) rotation and i can't figure out why it's doing that... im using Inputactions Here is my Code:

void OnRotationK(InputValue value) {

        lookDirection = value.Get<Vector2>();
        Vector2 objectPosition = (Vector2) Camera.main.WorldToScreenPoint(transform.position);
        Vector2 d = (lookDirection - objectPosition).normalized;

        rotation(d);
    }

    //rotation on controller
    void OnRotationC(InputValue value) {
        controllerPos = value.Get<Vector2>();
        if (controllerPos.x != 0 || controllerPos.y != 0) {
            // Debug.Log("x: " + controllerPos.x + " y: " + controllerPos.y);
            rotation(controllerPos);
        }
    }

    void rotation(Vector2 d) {
        if (d.x != 0 || d.y != 0) {
            float angle = Mathf.Atan2(d.y, d.x) * Mathf.Rad2Deg;
            // Debug.Log(angle);
            transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle-90));
        }
    }```
vocal jay
opal rock
vocal jay
#

Yes, it should be higher. I would just use the default values

opal rock
vocal jay
#

Yes, it's an input processor

opal rock
#

oh well that makes things easier xD

vocal jay
#

Ideally if you are using the input system you shouldn't be doing any input processing in your code

#

(unless that code is an interaction, processor, or modifier)

opal rock
#

oof didnt see that until now xD. Works perfect now

#

thanks alot <3

sharp geode
#

not sure why unity hasn't done this already

copper plinth
#

my buttons dont allow me to do anything. the only option i have for pick function is Monoscript

stiff mauve
#

I am an independent game developer creating a game for the PlayStation platform. I am seeking assistance for adding playstation 5 dualsense controller to work with my player!

#

any help is appreciated!

#

to make it easier I am using the FPS microgame as a template at the moment

#

(need reply withtin a few days I dont mind)

limber gull
#

how do i fix this error? im using the newer input system with vr controls

#

@stiff mauvedo u even have ps5 controllers to begin with?

stiff mauve
#

Assuming coding dualshock 4 support could work as well

stiff mauve
#

.

glossy ether
#

Anyone knows what type of data axis control types spits out?

blissful lotus
# glossy ether

Should be a float. Axis allows multiple components to be bound to influence the value positive and negative.

strong knoll
#
button.onClick.AddListener(() => this.PerformRebind(button.gameObject.GetComponent<InputText>()));

When this gets called I get an obejct reference error and I'm not sure how to fix it

stiff mauve
#

I still need help on adding controller support/input to my game

#

I am using the fps microgame as a template hope that helps

void glacier
#

Do all input classes generated by Input System derive from IInputActionCollection2? Can I safely depend on it without one day getting an input class which doesn't derive from it?

austere grotto
#

In the current versions of the input system package yes

fleet kettle
#

why isnt it not working?

#

here

#
using System.Collections.Generic;
using UnityEngine;

public class PlayerControlling : MonoBehaviour
{
    PlayerControls controls;
    float direction = 0;

    public float speed = 3.0f;

    public Rigidbody2D playerRB;

    private void Awake()
    {
        controls = new PlayerControls();
        controls.Enable();

        controls.Land.Move.performed += ctx =>
        {
            direction = ctx.ReadValue<float>();
        };
    }

    // Update is called once per frame
    void Update()
    {
        playerRB.velocity = new Vector2(direction * speed * Time.deltaTime, playerRB.velocity.y);
    }
}
#

that's the movement script

#

any help please?

#

here is some extra stuff

tame oracle
fleet kettle
#

the player doesnt move

#

at all

#

i assigned path for the + and -

#

it still doesnt move

tame oracle
#

You need to read the value in update

#

you are doing it just once

fleet kettle
#

hmm?

#

dont i have it in the update

#

void Update() { playerRB.velocity = new Vector2(direction * speed * Time.deltaTime, playerRB.velocity.y); }

tame oracle
#

yeah but "direction" is set only once

fleet kettle
#

how can i fix it?

tame oracle
#

you need to update it constantly

fleet kettle
#

i hate to ask this, but how do i do that?

#

pls

tame oracle
#

direction = controls.Land.Move.ReadValue<float>();

#

on update

fleet kettle
#

i have that on awake

#

set as: direction = ctx.ReadValue<float>();

tame oracle
#

yeah

fleet kettle
#

alr let me try

#

do i just copy paste it to update?

tame oracle
#

yeah

fleet kettle
#

alr let me try

fleet kettle
#

strange

#

OP

#

fixeed it

#

it was just the speed thingy

#

i had it on 3 and it was suppose to be at 400

#

mb

tame oracle
#

nice then

fleet kettle
#

thanks a lot man

#

u

#

do not understand how much i took for this

#

ty s om uch

#

even without the direction = controls.Land.Move.ReadValue<float>();

#

in the update section

#

it still works, it was all just the speed set at a low rate

tame oracle
fleet kettle
#

also i want this to only happen once you enter a trigger collider beside clicking E

#

does this work?

#

ok it work

tame oracle
#

one thing, you can move the "controls.Land.Interact.performed" to awake

#

i didn't know you could, but it is better there

fleet kettle
#

gotcha

fleet kettle
fleet kettle
#

my game is touch screen

#

and everything works but the animations

#

they dont play

#

left button:

#

right button:

austere grotto
fleet kettle
#

eh im following a tutorial

austere grotto
#

The tutorial tells you to do that?

#

Bad tutorial

fleet kettle
#

welp

#

the tutorial didnt do the animation thingy

#

the one i added

austere grotto
#

I don't understand what the input.keycode bit is supposed to do. Seems completely out of place

#

It also makes no sense to put it there

#

Shouldn't you just be checking if direction is positive or negative?

swift tusk
#

Hey I want to ask if is possible to make Dedicated Server console input reader / handler.

fleet kettle
#

if (direction is postive or negtive)
{
play animation?
}

glossy ether
#

would that be a magnitude?

glossy ether
sudden lagoon
#

so I have playerinput and this little script on same game object:

public void OnClick(InputValue value) {
        Debug.Log("********************** Yoooo point");
        enabled = false;
    }

Idea is that it will run this script once, andafter that disables it self. However this keeps running even if script is disabled, my guess is I failed to unsubscribe it somehow, but not sure how to do it.

austere grotto
#

It doesn't affect anything else really

sudden lagoon
#

Talking about input system... how it is with every Unity update Webgl Input system keeps getting problems with focus again and again. It seems they Fix it, but next update comes, and again, WebGL loses Focus and input system forgets to reset input and your character continues walking without any buttons..... I was sure they fixed it. 2022.2.1 -> it is back again. Saw something about it in 2022.2.2... Lets hope that is the fix.

patent vortex
#

Hi does anyone know how can i get touch input but i dont want ui to register the input.

#

And also i want add a long jump input by holding the touch screen anyidea

sudden lagoon
#

Or at even check if the coordination of touch is over UI or not.

patent vortex
sudden lagoon
# patent vortex Is there a method to check if the user is clicking on ui?

I created check like this, it will be different for you I guess:

private int PlayerUILayer_mask ;
private int UILayer_mask;
private void Start(){
   PlayerUILayer_mask = LayerMask.NameToLayer("PlayerUIMaskName");
   UILayer_mask = LayerMask.NameToLayer("UILayerMaskName");
 }


 public bool IsOverUI() {
   var results = new List<RaycastResult>();
   EventSystem.current.RaycastAll(ScreenPosToPointerData(point), results);
   if (results.Count > 0) {
     var layer = results.First().gameObject.layer;
     if (layer == PlayerUILayer_mask || layer == UILayer_mask ) {
       isOverUI = false;
       return isOverUI;
     } else {
       isOverUI = true;
       return isOverUI;
     }
   }
}

And I call this if (IsOverUI) DoStuff or dont do stuff on every click. This is one of methods, it depends on your project. This is most primitive, as more advanced methods did not work in my scenario.

#

Here there is assumption that your UI is put on different layer.

have in mind this is just one of many methods.

patent vortex
sudden lagoon
#

yes it is, but I needed it to work on multiple types of UI, and when I am using Ui toolkit and legacy UI, normal methods did not work 😄

#

I hope someone else will give you better answer, but at least u will have back up plan

tropic tulip
#

hi guys i have been traumatized by the new unity input system code can anyone send me a ref code so i cn understand it

ashen mica
#

I can

#

@tropic tulip i can also suggest to you to read the manual on the input system on the unity website till you understand it.going by a certain code is just an example but it doesnt teach you the system in a full way.it just shows you one way to write and implement your input action map

woeful hamlet
#

This might go here so I attempted to have selectable ui using arrowkeys but it doesn't work, first selected doesn't work for my ui eventsystem, any clue why?

sudden lagoon
# tropic tulip hi guys i have been traumatized by the new unity input system code can anyone se...

https://assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-196526#reviews

This helped me to understand Player controller, UI controller is bit more simple. This uses SendMessages and is very convenient. Tho UnityEvents in my opinion is easier to understand instead of SendMessages. But in general for controller it is good approach as you can do fancy stuff while intercepting the controller data and adjusting it if needed rather than getting just inputs.

sudden lagoon
topaz galleon
#

Hi

#

is it possible to fire input action from code?

topaz galleon
gleaming oar
#

If you reference an instance of the generated input actions, you can subscribe to any of the inputs you put in there

woeful hamlet
placid gulch
#

Hi, I wonder if anyone already discussed about rebind a key and check if the key is already used?

sudden lagoon
sudden lagoon
woeful hamlet
#

Ill check

sudden lagoon
#

second : make sure your event system is present and setuped

#

and third: in order navigation to work, you first need to press at least once on one of the buttons, or make them selected via code.

woeful hamlet
#

K, My project is loading up

#

I think first selected is supposed to fix that issue

#

Alright w it worked all long my issue is that I thought it would show via highlighted and not selected