#🖱️┃input-system

1 messages · Page 9 of 1

strange bison
#

@fallen waspfor future reference you can get ReadValueAsButton only through the InputAction.CallbackContext type:

strange bison
#

Just dived into the InputSystem code, found the file the handles generating the C# script files.
Right at the top of the file is:

////TODO: option to allow referencing the original asset rather than embedding it

This is exactly what I need! Anyone know when this is going to be implemented?

strange bison
#

This would be the code for it,:

// Original Asset Constructor
writer.WriteLine($"public @{options.className}(InputActionAsset referenceAsset)");
writer.BeginBlock();
writer.WriteLine($"asset = referenceAsset;");

foreach (var map in maps)
{
    var mapName = CSharpCodeHelpers.MakeIdentifier(map.name);
    writer.WriteLine($"// {map.name}");
    writer.WriteLine($"m_{mapName} = asset.FindActionMap(\"{map.name}\", throwIfNotFound: true);");

    foreach (var action in map.actions)
    {
        var actionName = CSharpCodeHelpers.MakeIdentifier(action.name);
        writer.WriteLine($"m_{mapName}_{actionName} = m_{mapName}.FindAction(\"{action.name}\", throwIfNotFound: true);");
    }
}
writer.EndBlock();
writer.WriteLine();

I cant inject it myself and if I modify the asset in the Library folder the package manager notices the discrepancy and restores the original.
Hmmmm

zinc moss
#

Have a question about mobile inputs for a rhythm game. I have a few fixed position, which is a game object that reads input, but touch positions are counted in pixels and game objects are counted in units, how do i convert it?

austere grotto
versed venture
#

@thick bay I found the problem

#

Idk why but like I thought, didn't it react to the y-axis. I changed the y-axis to the one beneth it (3rd axis)

#

Now it works, but reversed, so when I move down, I go up, if I move up with the joystick, I move down

thick bay
versed venture
#

ah yes with the invert enables, does it works perfectly

#

never thought it would come out

#

I was wondering if there's a sort of customable mouse. I'm letting my character move towards my mouse's position, but on ps4, there is no mouse, so maybe I could create a "custom" mouse that could be moved with the right stick?

thick bay
versed venture
# thick bay as long as you configure and get the vaules the same way you do the axis, and ac...

Found a video that'll explain. Hope's it works, so I can play it with my controller.https://www.youtube.com/watch?v=Y3WNwl1ObC8

Make a custom gamepad cursor using Unity's New Input System. This way you can navigate UI using a controller similar to a mouse.

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

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

Thanks GeekZebra for helping make this video possible!
*Sorry for...

▶ Play video
thick bay
#

^ watch out ... this video is using the new InputSystem. so far, you are not. @versed venture

versed venture
thick bay
#

That actually works?! I thought I got a message saying the old one won't work when I installed the new InputSystem package. perhaps I misread.

versed venture
#

it detects both.

#

deam. I think i typed smt wrong and got like 5 errors from the vid

willow patio
#

I was wondering if someone can help me with my movement controls. it's set to just tap, and i want to hold w to move and a and d to rotate using a playership

trim hollow
trim hollow
#

For big existing project it can be useful

willow patio
#

ty for the respond back @trim hollow

zenith valve
#

hey guys how do i put the warning/error message to display on the screen

tough hatch
#

Hi folks! Trying to understanding why my OnUpdate callback (implemented with IInputUpdateCallbackReceiver) is working in one script and not another. Working script is a custom input device derived from InputControl, non-working case is a MonoBehaviour. No errors in either script, but my Debug.Log statement in the MonoBehaviour's OnUpdate doesn't fire at all, whereas the OnUpdate on the input device class fires as expected. Everything else is working just fine in my MonoBehaviour (i.e. Update, Start, custom methods). Any idea what could be causing this issue?

zinc moss
# austere grotto What are you trying to accomplish

I'm trying to make an input system for a rhythm game, I'm currently using a raycast to detect inputs

   if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
            RaycastHit hit;

            if(Physics.Raycast(ray, out hit))
            {
                if(hit.collider != null)
                {
                    Color newColor = new Color(255,0,0,0);
                    hit.collider.GetComponent<MeshRenderer>().material.color = newColor;
                }
            }
          
        }
#

The thing that i am curious is, even I only attach this script in one game object, the other game object will still affected by the touch

edgy notch
#

How can I get a correct value from parameter of function SendValueToControl?
I want to read a non-normalize Vector2 in CallbackContext

#

I use CallbackContext.ReadValue<Vector2> but I just receive normalized vector2

austere grotto
austere grotto
austere grotto
edgy notch
austere grotto
austere grotto
edgy notch
#

I use Desktop and Phone

austere grotto
#

not the computer

#

I'm asking if you're using a keyboard

#

joystick

#

or what

edgy notch
#

Joystick

austere grotto
#

Can you show the code where you read the input data

#

and how you are checking if it's normalized

edgy notch
#

Alright

#

I'm using SendValueToControl like this

edgy notch
#

This is how to I receive value callback

austere grotto
# edgy notch I'm using SendValueToControl like this

Well first off I don't really understand what you're doing here but it seems to have little to do with the input system itself.
Second, you're manually normalizing that vector yourself right on the last line

austere grotto
#

also it seems completely unrelated to the above screenshot

#

so I'm not sure what the connection is

edgy notch
#

Ok, wait

#

I Debug.Log when I send the value to control and then I received it. And this is result

austere grotto
edgy notch
austere grotto
# edgy notch

what do you have for this

        [InputControl(layout = "Button")]
        [SerializeField]
        private string m_ControlPath;```
#

and what is it set to in the inspector

#

and what does the given binding in your action look like in the input action asset

edgy notch
#

I dont understand what do you mean

austere grotto
#

which part

#

you said you copied the custom onscreen control script, right? Share all your code for that.

#

And show what you have set in the inspector for the control path

austere grotto
# edgy notch

and show how the binding for that control path was set up here

edgy notch
#

First, this is control path of my joystick

#

I did want to use the joystick script of Input system, so I add this by myself

austere grotto
#

can you show that

edgy notch
edgy notch
#

@austere grotto Are you being here?

lost valley
#

hi, for some reason when i change the character on my game the input system detects i'm on a gamepad even tho i'm not

#

does anyone know what may be the reason ?

#

default scheme set to keyboard/mouse

#

even without a controller plugged in it gives me this problem

#

the playerinput from the character that works

#

the playerinput from the character that doesn't

#

for some reason it's not recognizing the keyboard/mouse... wtf ?

olive notch
#

New to input system but I've looked everywhere on google but I don't think I've found anything that can apply to me.

essentially I want to use one gameobject to instantiate another gameobject with the same device.

I have a PlayerInputManager create "Object A" when a player joins
I want Object A to create another object "Object B" on a seperate trigger,
I want Object B to have use the same device that Object A uses

chrome walrus
olive notch
#

My issue is i dont know how to connect Object B's input device to be Object A's input device

#

Object A is a used as a character selection object, and Object B is the actual character played

chrome walrus
#

Ah, so they actually do not exist at the same time. You can still have a Player Class that is held active just as a class above the visual representation. So you just spawn your objects with a reference to your player class that is holding the input

olive notch
#

well the game is multiplayer

#

local

#

its a fighting game

chrome walrus
#

It does not matter

#

You question was about how to get the input device to another script. Or are you asking, how to get different inputs to a specific player?

olive notch
#

yea I wanna get the input device to another script

#

Let me lay it out for you

When the scene runs it pulls up a character selection window
When a player touches any button on their device(Gamepad/Keyboard) it will spawn in a "Cursor" Object
When the player selects a character the Cursor object will run a method that spawns the actual character in,
the problem I have is I don't know how to assign the same device to the character.```
chrome walrus
olive notch
#

wdym?

#

yea the function triggers

#

i just have a print statement rn

chrome walrus
#

What does that functino look like

olive notch
#
    {
        skinIndex = rows[rIndex, cIndex].index;
        print(skinIndex);
        PlayerInput p = PlayerInput.Instantiate(manager.playerPrefab, playerIndex: input.playerIndex);
    }```
I was playing with the playerinput instantiation
chrome walrus
#

skinIndex, is that relevant to the input or just part of your code?

olive notch
#

ignore that

#

just there

chrome walrus
#

so charSelect is triggered by what?

#

I would love to see the code for "When player touches any button [...]"

olive notch
#

the "when player touches any button" was automatically created with the PlayerInputManager component.

chrome walrus
#

Ohhh, that class again. yeah I never worked with it, but I am sure, it has some function to hook into. Is there any docs about it?

olive notch
#

do you know how to get the device a player input is using?

#

looking at the debugs and thats all i need now, got it to instantiate with the control scheme and playerIndex, just need to get device

olive notch
#

Yea I think i got it

chrome walrus
#

This should give you the actions you can hook into

#

for each player.

olive notch
#

Yea i went exploring manually in the playerinputmanager class and i got it

#

thanks man

chrome walrus
#

Cool, hope you get along with those events, tell me, if it worked 🙂 Wanted to test out local multiplayer myself soon or later

olive notch
#

ye

stoic oyster
#

Hiya! I'm having this really, really, really weird issue, where you can't use the wasd keys and the mouse at the same time, but you can use the arrow keys and the mouse at the same time. The "nipple" mouse on lenovo thinkpads also works while using wasd aswell as arrow keys. If it matter,s when I refer to mouse I mean touchpad as I'm programming on a laptop, and haven't tested it with an actual mouse yet. It occurs on windows, linux and webgl builds. Anyone have any idea what could cause this?

chrome walrus
stoic oyster
chrome walrus
stoic oyster
#

I have not messed with anything other than that

chrome walrus
#

Ohh, well, GetAxis needs to be setup somewhere in your Input settings. If you setup your axis (or unity things) would be the mouse /trackpad position AND WASD, it will disable the other or override it maybe.

stoic oyster
chrome walrus
chrome walrus
stoic oyster
chrome walrus
#

If I may suggest, you might wanna look into the new input system, if you are not in a hurry with that project

stoic oyster
chrome walrus
slender reef
#

I made portals so when the player collide with the 1st he transport to the 2nd
I made dissolve shader starts when the player collides

(I’m using the new input system)
when I put the player besides the portal then start the game.. press D to move and collide with the portal .. the dissolve does not happen

But when I put the player above the portal and start the game he falls by gravity on portal and the dissolve is running ok

I disabled the new input system and used the old one
everything worked!

can anyone tell me why this is happening?

next hare
#

Have this really weird issue with my inputs. For some reason I can get Vector2 inputs from my wireless switch controller and mouse, but I can't get button inputs from the controller or my keyboard.

#

never mind

#

I'm dumb as hell

#

the triggered functions for those actions aren't capitalized

#

you'd think after 8 years of experience programming in university and work you'd be immune to these kinds of mistakes

austere grotto
paper venture
#

Are the PlayerInput components really necessary for local multiplayer?
Is there no alternative for this?

austere grotto
#

you can certainly do all of your own input device mapping to actions yourself, but it'd be annoying

stoic oyster
#

Hiya! Theres a LOT about this new input system that wasn't covered by the quick guide. For example, when I've created a mouse action as a vector2 value, how do I store that as a variable in my script? Do I need to reference the input manager?

austere grotto
edgy notch
#

How can I get correct value of parameter of function SendValueToControl?

flint snow
#

hi there
quick question, how do you guys structure your action maps?

#

or are there some articles that give some tips to that?

fossil walrus
#

Hello !
Do you guys know the path for PlayStation and Switch controllers ?
I know that for Xbox it's /XInputControllerWindows but I can't find the others :/

fossil walrus
#

If you have a menu, a fighting gameplay and a boat navigation gameplay, you'll have 3 action maps ; they won't override each others

polar timber
#

whats the right way to link ui buttons to the input system for mobile controls, i saw tutorials online and they usually put a on-screen button script and link a gamepad to it, but isnt the gamepad for controllers?

neat jacinth
#

How to get touch id from IPointerDownHandler ? In standalone event.pointerId is actually left, right, center mouse click

olive notch
#

Is migration from local multiplier to online problematic with input system? Or does it require little adjustment?

austere grotto
gleaming oar
#

The case where the input system would differ a lot is if it's a couch co-op local MP game, then switching to online. Still, it mostly has to do with how your MP framework handles multiple players

crimson crater
#

The on screen joystick doesn't appear to work in my project. I can move it but no input is being received by the PlayerInput component, any idea what could cause this?

#

it works fine if i remove the PlayerInput component tho

ripe flower
#

What's the best way of replicating the GetButtonDown/GetButton/GetButtonUp workflow in the new input system? I'm trying to get separate actions to fire on click (function call to queue an item), hold (set bool holding to isPressed), and release (function call to release item).

Am I on the right track in using a Pass-Through action for this?

austere grotto
#

for the moment, assuming you have a Button action, you can get the same exact behavior like this:

InputAction myAction;

void Update() {
  if (myAction.WasPressedThisFrame()) {
    // this is like GetButtonDown
  }

  if (myAction.IsPressed()) {
    // this is like GetButton
  }

  if (myAction.WasReleasedThisFrame()) {
    // this is like GetButtonUp
  }
}```
#

this is with a basic "Button" action

ripe flower
austere grotto
#

you can do it with events, yes. It depends on which event we're talking about. Are you manually subscribing to events, or using something like PlayerInput UnityEvents?

ripe flower
#

I currently just started working off the Starter Asset examples.

austere grotto
#

I don't know how thaose work. Is it using the PLayerInput component?

ripe flower
#

Yes, it is. Kinda hard to explain but there's also a iseparate, state manager-esque script that just sets and unsets bools.

#

Using onX.

#

I'm not sure if it really fits in my use case since I need to trigger stuff on press and release instead of just setting bools.

austere grotto
#

Assuming it's using PlayerInput you can set up a function and do this:

bool isPressed = false;

public void OnGrab(InputAction.CallbackContext ctx) {
  if (ctx.performed) {
    // this is like GetButtonDown
    isPressed = true;
  }
  else if (ctx.canceled) {
    // this is like GetButtonUp
    isPressed = false;
  }
}

void Update() {
  if (isPressed) {
    // this is like GetButton()
  }
}```
#

if they're using the version that looks like this:

void OnGrab(InputValue val) {
  
}``` it's a little tricker and I recommend switching the PlayerInput component from SendMessages mode to UNityEvents mode
ripe flower
#

It's definitely the second version.

austere grotto
#

I'd recommend switching but it's definitely possible in that version

#

you'd have to do something like this:

austere grotto
# ripe flower It's definitely the second version.
bool isPressed = false;

void OnGrab(InputValue val) {
  bool newValue = val.isPressed;
  if (newValue != isPressed) {
    if (newValue) {
       // this is like GetButtonDown here
    }
    else {
       // this is like GetButtonUp here
    }
  }

  isPressed = newValue;
}

void Update() {
  if (isPressed) // this is like GetButton here
}```
ripe flower
#

Gotcha, that makes sense. Part of the issue is that Starter Assets separate the PlayerController from the script that handles "OnGrab".

#

so in the nested if else I'd need to call something in the separate Controller script, which feels kinda gross.

austere grotto
#

or make an event

#

and subscribe to that from the controller script

ripe flower
#

Alright, I'll give that a go, thanks for the help.

full rose
#

guys how do i make shortcut keys?

austere grotto
willow patio
#

i was wondering if anyone can help me with using the new input so I can hold W to move, it's only set to tap and it's kind of a braintwister.

#

please

#

i will literally pay you to sit down and help me with this. im pulling out my hair smh lmao, i've looked over so much yt and google tutorials

#

XD NVM

#

fucking finally got it. just had to turn on my fucking brain

#

but i love it tho ;')

ripe flower
# austere grotto if they're using the version that looks like this: ```cs void OnGrab(InputValue ...

So I went ahead and converted from SendMessages mode to UnityEvents, and the ability to consume an InputAction.CallbackContext over an InputValue is definitely more expressive for my use case. That said, are there any differences between subscribing via lambda like:

_playerInput.actions["Grab"].started += _ => Something();
_playerInput.actions["Grab"].performed += _ => SomethingElse();
_playerInput.actions["Grab"].canceled += _ => AnotherThing();

and handling the logic within OnGrab? Are they functionally identical?

willow patio
#

public void OnRotate() //Action Command Rotate whenever i press A or D.
{
transform.Rotate(0,0, rotationSpeed * Time.deltaTime);
}

#

does anyone know how to make it so it rotates to left and rotate using the new action input

full rose
#

like ctrl rmouse

austere grotto
ripe flower
untold flax
#

How can I convert 2 axis as different values into 1 vector2 input?

austere grotto
blissful lotus
blissful lotus
umbral lotus
#

Is there a way to emulate the old "OnKeyDown" with a PlayerInput component on the new system?
"Press" require releasing the key, "Tap" for some reason re-fire the event if held too long, etc.

austere grotto
#

You don't need any interaction

ripe flower
austere grotto
ripe flower
#

And one could use that in place of OnAction handlers with no major difference in functionality and performance? Is it good practice to use both or one or the other?

austere grotto
# ripe flower And one could use that in place of OnAction handlers with no major difference in...

I think generally if you're using the PlayerInput component you should be using one of its tools:

  • UnityEvents
  • SendMessages

If you're not using one of these then you might want to explore dopping the PlayerInput component entirely. The only exception to that might be if you are doing local couch multiplayer so want to take advantage of PlayerInputManager but also really want to use the manual event subscription style

#

otherwise there are cleaner approaches than reaching into _playerInput.actions such as InputActionReference, a direct InputActionAsset reference, or use of the generated C# code class.

ripe flower
#

Alright that makes sense, no point in player input sending messages or invoking events if you're hooking directly into actions.

umbral lotus
#

@austere grotto
I can get it to work via script, yeah.
What I'm wondering is if you can do it via the PlayerInput component, or if I shouldn't bother with it outside of prototyping.

austere grotto
#

in the script you can check which phase of the interaction you're in

umbral lotus
#

Yeah, but its Editor has a panel to bind directly gameobject's function to actions.
That's what I'm trying to use.

#

Guess I should just not bother with that option and do it the usual way.

austere grotto
#

in those functions you can check which phase of the interaction you're in

#

e.g.

public void MyFunction(InputAction.CallbackContext ctx) {
  if (ctx.performed) {
    // stuff to do when the action is performed.
  }
}```
untold flax
untold flax
#

Or wait couldn’t I just set another random bond value to the vector2 value and use that in cinemachine?

#

For question which update function would I use for that instance

untold flax
#

Also another question what are all the sub commands for a bind for example axis1.ReadValue but what are the others

untold flax
#

would this change my bind value

#

it doesnt but how would i do it

untold flax
#

please help

desert oyster
#

I'm using the new Unity Input System and I think I'm approaching handling events wrong.
I have the example set up where you establish an interface for the Input Map and all of the associated functions. My 'problem' is...well, from there, I'm just using the UnityEvent/UnityAction system and event listeners to say "Hey, a callback exists and here was the data for it."
Should I just be checking the Input uh...InputActions I think directly in those classes that are now listening for the events to just get the data directly and do what I need with it?

compact cedar
#

Hey all, I'm trying to add a new input to the first person starter assets, but even after updating the input actions to contain a new shoot function, updating the starter assets inputs, and adding a debug line to the first person controller nothing is happening. Am I missing a step in creating a new input?

compact cedar
#

It broke because I wrote it as onShoot instead of OnShoot

#

no error anywhere btw, cool system

austere grotto
austere grotto
compact cedar
#

no I mean thats literally what solved my problem. Changing it to OnShoot. The input wasn't registering in game but now it is after that change

quiet tusk
desert oyster
#

Or maybe it's perfect and this is exactly what I should be doing. I have like a 'GameManager' of sorts that listens for the EventManager calls and does what it needs to do with MousePrimaryClick/ActionBarShortcut, etc.

#

I just don't know if I should be bothering with all of this and just have direct references to My InputManager so I can check ReadValues and stuff directly.
I think I understand the system, but I don't know if I'm butting heads with how it 'should' be used.

quiet tusk
desert oyster
#

Are all of those ####.Instance references singletons like how you define Instance on line 6/12?

quiet tusk
desert oyster
#

If so, I MIGHT have complicated things by writing my code in a way that suggests there might be multiple player controllers and such...but that's 100% not going to be the case since I'm developing a turn based game meant for single player sooo. Hmmm

quiet tusk
#

It may not be feasible for you. There are a lot of factors that can prevent you from using singletons. Mine is a single player game.

desert oyster
#

Yeah, I don't think it's unfeasible but also might not be worth refactoring. I basically have a second layer of processing between say...Getting your Fire input and calling for the PaintGun to shoot. It might be unnecessary, but I guess it isn't hurting anything, and otherwise behaves extremely similarly

quiet tusk
#

What I don't like about your script is your strings being passed into your TriggerEvent function

desert oyster
#

It's good to see an example of actual use though besides the mess I'm putting together

#

Yeah the usage of strings isn't great. I should convert all that to an Enum.

#

It's basically saying 'Call all of the functions currently listening for this event (the string)'

quiet tusk
desert oyster
#

Nah, the image was from the InputManager that's just tied to the interface. All of the handling of what to do with those inputs are shuffled through the EventManager and to a Player Handler

untold flax
pulsar scarab
#

Currently trying to call JoinPlayer from PlayerInputManager with OpenXR InputDevices.... but it returns null because playerInput.user.valid is false, What can cause this to be false?

gritty ridge
#

I looked around the internet and couldn’t find a solution to this problem.

Code

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class Combat : MonoBehaviour
{
    private Animator animator;

    private Vector2 kickValue;
    private Vector2 punchValue;

    private void Awake()
    {
       animator = GetComponent<Animator>();

    }
    private void OnPunch(InputValue value)
    {
        punchValue = value.Get<Vector2>();

        if (punchValue.x != 0 || punchValue.y != 0)
        {
            animator.SetFloat("X", punchValue.x);
            animator.SetFloat("Y", punchValue.y);

            animator.SetBool("isPunching", true);
        }
        else
        {
            animator.SetBool("isPunching", false);
        }
        Debug.Log("Punched");
    }
    private void OnKick(InputValue value)
    {
        kickValue = value.Get<Vector2>();

        if (kickValue.x != 0 || kickValue.y != 0)
        {
            animator.SetFloat("X", kickValue.x);
            animator.SetFloat("Y", kickValue.y);

            animator.SetBool("isKicking", true);
        }
        else
        {
            animator.SetBool("isKicking", false);
        }
        Debug.Log("Kicked");
    }

}



#

Error Message

InvalidOperationException: Cannot read value of type 'Vector2' from control '/Keyboard/z' bound to action 'InGame/Punch[/Keyboard/z]' (control is a 'KeyControl' with value type 'float')
UnityEngine.InputSystem.InputActionState.ReadValue[TValue] (System.Int32 bindingIndex, System.Int32 controlIndex, System.Boolean ignoreComposites) (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Actions/InputActionState.cs:2800)
UnityEngine.InputSystem.InputAction+CallbackContext.ReadValue[TValue] () (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Actions/InputAction.cs:1939)
UnityEngine.InputSystem.InputValue.Get[TValue] () (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Plugins/PlayerInput/InputValue.cs:44)
Combat.OnPunch (UnityEngine.InputSystem.InputValue value) (at Assets/Scripts/Combat.cs:21)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
flint snow
#

hi there
how would you guys make a kind of "tab switch" control in the UI?
Like using the shoulder buttons for switching inventory tabs

lost valley
#

hi, i'm using the PlayerInput to handle input and Unity Events, however when i change my character on the selection screen for some reason my input does not work anymore... any ideas why?

austere grotto
lost valley
#

the only thing i'm doing on the character selection screen is changing the player model, they are all the same with different sprites

#

looks like when i add some object with playerinput at runtime the input would not work or something like that

austere grotto
austere grotto
#

That's only something you would do when a new player joins

#

E.g. by connecting a device or something

lost valley
#

so i can't change my player prefab at runtime using the new input system ?

austere grotto
#

You can change your player prefab all you want

#

Don't make PlayerInput part of the prefab if that's what you're doing

#

Again, the analogy for PlayerInput being created is a new device being connected

#

It's one PlayerInput per physical human person

#

Not for an in game character

untold flax
#

Asap

digital narwhal
#

Hey guys, I just updated my input systems to 1.5.0, and everything works as before. But when I went to my Input Actions asset, it showing me this in inspector:

#

I tried adding a new one, and it gives me the same error. Has something changed in 1.5.0 where now it has a different workflow?

#

I read the change log and the docs and didn't find anything about this.

#

What's going on?

austere grotto
#

(even unrelated to this)

digital narwhal
#

No

#

No

#

Like I said, it worked properly and continues to do so, the issue is that I can't add/modify the input actions via editor UI, I would have to do it manually via text editor.

#

I downgraded to 1.4.4 and reimported the file and now it works. I upgrade to 1.5.0 and it gives me the same crap.

austere grotto
#

maybe there's a bug in the new version

#

🤔

digital narwhal
#

That's what I reckon...

#

Just wanted to see if anyone else had this issue? If not, then maybe it's something else I have that would, for some reason, interfere with this...

slate shoal
#

Is it possible to get track/touchpad input?
I need my camera controls to behave differently depending on if input is coming from a mouse or trackpad.
For example a mouse should zoom when scrolling and pan when middle-mouse dragging,
but a trackpad should zoom when pinching and pan when two-finger dragging.

gleaming oar
#

I did this in a game before, I ended up making an input action that included both mouse and touch input

#

and just handled them in their .performed callbacks

#

My functionality had the middle mouse zoom in/out and I wanted to duplicate that functionality with 2 finger zooming. To do this I subscribed to these events from the input actions cs controls.Touch.SecondaryTouchContact.performed += _ => ZoomStart(); controls.Touch.SecondaryTouchContact.canceled += _ => ZoomEnd(); controls.Touch.ScrollY.performed += context => HandleYAxisMovement(context);

slate shoal
#

Thanks for the suggestion. Unfortunately I specifically need trackpad input so the issue is not so much figuring out what to do with the input, rather, it's getting detecting the input in the first place

#

It seems two-finger drag and pinching is translated into scroll delta so I cannot handle them separately.
Pinching aside, I cannot even distinguish from a normal mouse and a trackpad.
I looked for differences in Mouse.current properties when using a mouse vs trackpad and every single property was identical.

neat pebble
#

if I intend for my game to be only on 1 platform, is there any point in using the new input system

austere grotto
#

Being cross platform isn't really a primary selling point of the new input system anyway. Both input systems are

pulsar scarab
#

I'm trying to understand the unity input system here. I am using the JoinPlayer method for manually adding a player to the Player Input Manager within Unity. I am also using the OpenXR Toolkit with this all within a VR game. I first retrieve the 2 VR controllers for the left and right hand with the following code.

ReadOnlyArray<UnityEngine.InputSystem.InputDevice> inputDevices = InputSystem.devices;
List<UnityEngine.InputSystem.InputDevice> selectedInputDevices = new List<UnityEngine.InputSystem.InputDevice>();
foreach (UnityEngine.InputSystem.InputDevice inputDevice in inputDevices)
{
    if (inputDevice.name.Contains("ControllerOpenXR"))
    {
        selectedInputDevices.Add(inputDevice);
    }
}

Then I try to add the selectedInputDevices to the player manager using the Join Player Method, but it doesn't appear to be working and returns null everytime only for the OpenXR controllers. I tried binding my Keyboard and that works fine. Is this due to a conflict with how the current controllers are being used within the XR Interaction Toolkit or something???

playerInput = playerInputManager.JoinPlayer(default, default, "Keyboard & Mouse", selectedInputDevices.ToArray());
pulsar scarab
#

ok... I figured it out.... I gotta have XR Controller in the Control Scheme attached with it

inner anchor
#

I wanna make touch inputs that work also with mouse. I need click, drag and drop and press. What's a good approach?

#

Working with UI elements

inner anchor
untold flax
#

I have a question with converting 2 axis inputs into 1 vector2 input if that makes sense.

For example I have a GameCube (from Nintendo) controller and an 8bitdo gbros adapter to connect it to my Mac. As shown in the images above it shows the controller debug with all its inputs and my input map that I created.

What I’m aiming to achieve is using the C stick (right joystick) for camera movement using cinemachine. Upon placing the axis into the slot for the cinemachine input provider it gives an error along the lines of “axis is not a vector2”. As I’m currently on a cruise I haven’t found much since, other than this GitHub repo (https://github.com/popcron/extra-controllers) which didn’t help as I’m using a gbros adapter and no input gets detected.

I haven’t found anything new other than that and this problem is still here. If anything else do I need to switch to the old input manager as a last resort?

GitHub

Adds support for GameCube controllers to the unity input system along with other controllers - GitHub - popcron/extra-controllers: Adds support for GameCube controllers to the unity input system al...

tame oracle
#

Yes

untold flax
tame oracle
#

Everything

trail adder
#

is it possible to have a "switch" in the new input system?

#

Like I press once its activated, I press second time it gets disactivated etc.

austere grotto
#

Make a button that toggles a bool variable

trail adder
#

like

#

whats the point of input asset otherwise

blissful lotus
#

@grave rapids Let's cover input system stuff here.

grave rapids
#

Thanks, I somehow didn't see this! I've got to do some IRL stuff real quick but I should be back in under 5 minutes.

blissful lotus
#

First of all, are you generating a C# class from your input actions object?

austere grotto
grave rapids
blissful lotus
#

Oh he wasn't talking to you. What does your menu system code look like?

grave rapids
blissful lotus
grave rapids
#

I'm not exactly sure what that means

blissful lotus
grave rapids
#

The function OpenMenu() opens up one menu and closes the rest and is what brings me to my controls menu. However, if you mean the button for changing a control, I am working on the control changing in a second script to keep things organized.

blissful lotus
grave rapids
#

My goal is to create a function which allows me to set one of the controls from InputActions when the function is called. However, I'm not sure how to change an InputAction.
https://hatebin.com/dfsdtfzwwi

grave rapids
#

Exactly

blissful lotus
#

Ooooh, okay. There's a built-in framework for that.

grave rapids
#

Is a framework kind of like a library of accessible functions? I'm not sure that I've used any yet.

blissful lotus
#

https://youtu.be/xF2zUOfPyg8 Check around minute 25 of this Unity tutorial for a good overview of how this works. It's definitely a microcosm of study that's worth a read to understand because there's a lot of filtering that you need to be aware of when listening for key inputs.

Andy Touch, from our Technical Marketing team, shows you how to solve common scenarios when developing a cross-platform game that uses the new Input System. Learn how to quickly switch control schemes, rebind control settings, and connect the Input System with other Unity features.

Speaker:
Andy Touch - Senior Global Content Developer (Unity)

...

▶ Play video
#

Code starts around minute 28, but the concepts are important to understand throughout.

grave rapids
#

Perfect, this seems very helpful. Thanks!

blissful lotus
# grave rapids Perfect, this seems very helpful. Thanks!

Unfortunately, what you write when changing a key has a few dimensions such as device number, key filtering etc. that the system can intelligently handle, but there's some layers to the implementation and it's not super intuitive (imo) if it's your first time looking at it.

grave rapids
#

That makes sense, for some reason when I was searching I couldn't find any relevant tutorials or articles not meant for more experienced users (probably bad search terms due to lack of knowledge) .

blissful lotus
#

One thing that I'd like to warn you about: everytime you use new GameControls(); you aren't referencing the original asset where you store your initial bindings. The C# file you generate actually doesn't read the object at all.

#

@grave rapids To access the asset, you can do something like InputActions.asset or something to reference the original ScriptableObject that opens up in the editor. If you run into problems where you're changing your keys but your game controls don't seem to respect the change, this is likely the cause.

grave rapids
#

Gotcha, so should I generally avoid new GameControls(), or just when doing rebinds?

blissful lotus
#

Just when doing rebinds, otherwise you'll be rebinding an instance. Using new in a read scenario should be fine.

grave rapids
#

Perfect, I'll keep that in mind. Is there any downside to using InputActions.asset over the new GameControls()?

blissful lotus
grave rapids
#

I'm taking a look in the inspector, how is InputActions.asset generally used? Is it something I assign GameControls to, or is it a separate type?

grave rapids
#

Oh, there is a variable type called InputActionsAsset. Is that it?

blissful lotus
#

For you, I guess it would be GameControls.asset.

grave rapids
#

Would that be a modification of the line public GameControls playerControls; or of playerControls = new GameControls();?

#

Or do I forgo both of those lines and just call GameControls.asset whenever I want to acess the game controls

blissful lotus
# grave rapids Would that be a modification of the line `public GameControls playerControls;` o...

For reading, you have to instantiate the class GameControls somewhere, so using new is fine for that. I use a singleton once in my project to make sure I'm always on the same instance like so:

        {
            get
            {
                if (_inputActions == null)
                {
                    _inputActions = new InputActions();
                }
                return _inputActions;
            }
        }```
When I'm rebinding, I get the action using `asset.FindAction(string name)` which returns an `InputAction` object.  That object contains the `PerformInteractiveRebinding()` method which assures that I'm binding on the action from the asset.
grave rapids
#

Are singletons just statics?

blissful lotus
#

So, I read from an instance of the generated class, but I write using the native binding behaviour of the individual InputAction objects, taken from the generated class .asset.FindAction().

#

That ensures I'm not making copies of the input generated class and changing the bindings on copies that don't persist.

blissful lotus
grave rapids
blissful lotus
# grave rapids Alright, so I am trying my best to understand how this works. However, I'm not q...

InputActions is a parameter with separate behaviours for reading and writing. Anytime I read InputMaster.InputActions (the name of my class), I return the value stored at _inputActions, which is a private member. If _inputActions is null, then I call new InputActions() to fill it. This ensures that the first time the member is accessed it creates a new instance of InputActions, then all future read actions just returns the same stored object.

#

There is no "set" because InputMaster.InputActions = new object() is not intended behaviour, so I don't allow it.

grave rapids
#

Alright, I'm reading through what you sent and the properties and this all seems to mostly be making sense. I assume a private member is a variable?

grave rapids
# blissful lotus https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-st...

Okay, I've been looking through the docs for a bit now and I think I am starting to understand it some. This example was provided

{
    private double _seconds;

    public double Hours
    {
        get { return _seconds / 3600; }
        set
        {
            if (value < 0 || value > 24)
                throw new ArgumentOutOfRangeException(nameof(value),
                      "The valid range is between 0 and 24.");

            _seconds = value * 3600;
        }
    }
}```
If I am understanding this correctly, this mean that I can essentially set a number inside of the function (Hours in this case) and/or retrieve a number from inside of the function, correct?
grave rapids
austere grotto
dapper dove
#

Hi all, does anyone have some experience in setting up multiple touchscreens and success in using the both at the same time (think interactive for kids playing at the same time on two screens)?

Ps. Will deploy on Linux but development is on windows, if it would work for both great, but focus is on Linux for now...

trail adder
pulsar bloom
#

Is there a way to get the bindingIndex for a binding immediately after adding it?

#

The return value of AddBinding has a bindingIndex field which has the wrong value in it

#

Okay it looks like I found a workaround for this but it's still weird behaviour/potentially a bug

austere grotto
chrome walrus
pulsar bloom
#

I don't think it's that, because I can see the new binding right there in the array. it's not like it's deferring adding it or anything

#

The workaround was to ignore the return value and just loop through the bindings array on the action until I find the control I want

#

Which is fine, just weird that AddBinding gives this totally incorrect value for no visible reason

chrome walrus
chrome walrus
#

Oh, the function itself is a Binding Syntax, got it

#

How do you do it codewise? Just to see an example

pulsar bloom
#

like int newIndex = action.AddBinding(control).bindingIndex;

#

where control is an InputControl

chrome walrus
#

And what if you just for testing put that in the next frame. Like accessing the index? Does it change?

pulsar bloom
#

I would prefer not to atm because I'm right in the middle of ripping a lot of complicated input code apart

chrome walrus
grave rapids
#

Howdy everyone! I am getting the following errors in the unity console. Does anyone know what I am doing wrong?

ControlCharacter1.Update () (at Assets/Characters/ControlCharacter1.cs:47)```
```NullReferenceException: Object reference not set to an instance of an object
ControlCharacter1.OnEnable () (at Assets/Characters/ControlCharacter1.cs:26)```
```UnityException: CreateScriptableObjectInstanceFromType is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'ControlCharacter1' on game object 'Character1'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject.CreateInstance (System.Type type) (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
UnityEngine.ScriptableObject.CreateInstance[T] () (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
UnityEngine.InputSystem.InputActionAsset.FromJson (System.String json) (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Actions/InputActionAsset.cs:465)
GameControls..ctor () (at Assets/Characters/GameControls.cs:23)
ControlsLogic+GameControlsMaster.get_GameControls () (at Assets/Scripts/ControlsLogic.cs:20)
ControlCharacter1..ctor () (at Assets/Characters/ControlCharacter1.cs:20)

Character controls script:
https://hatebin.com/yeuepszpsw
Controls manager script:
https://hatebin.com/tvnuqyrczs

#

It seems like the line private GameControls playerControls = GameControlsMaster.GameControls; is what is causing the latter problem, however I cannot find what is wrong with it

austere grotto
grave rapids
#

gotcha

austere grotto
#

Don't assign in the field initializer

grave rapids
#

That makes sense

fading field
#

hi, does anyone know a better way to write this bit of code


void Update() {
  if (Keyboard.current[key].isPressed) {
    // do stuff
  }
}```
austere grotto
#

how do you know? You should add Debug.Log

grave rapids
#

https://hatebin.com/nmqpjvcyrt
I've been working on this script for a while now, but I can't seem to get it to work. It throws InvalidOperationException: Cannot reconfigure rebinding while operation is in progress.

#

I thought the problem might be related to it being enabled, but adding actionToRebind.Disable(); did nothing.

#

Oh, it seems like people put the rebind script on the button itself. Maybe doing that will work better.

#

If anyone has any tips or similar for this, feel free to send me a ping and I will respond ASAP.

#

For now I am going to come back to this in a bit, hopefully coming back in a while will give me better insight for the error

austere grotto
#

fovSlider is null

vague gyro
#

Hi! I'm very new to Unity and I'm trying to experiment using the Input System. I have a simple setup with a single InputAction with two maps: Player and Camera. What I wanted to do is to have the player object use the Player map and the camera use the Camera map (I want to use it to toggle camera perspective on key press).

However, this isn't working. Am I missing something or do I necessarily have to have two different InputActions in order to make it work?

#

Right now I have a PlayerInput component both in the player and in the camera object

#

Each PlayerInput is assigned its map and both are set to "Send Messages".
They only work if only one is enabled. If I enable both, nothing works

tame oracle
#

How do i get current active tmp text input (webgl)

tame oracle
#

Without havin to make an on select for each…

grave rapids
lapis briar
#

How can I implement the new input system so that I could move my player to left and right through touch input?

junior arch
#

anyone have some good methods for button prompts, was thinking for a action i could just search through and get the path of the binding

#

and have a lookup table for those paths to icons

grave rapids
#

Is it bad to make each direction of input (MovementUp, MovementDown, etc) a separate action? I'm not sure how else I could use my StartInteractiveRebind script on anything with more than one binding.

#

Never mind, I just need to put in a binding value, that should work if I just add another parameter.

delicate pollen
#

Hey folks, I seem to have forgotten how to set up WASD on a new Input Action. I can't get access to the composite bindings and... I'm getting really confused.

#

I'm trying to do this...

#

...but all I have is this:

rough trench
# junior arch anyone have some good methods for button prompts, was thinking for a action i co...

I believe that implementation is the 'correct' one for dealing with matching a control's name to an icon, especially if you are going to allow rebinding, or an input action/control that is bound to an icon on the screen may change at runtime.
You most likely want to use the 'name' property of an InputControl. The documentation states this for the 'name' property:

The name of the control, i.e. the final name part in its path.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.5/api/UnityEngine.InputSystem.InputControl.html#UnityEngine_InputSystem_InputControl_name

junior arch
#

yeah looks like i will have to do that

#

but handle seperatly buttons by name

#

buttons by position

#

and buttons by purpose

rough trench
rough trench
junior arch
#

do not allow rebinding, but what i bind to in game depends on a few things

#

some cases it will be A and B always since its for stuff like confirm and Cancel

#

but other times i am using North, South, East or West and position matters more

#

since a b x y are all in different spots in switch vs xbox

rough trench
#

Ah.
I haven't messed around much with rebinding (one of the things that I really wanted to take a crack at), but from my understanding is that you can initiate a rebinding operation passing into it a series of either limitations, or requirements.

delicate pollen
rough trench
#

The documentation has this nifty example which seems to do some of it

var rebind = new RebindingOperation()
    .WithAction(myAction)
    .WithBindingGroup("Gamepad")
    .WithCancelingThrough("<Keyboard>/escape");

rebind.Start();

and it also contains an example for excluding

rebind
    .WithControlsExcluding("<Pointer>/position") // Don't bind to mouse position
    .WithControlsExcluding("<Pointer>/delta") // Don't bind to mouse movement deltas
    .WithControlsExcluding("<Pointer>/{PrimaryAction}") // don't bind to controls such as leftButton and taps.

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputActionRebindingExtensions.RebindingOperation.html

#

Does that seem what you require passerby?

#

I may be misunderstanding what you need Reverend.
Now that you have set your Move Action as a Value and a Vector2 Control, if you select to 'Add' a new binding, does it not display the option of an up/down/left/right control?

tame oracle
#

After enabling the input system used in my project to "Both", I am constantly getting 3 of these errors whenever launching the editor, and testing the game:

delicate pollen
#

I'm also missing the options to reduce the stick output to one axis (note the original example I'm copying from is on the RIGHT in the following image):

sly locust
#

hey whats the best input system for Local Multiplayer games? It's just gonna be 1 keyboard and mouse player and up to 3 controller players but idk if i should use the new system or some people reccomend "ReWired"

rough trench
# delicate pollen Hi Matt - sorry, I missed your response. I am getting the option, 'Add Up/Down/L...

Hm... Okay... So, first things first.

There exists Bindings and Composite Bindings. A Binding binds itself to a SINGLE control (a Keyboard Button, a Gamepad Button, or a single Axis Control, such as the mouse Scrollwheel). A Composite Binding can bind itself to two or more controls. (A and D Keyboard buttons for example).

The option to use 1D axis in the Composite Binding can only be enabled if you create a binding that HAS a Positive/Negative Binding (aka, a Composite Binding).
You can only create a Composite Binding for Actions of certain types.

ActionType Button grants the option to create a Composite Binding, however, if you are creating a Move action, they aren't ideal if you want to support Gamepad since moving the Gamepad stick has values between 0 and 1, and Buttons only trigger once if the value crosses the .5 threshold (or whatever value you've defined in your InputSettings asset). For Gamepad Stick support, what you want is to use ActionType of Value.

ActionType Value HAS the option to create a Positive/Negative binding if you select certain control types.
A ControlType of Axis will allow you to create a Positive/Negative binding. When you select this Binding that you just created, you'll be able to change the composite type (which is what you are showing on your first picture there). So that solves your issue A.

With an ActionType Value, and a normal Binding (not a composite one), you can bind that to the Gamepad Left Stick X or Y values. The left stick X can bind to Control types of Axis (you just have to specify if you want the X or the Y axis when you are doing the binding to control), or 2D axis (where you specify to just use the Left Stick itself.

A ControlType of Vector2 allows you to create a Up/Down/Left/Right binding. With that binding you can select WASD as your input keys, and you can select the LeftStick control itself (since the left stick control is a Vector2 ControlType)

delicate pollen
#

That's great info, @rough trench ! I'm in transit atm, but I'll try that info out tomorrow!

exotic urchin
#

I (relatively inconsistently) get these errors thrown. It's not a 100% of the time issue, and as far as I can see in my code it seems fine.

Peeked through the past instances of this in the thread, but either I missed something or the issue itself is something different, typically seems to happen after I update scripts. Is this something "normal" or a sign that there's some sort of issue that's a common thing to find?

#

The weird thing is in regards to some of the lines are kind of nonsense? For example for the CamZoom script, line 28 is just the final curly bracket in the script

light quarry
#

Hi people! How do I detect if a keyboard is present at startup ( in Awake() )?

#

I tried googleing but was not lucky until now

#

(maybe I should ask Bing LOL)

austere grotto
light quarry
delicate pollen
# rough trench Hm... Okay... So, first things first. There exists Bindings and Composite Bindi...

Thank you, Matt. Christ, I should get that information tattooed to my forearm, but I'll settle for saving it in a document. As it turns out, I've learnt all this before, but every time I go back to the Input System fresh I end up confusing myself over the options available from Action Type and Control Type. Switching to Action Type 'Value' and Control Type 'Axis' allowed me to construct the controls as I had originally intended. It's just frustrating to realise I'm not getting better at configuring this system...! Again, cheers for all the advice...!

rough trench
rough trench
exotic urchin
#

Yep, pretty much exclusively related to whenever I've made changes relating to the input system code specifically.
I'm not getting them now, but was more curious than anything else what the general cause would be. The joys of an inconsistent error and all that.

delicate pollen
#
  • sigh * Anybody know how I can check if Unity is seeing my PS5 Duel Sense pad?
rough trench
#

You'd have to post some samples of your code for us to have any idea. Usually missing references to the input system may be because you edited the asset, and it is setup to be saved as a C# file, and it errors out while the c# file is being recompiled.

#

That'd be my best guess without looking

delicate pollen
#

I'm looking at the Input Debugger atm, and while it lists the Duelsense, I don't seem to be getting any input from it. Eg. when I use the 'listen' function in the Input Action window, it's giving me no response.

#

Additionally I'm not getting input from it when running my little test game.

rough trench
delicate pollen
#

Yeah, I'm looking at that right now.

rough trench
#

Try disconnecting and reconnecting it and see if unity prints out in the console that it has recognized it being connected

delicate pollen
#

It does detect that, I tried that earlier (and just now!).

#

...Although it doesn't appear to show up in the Input Debugger now. =/

#

It's listed under 'Disconnected', though I've just had the console message, "Joystick reconnected ("Wireless Controller").

rough trench
delicate pollen
#

Thank you.

#

Might just restart Unity, see what that does.

rough trench
#

"PS5 DualSense is supported on Windows and macOS via USB HID, though setting motor rumble and lightbar color when connected over Bluetooth is currently not supported."

delicate pollen
#

Yeah. It should be supported. And I'm wired, here.

#

On Unity restart, it's found it...

#

...and it responds to the input in-game. So, turn it off, turn it back on again. The Old Ways.

#

Hah. Praise jebus!

potent lodge
#

Hi everyone! My input was working fine (touch on iPhone and the simulator in unity), and then yesterday with literally no changes (I'm using version control so 'really' no changes) it stopped working. I now get this error (and doing this doesn't fix the issue). any ideas?

InvalidOperationException: EnhancedTouch API is not enabled; call EnhancedTouchSupport.Enable()

waxen hull
#

Hey, I am creating a fps view game and I want to add console controller controls but the joystick Y Axis does not work. Is that normal ?

stable parcel
#

I'm making a game with multiple controllers, and every time i reload a script while playing it crashes giving a NullReferenceException when it runs OnEnable, saying controls.Player doesn't exist (which is the control scheme)

PlayerControls controls;
void Awake()
{
    controls = new PlayerControls();

    selector = gameObject.transform.Find("Selector");
    selector.GetComponent<SpriteRenderer>().color = SetPlayerColor();
    terminal = GameObject.Find("Terminal 1").GetComponent<Terminal>();
}
void OnEnable() => controls.Player.Enable();
void OnDisable() => controls.Player.Disable();

Now without reloading while the game plays it works perfectly fine, but i don't think it's supposed to happen and i definitely don't want it happening during build versions

hoary folio
#

How can I make it so the player can change their keybinds through code?

mossy oasis
#

Hello everyone, I am new to unity, I want to know that, How can I integrate Bluetooth in my Unity Game? I have HC-05 Bluetooth module. Please help.

slim reef
hoary cedar
#

Hey! I'm using OnScreenStick with Control Path "Left Stick [Gamepad]" and it's working nicely for movement.
The problem is that I would like to be able to instantiate this On-Screen Stick to the screen position that is touched and get movement (dragging) working immediately without separate touch. I mean, I'm now able to instantiate the stick to desired position but I need to touch&drag it again in order to start the movement. Any tips?

austere grotto
potent lodge
#

Hi everyone! My input was working fine (touch on iPhone and the simulator in unity), and then yesterday with literally no changes (I'm using version control so 'really' no changes) it stopped working. I now get this error (and doing this doesn't fix the issue). any ideas?

InvalidOperationException: EnhancedTouch API is not enabled; call EnhancedTouchSupport.Enable()

hoary cedar
fair plaza
#

For InputAction, I’m trying to make a bullet hell and doing the controls first, I have the InputAction package and I’m trying to figure out action and control type, I’m doing it so when the player presses on the screen, when they drag their finger they can move where the ship is, any suggestions? no mouse controls, finger

zinc stump
#

@fair plaza I pointed you to a tutorial, like an hour ago. Did you bother to look it up?

fair plaza
#

i know how to transform an object instantly from point A to B, but not drag and move

zinc stump
#

It covers virtual joystick drag inputs

fair plaza
zinc stump
#

It has chapters and even points to them in the description

fair plaza
#

I don't actually have to make a joystick do I?

zinc stump
#

Why don't you start by looking it up?

fair plaza
zinc stump
#

@fair plaza You can stop tagging me with useless questions as well. Look up the video. See how it works. Implement it.

fair plaza
#

oh wait it uses applyforce, that wont work for me

zinc stump
#

It takes variable input, how you use it it's your code...

fair plaza
#

ah I meant code wise, I know its basically the code for the rollaball game every unity coder starts with, just not sure how to apply that to a gameobject that wont have a rigidbody

zinc stump
#

You should start with basic tutorials on !learn Preferably Essentials Pathways courses.

sonic sageBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

zinc stump
#

Joystick just gives you Vector2 which input system can normalize for you as well. You need to know how to use it.

topaz elm
#

Hey everyone I have been following https://catlikecoding.com/unity/tutorials/movement/orbit-camera/.
Instead of using the old input system I am trying to use the new input system to make myself familiar with it.

void ManualRotation () { Vector2 input = new Vector2( Input.GetAxis("Vertical Camera"), // <-- using old input system. Input.GetAxis("Horizontal Camera") ); const float e = 0.001f; if (input.x < -e || input.x > e || input.y < -e || input.y > e) { orbitAngles += rotationSpeed * Time.unscaledDeltaTime * input; } }

I found that the default input scheme it generated for me already had Look action defined so i just used it instead. I've added sceenshot of the input scheme.
I also added Normalize Vector2 processor to it which improved it a bit but it's still jagged.

private void ManualRotation() { Vector2 input = new Vector2(-look.ReadValue<Vector2>().y, look.ReadValue<Vector2>().x); const float e = 0.001f; if (input.x < -e || input.x > e || input.y < -e || input.y > e) { orbitAngles += rotationSpeed * Time.unscaledDeltaTime * input; } }

But it gives me erratic results with jagged camera. I know I could lerp the camera movement but I don't want to make it any complex than it has to be.
I also tried finding the Vertical Camera Axis in the input manager settings so i could replicate it in actions which is what i did for wasd movement.
But, I couldn't find it listed anywhere, i've added screenshot of the Input Manager Axes.

I am using Unity 2021.3.5f1 on Windows. I would appreciate any help in this. Here's my full code for camera controller: https://gdl.space/hudatikozu.cs

A Unity Movement tutorial about controlling a sphere via an orbit camera.

austere grotto
#

it is not related to your new input system code at all

#

oh sorry didn't see the second screenshot 😓

topaz elm
austere grotto
#

what is "orbitAngles?"

topaz elm
#

i couldn't find "Horizontal Camera" axis defined anywhere. I though I could replicate it

austere grotto
#

The main difference between the new and old code is that GetAxis does some automatic smoothing

topaz elm
austere grotto
topaz elm
#

by older code i mean older input system

#

Nor did i import any packages from the tutorial. I built it from scratch.

austere grotto
#

You would have manually defined it

#

you probably just forgot about that step

topaz elm
#

Should I put the project on github so people can quickly test it?

topaz elm
austere grotto
austere grotto
#

so you'll need to recreate that smoothing yourself if you want the same behavior

topaz elm
topaz elm
austere grotto
#

it's nothing special

topaz elm
#

Sorry I must have missed it. How do i do the smoothing on the mouse delta i get? I have normalized it but i can't think of any other way then lerping which will drag the camera behind i guess

austere grotto
austere grotto
#

The GetAxis gravity stuff is dead simple

#

it's just MoveTowards

topaz elm
austere grotto
#

I'm not going to download your project

#

Suffice it to say I believe you

#

because there is no input smoothing

topaz elm
austere grotto
#

you can just use MoveTowards to get the same behavior as GetAxis used to have

#
float speed;

Vector2 currentValue;

void Update() {
  Vector2 input = myInputAction.ReadValue<Vector2>();
  currentValue = Vector2.MoveTowards(currentValue, input, Time.deltaTime * speed);
}```
#

"speed" is like "gravity" from the old system

topaz elm
austere grotto
topaz elm
#

i sent the paste link but i'll send it again

#

LateUpdate is where I set the transforms. UpdateFocusPoint is where i lerp the camera to the moving sphere. Sorry for not commenting the code i was following the tutorial

austere grotto
#

shouldn't it be:

Vector3 lookDirection = lookRotation * Vector3.forward;```?
#

right now you're using the old look direction to calculate the new camera position

#

that seems off

topaz elm
austere grotto
#

I would assume you would use the newly calculated rotation to determine where to position the camera

#

it's using the rotation from last frame to do that currently

#

which could easily lead to stuttering / weirdness

topaz elm
austere grotto
topaz elm
#

yeah i'll do that first

#

you know what that fixed it haha. I have axes inverted which i can easily fix

#

Can you explain to my why it was stuttering? why it worked with the old input system? I still don't fully understand it.

trail kite
#

So I'm scrolling through past information but I'm still not grasping it. With this example, what would be the best replacement for Input.GeyKeyDown
if (Input.GetKeyDown(KeyCode.Escape) && canPauseGame == true)
{
PauseUnpause();
}

austere grotto
#

it's not just a 1:1 code replacement

#

it's a totally different approacj

trail kite
#

fml, this new system is so confusing

austere grotto
#

the 1:1 code replacement would be: Keyboard.Current[Key.Escape].wasPressedThisFrame

#

but that's not the "best" replacement

trail kite
#

ok

topaz elm
#

As i know we calculate the orbit angles from the input, which is quaternion of the direciton I am looking at then i multiply it with forwad to get my lookdirection. the position I set using the look direction. and finally set rotation.

#

wait a second. I didn't multiply the forwatd direction -

trail kite
topaz elm
trail kite
#

when you say 'use a function'

austere grotto
trail kite
#

is that in the window I screenshot, or in code?

#

oh ok

austere grotto
#

so you can understand how the event based stuff works

trail kite
#

they confuse me

#

but ill give it another go

topaz elm
#

pause= controls.Player.Jump; pause.Enable(); pause.performed += (ctx) => { if (canPauseGame) PauseUnPause(); };

trail kite
#

._.

topaz elm
#

controls would be C# script generated by input action asset,

trail kite
#

"+= (ctx) =>"

#

that is

#

so confusing to me

topaz elm
#

okay wait a second. Ill send proper code.

#

with screenshots

#

You define the action, it's type is Button as we don't want values

#

Generate a C# class

#

i should use a pastebin

#

That's what I would do

#

i am assumign you're doing the if check in the Update funtion, this way you won't have anything in Update()

#

btw i dunno how i got the Input Action Asset, it was just there when i set it up. I renamed it from Tutorial to PlayerControls

trail kite
#

hmm

#

trying to wrap my head around it all

#

i think i might just be too stupid

topaz elm
#

Yeah, i think of it as an event. I guess the old input system relied too much on checking stuff on each frame. The new input system is I guess event based. You define actions. if they're "event-like" like jumping or pausing you define it as button. then hook a function as callback so unity can call it for you when those actions take place

trail kite
topaz elm
#

it changes how you code 🤔 so there's no 1-1 translation

trail kite
#

and that was ages ago now

topaz elm
#

i thought you could only ReadValue() since it returns float i was doing weird stuff like checking against 1.0f 😄

#

doesn't work properly btw.

trail kite
#

the thing i posted, or the thing you said doesnt work?

topaz elm
#

whoa there's a setter triggered i could have just used it

#

btw thanks everyone :). Have a nice day.

trail kite
#

i saw it in a video i was watching

#

gah, i hate this system!

topaz elm
trail kite
#

yeah for this example

topaz elm
#

if (... get esc button down) { Debug.Log(...) } so something like this would be fine right? You can put the pause functionality inplace of debug log. I guess you want to toggle it as well 🤔

fair plaza
#

I need help, for some reason My touches in my simulator arent being responded, I'm trying to do drag and drop movement like in Bullet Hell gams with the player ship, anything seem out of place as to why my input is noty working?https://gdl.space/iyasavagir.cs

fair plaza
#

Hello, for input action, I’m trying to set up an input action for Android controller, would that be press or hold?

clever relic
#

why there is no vectors?

austere grotto
clever relic
hexed inlet
#

Anyone ever successfully use QueueDeltaStateEvent for a custom device?

wraith kraken
#

Hey there! I am a student and planning to make my first mobile game in unity...my previous games were all pc and controller based and all were made with legacy input system so I thought to give input system a try but it feels pretty overwhelming compared to legacy input system....Since the input system is best for controllers and crossplay options is it worth it to learn all this for touch inputs or shall I use legacy inputs for this touch controlled mobile game?

fair plaza
#

this here is code for my player movement, I'm doing a touch based player input, any suggestions on how to put a limit on how far the player can go on the screen? so my player doesnt go off screen https://gdl.space/zaxiyedife.cpp

austere grotto
fair plaza
austere grotto
#

e.g. setting velocity or using AddForce

fair plaza
austere grotto
fair plaza
chrome pendant
#

how do i make the button press so it only registers once when pressed down?

it registers if i press and hold it and i dont want that

remote radish
#

I think my favorite features have been free events and the fact that it supports control bindings automatically, and lets you set new ones with one function

#

Overall its nice to use i think

austere grotto
potent lodge
jolly maple
#

how would one go with making a double jump and hold to jump higher script with the new input system?

#

cant really find tutorials for it

austere grotto
jolly maple
#

sorry

trail kite
#

Hi friends, when I jump a single time it's immediately using up the bonusJump token, rather than waiting for another input. And logically I understand why, but I don't know how to fix it. I tried creating a new function called BonusJump and binding it to the same button, but same issue persists.

#

Looking online i might be able to use something like playerControls.Player.Jump.IsPressed, ill have to give it a go

loud wharf
#

Hi all i want to create vr car race game for oculus secondary thumbstick pressed up car move forward, thumbstick pressed down apply break smoothly how i can map thumbstick controller key binding for specific action

blissful lotus
#

context should have a phase enum where you can determine what phase of the input action invoked Jump(). You probably want to narrow for Phase.Started.

trail kite
gray wadi
#

hello, I use the events, and I would like to run the event on all the Item.cs scripts in my scene but the function is not showing when I select the script.. How can i select all the scripts instances without put one by one the object reference..?

#

this si the function in the Item class

austere grotto
gray wadi
#

Thank you

oblique elm
#

I am trying to use Touch input for my game so I am just testing if it works by checking if (Input.touchCount > 0) but this condition never becomes true. So this means that there is no touch input right? I don't want to use the new input system so is there something I need to do in order to get this to work

austere grotto
oblique elm
#

Then how can I fix it, like, I am using my mouse's LMB for clicking

oblique elm
austere grotto
oblique elm
spark spire
#

Hey guys, I am trying to make a test class for testing my inputs however when I try to inherit the class from InputTestFixture it says that the class is missing...

#

Is there any workaround for this?

#

I have added the "com.unity.inputsystem" under the "testtables" section in manifest.json

spark spire
#

However, it seems like my mouse click and movement won't get simulated in the system... it won't print the statements which i wrote when the UI element gets clicked ,could there be a reason for this?

upbeat sand
#

Does anyone experienced the bug that although added controller and keyboard functions to your inputSystem, only one gets read. And this is completely random? xD I have no idea how to fix that. Please @tame coyote me if you know how to fix it 🙂

spark spire
polar timber
#

im trying to make it so that when i tap the space key i jump once, and continuously jump when i hold down the space key, but only the tap input is working and the player doesnt jump at all when i hold down the space key, how do i fix this?

gray bloom
#

what script are you using to trigger the jump method?

polar timber
#
private void jumpInput(InputAction.CallbackContext context)
    {
        if (readyToJump && grounded)
        {
            readyToJump = false;

            Jump();

            Invoke(nameof(ResetJump), jumpCd);
        }
    }
polar timber
#

jumpCd is set to 0 for testing

gray bloom
polar timber
#

oh

spark spire
#

Hey guys, is it possible to simulate keyboard inputs (such as typing with keys) for UI testing with InputTestFixture?

lyric turtle
#

So I'm having an issue when using the input system, that prevents my player character from moving the way I want. I am using Invoke Unity Events to call this function. But instead of allowing my character to walk continuously in whatever direction the player wants to move, it just moves a bit then stops.

public void MovePlayer(InputAction.CallbackContext context)
    {
        var value = context.ReadValue<Vector2>();

        Vector3 direction = new Vector3(value.x, 0f, value.y).normalized;

        animator.SetBool("Walking", true);
        float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + mainCamera.transform.eulerAngles.y;
        float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnsmoothVelcoity, turnSmoothTime);
        transform.rotation = Quaternion.Euler(0f, angle, 0f);

        Vector3 movedirection = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
        controller.Move(movedirection.normalized * walkspeed * Time.deltaTime);
        Debug.Log(movedirection);
        if (context.canceled)
        {

            animator.SetBool("Walking", false);
            return;
        }
    }```
vital idol
# lyric turtle So I'm having an issue when using the input system, that prevents my player char...

couple ideas:

  1. Check the input system configuration: Make sure that the input system is correctly configured to recognize continuous input from the player. For example, if you are using a joystick or a gamepad, make sure that the axis values are mapped to the correct input actions and that the axis values are continuous. If you are using keyboard input, make sure that the input system recognizes key press and key release events.

  2. Check the Invoke Unity Events: Make sure that the MovePlayer function is being called continuously while the input is being held down. If the function is only being called once, then the character will only move a bit before stopping. You can check this by adding a Debug.Log statement inside the MovePlayer function and checking the output in the console.

  3. Check the controller input values: Check the values of the direction vector and the movedirection vector to make sure that they are being calculated correctly. You can add Debug.Log statements to print the values of these vectors to the console and check that they are what you expect them to be.

  4. Check the walkspeed value: Make sure that the walkspeed value is set to a value that allows the character to move continuously. If the walkspeed is too low, the character will move slowly and may stop after a short distance.

  5. Check the controller.Move function: Make sure that the character controller is moving the character in the correct direction and at the correct speed. You can add Debug.Log statements to print the values of the movedirection vector and the walkspeed value to the console to check that they are what you expect them to be.

lyric turtle
#

Well, I did assume it might be option 2, and it is only being read once, but I'm not sure how to go about fixing it.

#

or rather

#

MovePlayer() is being triggered three times with the same values. But seemingly only moving my player once.

vital idol
lyric turtle
#

Ofc

stable parcel
#

for the life of me i cannot figure out how to explicitly state which input devices to pair with which player input components, it seems to just choose the first device available instead of the ones i want

#

i'll have a keyboard and two gamepads, and sometimes i might want to use two gamepads instead of all three or a keyboard and gamepad but it seems like i have no control over that

vast portal
stable parcel
#

i actually wasn't using anything but i'm wondering does it add a device or make that the only device that can use that instance of a player input

loud wharf
#

I want move a car when Oculus secondary thumbstick pressed up how to bind controls in unity

alpine wraith
#

Hi can I get some help, I tried to click the world space canvas with the WMR controller, but the button never reacts when I pull the trigger or any other buttons. What should I do?

sleek bear
#

I'm having a problem with the new Input System, I just want to switch from tiles to tiles in my UI Menu, but for some reason when I decide to go left, it calls the function multiple times and continues to go left until there's no more "Left Tile" left (no pun intended).

for the record, it does not just jump from the right one to the left one, it goes inside the middle one and immediately goes to the next left one.

#
private void Awake()
    {
        controls = new InputControls();
        updateTileStyle();
    }

    private void OnEnable()
    {
        controls.TiledMenu.Enable();
        controls.TiledMenu.RightTile.performed += moveToRightTile;
        controls.TiledMenu.TopTile.performed += moveToTopTile;
        controls.TiledMenu.BottomTile.performed += moveToBottomTile;
        controls.TiledMenu.LeftTile.performed += moveToLeftTile;
    }

    private void OnDisable()
    {
        controls.TiledMenu.Disable();
        controls.TiledMenu.RightTile.performed -= moveToRightTile;
        controls.TiledMenu.LeftTile.performed -= moveToLeftTile;
        controls.TiledMenu.TopTile.performed -= moveToTopTile;
        controls.TiledMenu.BottomTile.performed -= moveToBottomTile;
    }

    private void moveToRightTile(InputAction.CallbackContext ctx)
    {
        if (!isSelected || rightTile == null) return;
        unSelectTile();
        rightTile.GetComponent<TileManager>().selectTile();
    }
    
    private void moveToLeftTile(InputAction.CallbackContext ctx)
    {
        if (!isSelected || leftTile == null) return;
        unSelectTile();
        leftTile.GetComponent<TileManager>().selectTile();
    }
    
    private void moveToTopTile(InputAction.CallbackContext ctx)
    {
        if (!isSelected || topTile == null) return;
        unSelectTile();
        topTile.GetComponent<TileManager>().selectTile();
    }
    
    private void moveToBottomTile(InputAction.CallbackContext ctx)
    {
        if (!isSelected || bottomTile == null) return;
        unSelectTile();
        bottomTile.GetComponent<TileManager>().selectTile();
    }
sleek bear
rough trench
#

Actually, nevermind, it is.

The issue is pretty simple.

#

You have the following execution order
RightTile
MiddleTile
LeftTile

each of them will try to execute one of these actions you've setup with every input you make at the 'same' time.

The problem comes from the fact that each of them is attempting to move left on their own, and because of the execution order, it seems like the selection jumped too far.

The step by step of what's happening is, when you have the RightTile as the isSelected = true.

RightTile reacts to your LeftTile action and executes a move left. That means MiddleTile isSelected = true.
MiddleTile reacts to your LeftTile action and executes a move left. That means LeftTile isSelected = true.
LeftTile reacts to your LeftTile action and does nothing because its leftTile property is null;

If you move in the opposite direction (right) starting from the left tile, in the background, what is happening is

RightTile reacts to your RightTile action and does nothing because it is not selected.
MiddleTile reacts to your RightTile action and does nothing because it is not selected.
LeftTile reacts to your RightTile action and executes a move right.

#

What you need is instead of having each tile receive the input and attempt to move on their own, you need a controller script that will receive the input, know what's the currently selected tile, and attempt to move left or right based on the currently selected tile's left/right/up/down tiles, and then deselect the current tile, and select the new one

#

It's pretty much the same behaviour as Unity's UI EventSystem and its Selectables.

sleek bear
#

ooooh I see, it makes sense, thanks a lot for the explanation @rough trench 🙏

stable parcel
vast portal
stable parcel
#

yyep

vast portal
#

You should test it out! I can't be of much help at this point

glass yacht
stable parcel
#

ah okay

#

actually earlier I was using PlayerInput.Instantiate with controlScheme/pairWithDevice as parameters and it seems to work fine, but if there's only one player then anyone can control that player

#

if there's two or more then that device only works for that player and other devices don't interfere

grave rapids
#

Howdy folks! Is there a way to get an action map from a static Input Action Asset based on a string? I can't seem to figure out how/where to use something like FindActionMap.

#

I can of course directly search for the binding, but some bindings (eg. between players) share names and I'd assume there is a more elegant way of finding the map than just naming my InputActions things like Player1Movement and Player2Movement.

#

(I am also fine with using an ID or whatever for getting the InputActionMap - I just can't seem to access it at all at the moment without a direct reference like controls.Player2.movement)

grave rapids
#

Alright, I think I figured out my problem. I'm not completely sure why, but when I use controls.asset.actionMaps that gives me what I need. I'll be doing more searching to figure out exactly why it is like this , but I should be all set on my own without help for now.

wide marten
#

hi, thank you in advance.
I am going to make a floatingjoystick using new inputsystem.
who can help me?

#

I am searching in google but not found.

#

there are some useful youtube but they don't show me FloatingJoystic.cs from Llama Academy.

#

If you have FloatingJoystick.cs, please send me.

austere grotto
wide marten
#

it's not productable, I think

#

there should knob, background at least and should be floating,

#

I want to control character by touching any position of screen.

#

@austere grotto make sense what I want?

#

Please help me

austere grotto
#

Not sure what "not productable" means

wide marten
#

🚨Synty Humble Bundle LIVE NOW through March 16 2023: https://www.humblebundle.com/software/syntys-polygon-game-dev-assets-bundle-3-software?partner=llamasoftware&charity=2280172 20 high quality, popular, low-poly style packs for as low as $25!🚨 This week you can learn how to add a Touch Movement Joystick to control your player using the New Inpu...

▶ Play video
#

this video show how to use FloatingJoystick.cs but now show the source code of FloatingJoystick.cs

fierce pulsar
#

the new input system doesn't really work in webGL - it works on windows and play mode

#

so I have 2 players both set to 1 input system file

#

In it I have Move, Jump, Teleport, and then I copied them to rename them (Move1, Jump1, Teleport1) and changed the keys

#

they I made one player work on Move, Jump, Teleport and the other on Move1, Jump1, Teleport1

#

like I said it works in play mode and on windows but just not webGL, any help?

#

also Move, Jump, and Teleport is WASD and Move1, Jump1 and Teleport1 are arrow keys
ping me

vivid yew
#

how do i get gyroscope for Xbox/PS4/Switch Pro controllers with new input system?

woeful inlet
#
public override void SetMoveValue(InputAction.CallbackContext input)
    {
        Vector2 moveInput = input.ReadValue<Vector2>();

        Vector3 moveDirection = transform.forward * moveInput.y + transform.right * moveInput.x;

        moveValue = moveDirection.normalized * speed;
    }

so i hooked this function in a unity event but the player keeps moving the in same direction until the key is released,any idea why this is happening and if it is the fault of the input system or another system?

rough trench
#

That's the expected behaviour of the system.
When an action is performed/executed/cancelled, the method is called, and the moveValue is updated.
If you have an Update function that moves the player based on move value, the player will be constantly moving since moveValue has had its value set to the input.
Once the key is released, moveValue is returned to 0

vivid yew
#

Why is my friend's Switch's Pro Gamepad Gyro detected as Right Analog Stick?

#

Or more rather, how to disable it?

#

does this also work for Gamepad's sensors?

#

(in pc ofc)

woeful inlet
hazy condor
#

how can I attach my joystick to move my guy

#

the red dot being the stick

twin oak
rough trench
#

You would have to update your moveValue in update to the updated transform.forward

woeful inlet
#

okay

woeful inlet
rough trench
#

You will have to use the transform.forward in your Update method like I mentioned.
In your setup, maybe I'd create a method 'CalculateMovementValue' that returns the moveValue from your inputbase, and you'd pass the transform of the character controller as a parameter

#

Can't help much atm, working atm.

crisp star
#

How important is it to unregister callbacks to InputActionAsset during exiting playmode?

#

I don't use generated C# class, I reference asset directly

#

through inspector

foggy dust
#

I'm wondering how to work this with a mouse focused strategy/sim game. Like If I want to select a tile or a an ui button, would I have one script that checks what I clicked on and then call the "clicked" method on my target. Or do I need a different approach for ui and other gameobjects? For UI there seems to be the "OnScreenButton" script available.... but i think that is only intended for mobile stick+a/b button like stuff and you should not use it for other ui elements. Implementing IPointerDownHandler etc. seems to be the new input way for ui stuff, it wouldn't work on tiles/gameobjects right?

austere grotto
#

And yes they work for non-ui

#

For tilemaps there will be an extra step of determining which tile you clicked on inside the OnPointerDown.

foggy dust
#
    {// Get the current mouse cursor position in screen space
        Vector2 mousePosition = eventData.position;
        // Convert the mouse position from screen space to world space
        Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition);

        // Convert the world position to a cell position in the tilemap
        Vector3Int cellPosition = tilemap.WorldToCell(worldPosition);```
#

like that right

#

as a script on the tilemap

#
  • tilemap.GetTile(cellPosition);
austere grotto
#

not this

#

eventData contains the world position in it

#

you don't want/need to calculate it yourself

#

So you can just do this directly:

Vector3Int cellPosition = tilemap.WorldToCell(eventData.worldPosition);```
foggy dust
#

aaah how do i copy from this mouse over ? 😄

#
        Vector2 worldPosition = eventData.pointerPressRaycast.worldPosition;```
austere grotto
#

oh sorry:

Vector3 worldPosition = eventData.pointerCurrentRaycast.worldPosition;```
#

then:

Vector3Int cellPosition = tilemap.WorldToCell(worldPosition);```
foggy dust
#

the collider on the tilemap doesn't seem to work correctly but it is registering the click so thank you!

languid isle
#

Does anyone have an idea of how did they do warthunders instructor? Did they use PID controlers?

lost valley
#

hi, for some reason the UI is not changing based on the D-Pad input some times, is this a known bug or what ?

#

here's a video of me pressing the D-Pad to move through my UI on a DS4 controller, even tho the Input Debugger shows that i'm pressing the D-Pad down it does not affect the UI some times, having to press up to 3 times so the UI can change the navigation properly

#

on joystick navigation i don't have this issue at all

swift quiver
fair plaza
past pecan
# lost valley

This has absolutely nothing to do with unity, but by chance could you dm me how you make obs make that screen effect

bold jackal
#

how do I return which number I pressed with code?

#

is there anything like context.button?

ruby spire
# bold jackal is there anything like context.button?

You should be able to do this. Autocomplete shows the following:

UnityEngine.InputSystem.InputAction.CallbackContext context;
var pressedNumber = context.action.bindingMask.Value.path;

All you need is to attach an event handler to your Switch action.

bold jackal
ruby spire
manic pelican
#

I got the input system working with VR hand animations today lol

#

it was fun

narrow fractal
#

Hello!
I am trying to use the new Input System. I plugged in a Gamepad and Unity recognised it as a USB Joystick. I can navigate through the UI with it, but when i press Button 2[USB Joystick] on a UI Button nothing happens

#

In the DefaultInputActions i added a new binding for the Click action, but with no success

#

Did I miss something? Any tips on what should I try?

gaunt cedar
#

Has anybody done any dev work with the steam deck? I'm trying to figure out the axes of the RT and LT triggers. They're working fine with an Xbox controller in windows.

inner star
#

Is there any way i can make certain buttons happen regardless of if a player has joined with a Player Input Manager?

inner star
#

anyone

narrow fractal
viral flicker
#

How can I do a charge up with the new input system? I'm using unity events and I want to know how I can record how long I'm holding down a button to charge an attack

austere grotto
viral flicker
#

how would i use a timer?

#

i was just thinking of like increasing a value while its held down, and when its released you check that value

austere grotto
viral flicker
#

so like if im charging a railgun shot that has a chargeup time of 2 sceonds

austere grotto
#

None of this is really input system related

#

the input system will tell you when the button is pressed and released

#

the rest is up to you

viral flicker
#

isnt there a state for held?

#

im using callback context

#

theres like ctx.performed and canceledd

#

theres one for held down

austere grotto
#

so it depends on if you're using event-based input handling, or polling.

viral flicker
austere grotto
#

but your code could literally be doing anything

viral flicker
#

how about this?

austere grotto
#

so yeah looks like you're using events

#

in this case you need to either:

  • start a coroutine when the button is pressed and stop it when released
  • set a bool true (isChargingWeapon) and timer to 0 when the button is pressed, update the timer in Update, and handle the release when the button is released
viral flicker
#

and same when i die

hazy condor
#

I have a little red box that moves when you touch it, and I have it in a on screenstick mapped to the left stick

#

how do I get this into a script

#

i have the basic move

#

mapped to wasd

deft berry
#

i'm guessing that means you didn't bother reading what i said past linking this channel. you may also want to see #854851968446365696 for how to correctly ask a question

tame oracle
#

Ok so i set all the values correctly and unable to find the 2D Vector composite any help ?

deft berry
#

remember how i already told you it's the up/down/left/right one in the options when you go to add a binding?

tame oracle
deft berry
#

show what options you do have then

tame oracle
#

I cant when i tab into my snipping tool i cant see the options are we able to go in a call you do not have to speak its just so i can show you?

deft berry
#

set a delay with the snipping tool

tame oracle
deft berry
#

remember how i told you twice already that it's the up/down/left/right one? (this makes three now)

tame oracle
hazy condor
deft berry
patent lark
#

Hi, I'm experiencing a massive performance drop when moving after I ported my project to the new input system, has anyone had a similar experience?

vast portal
#

How can I update to version 1.4 / 1.5? Do I need to get it through GitHub or something?

austere grotto
tough atlas
#

Is this a known issue or maybe a bug in my unity version? I have this very simple code and everything works fine for the first if. But then if i press the key it doesnt get triggered. I have to spam the key rlly fast to get single or multiple triggers and the output. I also tried it with the newer input system and i have the same result but i have no idea why. Code:

private void OnTriggerStay(Collider other)
    {
        if(other.transform.gameObject.transform.tag == "climbObject")
        {
          //until here everything is fine
            if (Input.GetKeyDown(KeyCode.Y))
            {
                Debug.Log("test");
            }
        }
    }```
austere grotto
#

Reading input should only happen in Update

patent lark
#

weird that it seemed so connected to my movement though

austere grotto
tough atlas
austere grotto
#

OnTriggerStay runs during the physics simulation

#

the physics simulation does not run every frame

#

so it is liable to skip input

tough atlas
#

ok makes sense, ty ❤️

mental path
#

Hello, not sure if this is the right channel to ask this, but does anyone know if the XR Interaction Toolkit can be made to work with the Valve Index controllers? I'm trying to complete Learn.Unity's VR course and they claim that the toolkit works with Valve Index, but that doesn't seem to be the case anymore as the Grip sensitivity seems to be just true/false ( as if the grip was simply a button )

#

(also if there's a better/proper place to ask this on the server, where is that?)

heady forge
#

hello! I'm having an issue with writing a custom interaction detecting a full 360 of a joystick. The custom interaction code is always reading the context Vector2 as <0,0>, but a separate movement action is working just fine with the same bindings.

vast portal
dusty urchin
#

Is it normal when i generating c# file after it this file has compiler errors?

warped arch
#

the input system works in the editor but not in the build

#

I have already tried googling for a solution but they dont work

#

I have tried

  • setting Active Input Handling to Both
  • setting the Architecture to x86
  • resetting playerprefs
#

I tried building it in an android and it works fine

slim reef
#

Hi there, I'm quite new to the new input system, and am trying to find an implementation for a drag interaction. I've followed this thread: https://forum.unity.com/threads/implement-a-mouse-drag-composite.807906/

It works wonders on PC with the mouse, but the isPressed value mentioned in the script is never true for touch input. Is there another value I could check to see if I'm currently pressing down on a touchscreen?

heady forge
#

i still have no idea why reading the value as a Vector2 is resulting in <0,0>. the only thing i could think of is if the Move action is eating it, but if i delete that completely and only have the Spin action have WASD/joystick bindings, its still <0,0>

austere grotto
heady forge
#

still 0,0 every input with just WASD bound to Spin

#

its weird in that its correctly calling IInputInteraction.Process when the input is changed, but its 0

austere grotto
#

Can you show your code

heady forge
austere grotto
#

You're calling ReadValue on the action

heady forge
#

WOW i'm dumb that was the case

#

completely glossed over that, thank you!

shut phoenix
#

the camera moves in late update and sets itself to the player rigidbody transform

the cursor moves in update and sets itself to ScreenToWorldPoint(Input.mousePosition)

using Pixel Perfect Camera also

#

no lerping anywhere, and doesnt seem to get better if i swap which update each of them do stuff in

i am mainly just having difficulty narrowing this down as it could be any of:

  • Pixel perfect camera messing up with rounding
  • Pixel perfect camera messing up Input.MousePosition
  • ScreenToWorldPoint not being fully correct
  • Code to set position in wrong Update function
glass yacht
shut phoenix
#

perhaps, however I'd expect consistent behaviour rather than seemingly random jitters

#

With a good time between each like 400ms maybe

glass yacht
#

why? Your camera can move different distances based on the frame rate and speed of the player

shut phoenix
#

The camera sets itself to the position of the rigidbody which is moving with the physics

#

Ah that would make sense why it's not constant jittering

#

and then I suppose yes I then want the cursor in late update and camera before it somehow prob in fixed update

#

Yeah that all makes sense will try it tommorow

#

Thanks for the suggestions

heady forge
#

(figured hard coding joystick quadrants was safest bc idk how this layer handles GC etc.)

warped arch
#

The Input system doesn't work in my standalone build but it works perfectly in the editor. I'm gradually losing my sanity trying to find a solution for this. Please help me!

sage root
#

Hey Guys!

Can't assign InputActionReference to fields of InputSystemUIModule

I am making a Co-op game and looking at implementing full controller remapping with the new unity input system. In order to do this I am cloning the input action asset with Instantiate() so that each player can have there own controls.

I then have to assign this new copy to the PlayerInput, which is working fine for me and also the InputSystemUIModule, which is where my problem is.

Currently, when I assign the new clone to the ActionAsset field, it resets all of the bindings. (Point, Left Click, Move ect). To work around this I get the InputActionReferences to the actions I want to re-assign and then set the field to the InputActionReference.

However, rather than correctly set it, it just remains as none. I get no errors or debug messages, and I am fairly sure that the InputActionReference I have is correct. The only other information I have is that when attempting to set the values' through the inspector, the only value available is none.

Here is the code I am using:

newInputAsset = Instantiate(inputAsset);
InputAction moveAction = inputActionAsset.FindActionMap("Player").FindAction("Menu Move");
InputSystemUIModule uiInputModule = GetComponentInChildren<InputSystemUIModule>();
uiInputModule.move = InputActionReference.Create(moveAction);

I'm on unity Version 2020.3 and input system version 1.1! Does anyone know how I might solve this problem, or circumvent it somehow? Any help much appreciated.

shut phoenix
#

still jitters

midnight pebble
#

When using the new input system, does anyone know if the pointer needs to be over a UI element to trigger the UI inputs like "click" or "middle click" etc or if these are performed every time whenever the e.g. left mouse button is clicked?
Like, would I need to add new input actions for "left click" etc when not dealing with UI elements?

chrome walrus
midnight pebble
chrome walrus
midnight pebble
chrome walrus
midnight pebble
#

Ooh, okay!

patent lark
#

Hi, how would I go about getting references to each individual binding in this group? (for rebinding purposes)

static hedge
#

can you use the input system on 2 different objects?

austere grotto
static hedge
#

I'm just trying to figure out why my controller isn't working on object2. I guess the mouse works for it but the controller doesn't. The controller does work on object1, so I don't think it is a controller issue

#

here is the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class Sight : MonoBehaviour
{
    Vector2 lookVector;
    [SerializeField] float sightDist;


    // Start is called before the first frame update
    void Awake()
    {

    }

    // Update is called once per frame
    void FixedUpdate()
    {
        transform.localPosition = new Vector2(lookVector.x * sightDist, lookVector.y * sightDist);
    }

    private void OnLook(InputValue value)
    {
        lookVector = value.Get<Vector2>();
        lookVector.Normalize();
    }
}
static hedge
#

So I pulled the values from my main movement script and it seems to be working now.

pulsar wren
#

Seems like anytime I change the name/input of an action in the PlayerInput manager, it breaks my code. It seems like it's trying to update/compile the PlayerInput script but it takes forever. Anyone see this before? Code was working fine before I changed the name of the action. Compiling seems to be locked up in the background task tab

#

Nvm figured it out - I had the PlayerInput asset in a different folder so when I made changes it created a new PlayerInput script in that folder and clashed with the old script in my script folder

static hedge
#

Now I am calling it in an input class essentially then referencing the values from there, that seems to work.

austere grotto
#

A callback like that I would expect to be used with the PlayerInput component

static hedge
#

Using the new input system it gets called via a sendmessage

austere grotto
#

Not the way that code was set up it doesn't

static hedge
#

right and I had one on my sight

austere grotto
#

Ok well you confused two approaches then

#

playerInputs = new PlayerInputs()

#

This is a totally different thing

static hedge
austere grotto
#

PlayerInputs playerInputs;

#

This whole variable is not doing anything

#

The real work is being done by the separate component you attached to your GameObject

#

Called PlayerInput

static hedge
#

right, i thought I had to call the enable and disable functions for it to work, I must have misunderstood

austere grotto
#

You're confused

#

Because you have named your input action asset similarly

#

But your "PlayerInputs" and the "PlayerInput" component are two separate things

static hedge
#

yes i understand that

austere grotto
static hedge
#

ok, When I was learning about the input system i must have gotten confused

#

so I will just use the send message and call the On functions

austere grotto
#

Yes it's confusing because there are many different ways to use the system

static hedge
#

yeah i noticed that

austere grotto
#

You've landed somewhere between two ways. Your code will still work if you remove this whole variable:
PlayerInputs playerInputs;

static hedge
#

thank you for the help

static hedge
#

Having some controller issues. The controller is seen everywhere but when I play the game in unity. I've tried restarting unity, restarting the controller, restarting my PC, deleting and reconnecting the controller. Search the internet, there seems to be issues with the switch controller, but I am using an XboxOne controller. Any ideas?

patent lark
#

hi, I am trying to bind a 2D vector composite to a controller. I have a rebind key component which handles this for me, the only thing I'm struggling with is getting the correct path.
Whenever I perform the interactive binding, I get the following paths for the controller: <Gamepad>/leftStick/y, but what I'm looking for is <Gamepad>/leftStick/up.
Is there a way of getting the up/left/down/right paths instead of just x/y?

austere grotto
#

yep sounds about right

#

I'd probably use started/canceled

wraith root
#

Is there a way to prevent the Delta [Mouse] input from taking cursor-locking into account? When I lock the cursor using Cursor.lockState = CursorLockMode.Locked and then move the mouse, producing a non-zero delta, it seems it applies the movement of the mouse from its position to the center of the screen plus whatever actual mouse movement I did

#

In this example I moved my mouse around without locking it to the center of the screen, and enabled/disabled camera movement based on the delta value - worked fine. Once I started locking the cursor though, you can see the camera snap

#

The values printed in the Console are just the values being given by mouseDeltaAction.ReadValue<Vector2>(); when I move the mouse after locking the cursor, you can see it emit a very large vector in comparison to the usual small ones

austere grotto
wraith root
#

Sure. The code in my main project is too complex to share easily, but I was able to reproduce the issue in a minimal project - uploading that to my Google Drive now, and then I'll have a link...

#

I can also post the script from the minimal project + a screenshot of the input action setup

wraith root
#

I suppose it's possible I'm just going about implementing this the wrong way? But at the moment, I can't think of what the "right" way to do it would be, if that's the case...

warped arch
#

Has anyone else experienced the new input system not working on a standalone build?

tropic tulip
#

this is all i need for a hold a key to do things system ryt?

austere grotto
#

If you mean - an action is triggered one time after holding the button for n seconds, then yes

#

If you mean - continuously do something while the button is held, then no

still cypress
#

Hi guys, does anyone know how to set up the "stepcounter" in the input system. I tried this about a week ago, but it doesn't work

sick tundra
lofty galleon
#

Anyone know why i alsways have an input put in at exactly trhe image values, i have disconected everything and it still doesent work, it has also tried being transfered over to another pc and when it is there it works. In any other game i play it never happens and when i build it still happen please help its starting to get annoying XD

austere grotto
#

Definitely sounds like a connected joystick or gamepad

sleek pasture
#

Using this code, I run PlayMode in Simulation (not Game) and this prints 2 when clicking with mouse left. Only when I switch tabs to Game and back to Simulation does it print 1.

    private void OnEnable()
    {
        TouchSimulation.Enable();
        EnhancedTouchSupport.Enable();
    }
    
    private void OnDisable()
    {
        TouchSimulation.Disable();
        EnhancedTouchSupport.Disable();
    }

    private void Update()
    {
        Debug.Log(EnhancedTouch.Touch.activeFingers.Count) // PRINTS 2
    }```
warped turtle
#

hey yall, im following along with this tutorial and the mouse movement script provided has inverted the up and down, ive been trying to fix it by changing stuff like the xrotation and yrotation but cant seem to find it, any help would be appreciated

warped turtle
#

i figured it out

warped turtle
#

for anyone wondering, change the xRotation -= yRotation to xRotation += yRotation

vocal bane
#

I am using the new input system and I have a pick up and drop event. Both are on the same button currently because it feels intuitive however I want the option to later split it in seperate buttons.

Because they are bound to the same button, if I press it, it will pick up and immediately drop whatever I picked up. Which is kinda logical. What is the best way to solve this?

#

Please ping or reply me so I get a notification

zealous beacon
#

How can I make it so these events only happen once at a time, for example if I when I click normally and am holdings shift at the same time, Both SelectShift and Select occur and I only want SelectShift to fire

jovial hearth
#

hello folks, got a bit of an issue, I have a movement script in 3d space (up, down, left right, forwards, backwards) and when setting up control scheme for both controller and keyboard, only the controller, works, as soon as I remove the controller, keyboard works, not sure what is the issue exactly, since afaik, it should just work

austere grotto
#

This would be instead of trying to use the Button With One Modifier composite, which is not that well thought out.

sleek pasture
# sleek pasture Using this code, I run PlayMode in Simulation (not Game) and this prints 2 when ...

Figured this out, if anyone was wondering. Had to add these scripting definition symbol checks for DEVICE_SIMULATOR and deactivate TouchSimulation. TouchSimulation was adding a second touchscreen on top of my Simulator touchscreen, which was causing EnhancedTouch.Touch.activeFingers to have 2x index == 0 fingers.

        private void OnEnable()
        {
#if !DEVICE_SIMULATOR && UNITY_EDITOR
            TouchSimulation.Enable();
#endif
            EnhancedTouchSupport.Enable();
        }

        private void OnDisable()
        {
#if !DEVICE_SIMULATOR && UNITY_EDITOR
            TouchSimulation.Disable();
#endif
            EnhancedTouchSupport.Disable();
        }```
gritty ridge
#

Does anyone know if I can put the same input system on multiple different objects? I want the player to interact with a door and npc but I want the input system on the door and npc because right now it’s on the player. Is there any way to go about this?

austere grotto
sleek pasture
# gritty ridge Does anyone know if I can put the same input system on multiple different object...

What you want to do doesn't need input system on the door or npc. You need to do a Raycast and hit the door and NPC and have those implement an interface called IInteractable (which you should create). Both NPC and Door script should have a method named Interact() that do different things, because adding the interface to the class composition will force those scripts to have and Interact() method. Then the Raycast should look for the IInteractable component and if found, do Interact()

public interface IInteractable
{
    void Interact();
}``````cs
public class Door : MonoBehaviour, IInteractable
{
    public void Interact() 
    {
        OpenOrClose();
    }
}```
gritty ridge
sleek pasture
gritty ridge
mossy vessel
#

Hi, I'm trying to teleport the player, which has a characterController, when a button is pressed by setting transform.position, but I think it's being overridden by a characterController.Move() call that I make every update, so it isn't teleporting. I'm able to fix it by using Move() and IgnoreLayerCollisions() to teleport, but I feel like this isn't a perfect solution as there may be more layers in the future that it has to avoid. Is there any way I can make the InputAction that teleports the player occur later, like around the same time as LateUpdate?

austere grotto
#

what do you mean by "input system" specifically?

#

Are you talking about the PlayerInput component?
An instance of the generated C# class?
what?

austere grotto
mossy vessel
#

ah SyncTransforms sounds perfect! thanks 🙂

gritty ridge
austere grotto
#

that makes little sense.

You can certainly throw that component on any object you want, but it is intended to represent a human player, and makes little sense on anything other than a character or object controlled by a human player.

gritty ridge
austere grotto
gritty ridge
#

Because you need to be near the door and interact with it to change levels

austere grotto
#

you have an input handler on the player. The player detects when it's near the door and then opens it.

sleek pasture
#

Has anyone made EnhancedTouch work with DeviceSimulator? I'm getting Touch ScreenPositions of Infinity, -Infinity

#

Looks like it's not compatible

spice trout
#

This rotator isn't following the player it just stays at 0,0

#

I have no idea why it is doing this

austere grotto
#

it follows the whims of the physics engine now, not the hierarchy

spice trout
#

ok, how so I just have to make it rotate without a rigid body?

austere grotto
#

I don't see why you added a Rigidbody

spice trout
#

to make it rotate based on mouse position

austere grotto
#

what does that have to do with Rigidbodies

#

Rigidbodies are for physics

#

not mouse input

spice trout
#

idk this is my script

#

I'll just do one based on transform.position