#🖱️┃input-system

1 messages · Page 46 of 1

grand crow
#

Oh wait

#

I had to click a button in the Event System object

#

because computers aren't capable of doing that without human input

#

apparently

subtle patrol
#

Hi guys, I hope this is the right channel, I use Input Actions
I follow tutorial, until step where I press control w,a,s,d is debug shown in play mode but the character is not moving yet is work very well, similar with the tutorial, and the next step I add character controller component and following tutorial that change the code, after I finish following the tutorial I can't go to play mode because some component is error

austere grotto
subtle patrol
austere grotto
subtle patrol
deft berry
#

looks like you are missing semicolons and brackets. Make sure your IDE is properly set up so it will show you those kinds of errors while writing the code. Check #854851968446365696 for the guide to set up the IDE

austere grotto
subtle patrol
#

woa! it's works, first I need to set up the IDE, and I open the script again there is new tool that can check my error on script and last I can fix AnimationAndMovementController, thank you @deft berry@austere grotto

clever oyster
#

replacing standalone input module to the new input system event system, now I cant click buttons in my menus

deft berry
clever oyster
#

doing that makes buttons to stop working

#

to the mouse for example

clever oyster
#

Dang it , but doing that the old event system to click with mouse doesnt work...

#

even though the two are active

#

ok it works when I disable the cursor

novel sparrow
#

My package manager is whole empty 😭

#

And i got 3 errors and unalble to fix it , this error is of sprites and all , everytime i am opening any scene its showing this error idk what's the problem pls help

whole scroll
#

No I didn't, should I?

whole scroll
#

I did now and it works fine in the editor thanks

twin sundial
#

how do I return the InputUser of a device that's being used?

#

I want to check if a button is pressed, and then return the device that was being used when the button was pressed

austere grotto
twin sundial
#

thanks!

tawdry wasp
#

I want while my player is placing a thing I can rotate it 90 degrees every time they press the button, but i'm not sure how to do it with the new input system it's confusing me, atm I have the key set to R on keyboard - to check if it's pressed once I can jsut have it on/off a bool, but to check how many times it's pressed and then rotate it idk how to do that

#
        void PlaceBuilding()
        {
            if (!placeLocations.Contains(curIndicatorPos) && !curBuildingPreset.twosquare)
            {
                if (cameraCo.rotatePlacementPressed) { 
                    GameObject buildingObj = Instantiate(curBuildingPreset.prefab, curIndicatorPos, Quaternion.Euler(new Vector3(0, 90, 0)));
                City.instance.OnPlaceBuilding(buildingObj.GetComponent<Building>());
                placeLocations.Add(curIndicatorPos);
                }
            }```
#

this is what I have to place it, what I use for no rotation is Quaternion.identity

grand crow
#

Can you keep a running counter in whatever method calls PlaceBuilding? Then pass in the (rotation % 4) * 90

#

I'm having trouble getting the new input system to recognize my gamepad at all. Its just a generic dinput pad and nothing works. I use XInput to emulate an xbox360 controller for games that don't support anything else and Unity doesn't even notice that. What am I missing here?

grand crow
#

It shows the gamepad's name correctly in the inspector, it just doesn't seem to notice or care when a button is pressed

remote basalt
#

Hello. I kinda have an issue. I'm running Unity 2021.1.12f1 on Linux, and oddly enough, a Rock Candy Switch Pro Controller, which the PC detects just fine; is not supported? I think it believes it to be a walkman?

Bus 003 Device 007: ID 0e6f:0187 Logic3 Rock Candy Wired Controller for Nintendo SwitchBus 003 Device 007: ID 0e6f:0187 Logic3 Rock Candy Wired Controller for Nintendo Switch```

~~Unity however...~~

I am a silly dingus bird, I didnt know the input debugger had contextual menus.... adding it to the support devices (literally an option) solves it.
twin sundial
#

I'm having problems with binding Control Schemes to my InputUsers

#

every time I try to do anything with the InputUser class that has to do with ControlSchemes, I get this error message

#

I made sure that my InputUser wasn't null or anything, and that all the values were set correctly

#

here's my code

#

The error is coming from the line that says player.inputUser.ActivateControlScheme(scheme.Value);

#

inputUser is a reference to the Player's InputUser, and pairedDevice is a reference to the device connected to the Player

#

before this part of my code, I used the PerformDevicePairing to pair the device to the user

olive loom
#

Whats the difference between these 2 events? I need calls when they has been pressed down

olive loom
#

I also cant seem to figure out which event is called every frame while the key is held

abstract jasper
fallow haven
#

How can I get the mouse position in the editor using the New Input System package?

#

Since actions can only be read while in-game

austere grotto
fallow haven
still forum
#

Hey guys 🙂
Just migrated to the new Input System (after a while i know) and i have trouble because
EventSystem.IsPointerOverGameObject(); doesn't work anymore and
inputSystemUIInput.IsPointerOverGameObject(); doesn't work as well...
so i can't prevent touch events altough UI elements where clicked...

What's the new way of handling such things?

twin sundial
#

you could always use a raycast from the mouse position and see if it hits anything

#

that's what I do

slate lance
#

Zipcar

still forum
twin sundial
#

I'm not exactly sure what you're trying to accomplish, but I know that a way to test if the mouse is over something is by using raycasts

#

basically you can just use the ToWorldPos method to convert screen coordinates to world coordinates, and then raycast using that as a position to see if the raycast hits something

#

although, anything you want to be hoverable will need a boxcollider

still forum
#

okay thanks for the advice 🙂

I'm pretty sure there must be a simpler solution (as it was before i updated to the new input system) but if I'm not able to find one I'll have a deeper look at the raycast solution.

as i know those pointers are raycasts anyway.

true drift
#

I am having a problem where the Unity file MultipleDisplayUtilities.cs did not upgrade to the new system. It keeps crashing my project. The error line is highlighted. How do I fix it?

grand crow
#

Idk if there is any difference but it is working for me in 2021.1.10

#

Or you might need to check your EventSystem in your hierarchy and see if it shows a message about switching the input system.

#

Its not intuitive. Like at all.

#

Speaking of which, this is happening and I don't know why. I don't have any methods assigned to this event, so I don't know why it is trying to read a float from a composite. Note that this only happens with the mouse wheel. If I remove that it stops complaining.

neat marten
olive loom
#

Is there a way to have a callback key event with the new input system that is called every frame while the key is being held?

timber robin
#

No, you need to set a bool which is set on the performers and cancelled actions.

olive loom
timber robin
#

Yes

olive loom
#

lame 😛

#

guess ill keep using the code i had

sharp wharf
#

hey, I'm new to Unity (though i do have six years of web dev experience) and I've got what i think is a pretty basic question.

#

How do I get the current user input device? I'm using the auto-detect input device setting to allow the user to change from KBM to controller on the fly, and it works well, but I want to also have it change the onscreen prompts to the proper buttons when that happens. I do know it fires an event when it happens, but inside the handler for that event, how can I access the current input device and get its type?

timber robin
#

Check Rene's response

sharp wharf
#

Thank you!

inland bramble
#

Hi, I'm new to unity and I just got stuck trying to understand something about the input system. The idea is: the player is a car, there will be 2 cars, one with WASD and the other with Arrows.

I made a player prefab of the car, and it uses invoke events to move, but when I spawn 2 game objects (each one of them having their own Player Input) only 1 of the cars move.

Can't multiple Player Inputs be activated at the same time?
What am I doing wrong?

#

I was expecting that, even if both cars had WASD, when moving it would move both cars.

inland bramble
#

So... this is awkward but it works. After a lot of searching on something that I have no idea what I'm doing, I finally got a work around.

This post suggests that PlayerInput will not assign the same device to more than one player..
https://forum.unity.com/threads/multiple-players-on-keyboard-new-input-system.725834/#post-4848698

So I managed to work around it by using the code on the car which has the PlayerInput:

void Start() {
    PlayerInput input = GetComponent<PlayerInput>();
    input.SwitchCurrentControlScheme(input.playerIndex == 1 ? "Keyboard (Arrows)" : "Keyboard (WASD)");
}
#

I'm not sure if that's the right thing to do or if there are easier ways, but it works... let me know tho.

fallow haven
#

How can I read an input value of an action in the editor?

still forum
still forum
#

what i did was an hold and release event

kindred island
#

hey when i start my game and i can move around if i click the pause button nth happens it doesnt even become darker for a sec

#

which means it has been clicked

still forum
kindred island
#

a ui one

austere grotto
obtuse laurel
#

Hi I'd like to ask for help setting up Input System for controllers.

#

I have a few questions regarding this, firstly, do I explicitly need the Input Player Manager? It's a one peripheral device game

#

So would be based on Gamepad.current

timber robin
#

You don't need the Player Input Manager component, no.

obtuse laurel
#

var playerGamepad = Gamepad.current; Vector2 joyStick = playerGamepad.leftStick.ReadValue();

#

I saw this in an example, but I'm using C#

#

thanks @timber robin already

obtuse laurel
#

I rarely use var datatype

austere grotto
#

¯_(ツ)_/¯ it's just a keyword not a datatype

timber robin
#

You don't need to cache your gamepad either, just set it up in your input asset.

obtuse laurel
#

I thought maybe @austere grotto

#

so my next challenge is linking to the input asset

austere grotto
#

I recommend using InputActionReference in your code, as needed, to refer to InputActions

obtuse laurel
#

thanks

#

I'll look it up in the ref

austere grotto
#

Some other options are:

  • use the generated C# code file from the Input Action Asset
  • use PlayerInput component
timber robin
#

I personally prefer using the code file, implementing the interface.

obtuse laurel
#

er, is there a walkthrough for PlayerInput?

#

I'm running out of time and it's an old project

#

Ah ok, so I should open the inspector up

austere grotto
#

Yep there ya go - there's a PlayerInput walkthrough there

#

The docs here really are kind of insufficient though. There's a ton of ways to use the new Input System that are just not really documented at all in the official docs.

obtuse laurel
#

Thanks.

#

I'm really foggy about this, but seems I've set up most of what I need in my code already

#

at least I know to investigate for my next project.

#

Problem is: I need to create controls for keyboard and or gamepad

#

So I'd prefer implementing the interface, rather than ad-hoc my own solution

#

in the end, that is

feral stone
#

my unity is randomly closes when i am about to publish a vr chat world any thoughts?

obtuse laurel
#

Is this related to input system?

feral stone
#

oh my bad

grand crow
#

I'm not sure if I'm approaching this the right way, but here's my concern:

I have a few Action Maps. These control a few broad states of the player. Regardless of what state the player is in I want them to be able to zoom the camera in and out. This results in my defining the CameraZoom action in every Action Map. This feels like its the wrong way to do this, but I'm not sure what the best way to handle it is.

austere grotto
#

just make sure to enable that separate map:

playerInput.actions.FindActionMap("CameraActions").Enable();```
grand crow
#

Either the documentation isn't clear (possible) or I'm just dumb (probable) but I didn't realize there could be several enabled at once.

#

neat.

olive loom
#

How do I make a key detect if its just pressed or pressed and held for a certain amount using the new input system?

nimble phoenix
#

My game pad does not work when I build my game using unity new input system

nimble phoenix
#

Yes

leaden sequoia
#

worst thing that can happen imo 👀
good luck 🥺

austere grotto
gleaming frigate
#

I set my 2020.3 LTS project to the newer input system

#

But it hasn't worked

#

It keeps telling me that the Input system stuff doesn't exist

#

Any idea what went wrong?

calm tapir
#

using UnityEngine.UI;

#

what

#

sorry i pasted the wrong thing

austere grotto
gleaming frigate
austere grotto
gleaming frigate
#

For some reason that hasn't fixed the issue. It seems like Unity set the input system to the new one without getting the necessary files for new input system

austere grotto
olive loom
olive loom
#

Thanks

#

i assume also i cant have both holding and on press? I need it on release

austere grotto
olive loom
#

If i just press, it does something, but if i hold and release for X seconds it adds more force to it

austere grotto
olive loom
#

Yeah thats the thing, i need to do the stuff on cancelled

#

aka lift key

austere grotto
#

mhmm

olive loom
#

Ahh, well i guess its fine eyesShake

austere grotto
#

that's what the canceled event is for

olive loom
#

yeah too bad there isnt a continuous-started event so it gets called every frame while something is being held KEKAH

forest fulcrum
#

wait

#

why isn't this working

#
public void OnCameraZoom(InputAction.CallbackContext context)
    {
        Debug.Log(context.ReadValue<>());
    }
#

im having an error on the readvalue function. it's saying "Using the generic method group 'ReadValue' requires 1 type arguments [Assembly-CSharp]csharp(CS0305)"

#

so i assume it needs an argument, but what would i put as the argument lol?

timber robin
#

You have to pass in the type into ReadValue.

forest fulcrum
#

ohhhhhh i see okay thanks mate!

grand crow
#

Is there a proper way to prevent disabled gameobject from responding to UnityEvents? I have an object listening for a certain event and the method gets called even when the gameobject is disabled.

#

I could just have the method check if its gameobject is disabled and return immediately, but this seems clunky.

austere grotto
olive loom
#

do i need this in order to actually detect duration?

austere grotto
olive loom
#

I also use it inside the canceled event

#

dont evne have a performed one registered

crisp topaz
#

hi, could anyone point me to where can I get Device Orientation (e.g. upside down portrait) in the "new" Input System?
I can get it via Input.deviceOrientation, but I'd like to maybe += to some "OrientationChanged" event, instead of doing it in Update()

devout rover
#

my ps4 controller doesnt register right triggrt up, is this inteended or is it broken? all other buttons work

#

(it registers right trigger down)

dense ridge
#

is there a way to have more than 1 input

devout rover
dense ridge
devout rover
#

yes, im pretty sure you just add another binding

dense ridge
#

but for the same binding

#

so like move forward to be w or joystick up

devout rover
timber robin
#

Yes just add a new binding.

devout rover
#

brackys has a great video on that

devout rover
# dense ridge but for the same binding

Let’s check out what Unity is working on for the new Input System!
► Go to https://expressvpn.com/brackeys to take back your Internet
privacy TODAY and find out how you can get 3 months free.

● Get the new input system here: https://bit.ly/2SiXsgS

👕Check out our merch! https://lineofcode.io/

♥ Support Brackeys on Patreon: http://patreon.com/b...

▶ Play video
#

does anyone know why my ps4 controllers triggers only works with "press" and not press and release?

#

is this intended behaviour

devout rover
#

do you know why?

#

🙂

dense ridge
#

nope

#

also the problem is the action is a vector 2

#

so it wil be hard to have more than 2

#

1

devout rover
#

what do you want to do with it

#

ohh

dense ridge
#

move, crouch, sprint

devout rover
#

so you want help do add bindings for a controller?

dense ridge
#

yes and still want it to be able for computer

devout rover
#

ok

#

click here

#

and add a new controll schem, name it something like "controller"

#

and you might aswell add one for the keyboard and mouse

#

Tell me when youve done that and ill explain the next step

dense ridge
#

done

devout rover
#

ok so, select the controller input scheme

#

and in it, replace the old bindigs with the contollrt bindings

#

then save, and it should be it

dense ridge
#

but I have 2

#

ok now I have movemnt for computer and movement controller for controller

devout rover
#

does it work

dense ridge
#

let me do the script

devout rover
#

ok

#

id watch a video and how to activate it, because it weird

devout rover
dense ridge
#

I already have one

devout rover
#

ok

dense ridge
devout rover
devout rover
neat marten
#

But in the latest version it's not GetValue, but ReadValue
It's also possible to read it from the action itself - if you want it in Update method

devout rover
#

like in the last minue

#

Running

#

have you just the input system for controllers? if you have, do you have time to help me

dense ridge
neat marten
#

What? Mouse.current.position.ReadValue maps to Input.mousePosition, not Input.GetAxis

neat marten
dense ridge
devout rover
calm tapir
devout rover
#

ohhh

devout rover
calm tapir
#

i haven't no

neat marten
calm tapir
#

i've only used mouse and keyboard

dense ridge
neat marten
devout rover
dense ridge
devout rover
#

which means that the character doesnt stop shooting and always spins

calm tapir
dense ridge
calm tapir
#

have u added it to the action map?

dense ridge
#

what

#

what do I need to add

devout rover
#

to this ^^

dense ridge
devout rover
devout rover
dense ridge
#

which I made a new action map thing like Move called mouse for this what do I change this to

devout rover
#

ehhhhh, ask dis_da_moe

dense ridge
#

dis da moe can you help

neat marten
calm tapir
#

one sec it's been a while since i did this i'm trying to do it myself

dense ridge
neat marten
#

But it should work without the action, just using Mouse.current.delta.x.ReadValue()

neat marten
dense ridge
neat marten
#
using UnityEngine.InputSystem;

...

Mouse.current.delta.x.ReadValue()
devout rover
calm tapir
#

on either side

neat marten
devout rover
#

´´´ OwO ´´

calm tapir
#

missing one on the right

devout rover
#

´´´ OwO ´´´

#

OwO

neat marten
#

Or OwO with one on each side

devout rover
#

Amogus UwU

#

hi

#

ok

#

a<zfxcgvhbnm <zxcfgvhbj

#
    {
        controls.Disable();
    }```
dense ridge
#

this is coming up

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

public class MouseLook : MonoBehaviour
{
    public float mouseSensitivity = 100f;

    public Transform playerBody;

    float xRotation = 0f;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Mouse.current.delta.x.ReadValue() * mouseSensitivity * Time.deltaTime;
        float mouseY = Mouse.current.delta.y.ReadValue() * mouseSensitivity * Time.deltaTime;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90, 90);

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }
}
``` code
dense ridge
neat marten
#

It's really strange
It works for me and I get such error only if I'm using Input.GetAxis

dense ridge
#

you saw my error

neat marten
#

Have you restarted Unity after enabling new Input System?

dense ridge
#

yes

neat marten
dense ridge
#

found problem but I removed it but now unity can'[t read

#

@neat marten

weak trout
#

Hi, does anybody know a good asset for displaying input bindings on screen? Bonus points if it can switch between keyboard/gamepad/VR

#

Essentially I just want something I can call to display a certain button on the GUI, and have it be able to change depending on which type of controller the player is using. I could make it myself but if anybody knows an asset that already exists for this, or what to search for, that'd save a lot of time

zealous wedge
#

Hey Y'all, I've been trying to do something that feels a bit slopppy where I'm amalgamating the raycast input click with the UI PointerEventData for a card game that handles both. Does anyone have any recommendations for amalgamating UI clicks and 3d world clicks into 1 uniformed thing? the interface i've made is a bit janky and I could use some advice

zealous wedge
austere grotto
#

that's my $0.02

potent python
#

I've got a question which I think I found but wanted to clarify. I have two Action Maps, one is "MenuInput" the other is "GameInput". I also have an action on both of these maps called "act_Point" which acts as the mouse, is this not possible to do as I'm noticing in my event handling that it's acting odd when I have two actions with the same name.

neat marten
#

Define odd
I haven't played with actions of the same name in different action maps, but I expect it at least to work if only one action map is active at a time

safe basin
#

Hey, i use a 1d Axis to rotate my player, but i just gives me values of 0 and 1 when i do .readValue<float> (i use a keyboard, so i figure it won't give a floating point value, but why are there no negative values showing up in the console?)

        Controls.Player.Rotate.performed += _ => SteerKeys(_);
void SteerKeys(InputAction.CallbackContext context)
{
_torque = context.ReadValue<float>();
Debug.Log(_torque);}
potent python
neat marten
#

Even if only one of the maps is active? Sounds strange, maybe a bug

devout rover
#

hello, im adding local multiplayer for my game, and we are using InputValue, in the tutoral he presses alt + enter, but i dont get the same menu as him, does anyone how i acces the same menu as he did

potent python
devout rover
ocean shell
#

How do I start editing an inputfield with a key?

#

Im making a fps, and the cursor is locked, cant click the inputfield.

neat marten
#

You need to Select() it

safe basin
safe basin
royal stream
#

With the new input system, I need input into several different scripts. Is there a way to poll the new input system?
For example, I have "Fire" and "Move" set up. On my Player game object, I have a Player Input component, and it works to move the Player, but I need the "Fire" input in the script on my Gun game object (child of Player). There will be several different gun game objects for different types of guns. I would like to be able to just poll "Fire" from the script on the Gun. Is this possible? If so, is there a tutorial or example of how to do this somewhere? Thank you.

frigid ridge
#

@royal stream Better way to solve this would probably be to handle the fire input on the player object and have it use the weapon

#

You certainly can go without Player input, but doing so breaks a lot of features player input provides

royal stream
#

@frigid ridge Do you mean get the input in the Player game object script, and then send a message to the Gun object script?

frigid ridge
#

Generally I have the player object call something on the item it's using

#

This has the added benefit of allowing AIs to do the same, as the item is no longer directly tied to some sort of player input

royal stream
#

@frigid ridge So, would you do this by calling a method in the Gun script?

frigid ridge
#

Yes

royal stream
#

@frigid ridge Thank you, I'll try this.

frigid ridge
#

If you in the future end up having different types of items, they can implement some sort of C# interface that exposes the Use() method.

royal stream
#

@frigid ridge Thank you for that. I'm planning on having at least 3 different types of guns, with each on a different game object (child of the Player). I'm just watching a video that is using interfaces (I've never used them before).

frigid ridge
#

If the only item type you have is gun, they can probably just inherit from a base gun script

#

Inheritance and interfaces are ways to make things neater.

royal stream
#

@frigid ridge One will be a laser, one projectile, and one particle. I'll analyze it from the inheritance and interface ways, once I learn more about interfaces.

frigid ridge
#

Yea if they don't end up sharing functionality, interface would likely be a better option. They are great for exposing a common feature between more or less unrelated scripts.

royal stream
#

@frigid ridge That's what I'm thinking, that they will have somewhat different functionality, which is why I was going to use 3 different game objects.

olive loom
#

Any reason to disable action maps that dont have a device plugged in for?

slate jetty
#

Hello, i've created an input action asset for Mouse Inputs using the new input system. I'm also using the EnhancedTouchSupport for Touch inputs on a TouchScreen. The problem is that I can't make them work simultaneously on Windows because a touch on a windows touchscreen is also emulated / considered as a mouse input.
Do you guys have any idea how to solve that problem ? I'd be able to detect mouse inputs & touch inputs but they have to not interfer between each other.

kindred island
#

hey ive made some ui buttons that i can press but when i add a panel i cant press them

#

pls help

#

...

kindred island
#

no a panel fom ui

#

from

neat marten
#

Difficult to understand your situation without examples

kindred island
#

look i want to make a in-game menu and ive added some ui buttons. However when you trigger that menu you can still see the game and i want to add a backround

#

and when i add the panel to make the backround i cant press them

#

ill thry adding an image

#

try

#

now i cant even see the buttons

#

i need some help with ui actually but there is no channel for that

neat marten
#

There is

kindred island
#

oh

#

sorry

#

😬

slate jetty
#

I was wondering what's the link with Input system 😄

#

Is my question above clear enough?

olive loom
#

this input system seems highly unoptimized; its using so many strings everywhere!

slate jetty
kindred kraken
#

granted, I haven't looked into the new input system

blazing vine
#

can someone tell me why Keyboard.current[Key.LeftAlt].isPressed always returns true for me until i actually press and release that button to reset the state?

blazing vine
#

no one?

olive loom
plush wasp
#

You mean internally? From a user perspective I don't have any string-based lookup in my input handling code

#

@olive loom

olive loom
#

the names have extras, control scheme is literally just a long string that contains what schemes it includes per action

#

@plush wasp heres a code i had to write yesterday to find all the player mappings , everything here is strings cs //gets all input bindings in `Player` Action Map that uses the Keyboard&Mouse control scheme var g = Inputs.Player.Get().actions; for (int i = 0; i < g.Count; i++) { if(g[i].name != "Look") { Debug.LogWarning($"{g[i].name}"); for (int j = 0; j < g[i].bindings.Count; j++) { if (!g[i].bindings[j].isComposite && g[i].bindings[j].groups.Contains("Keyboard&Mouse")) Debug.Log($"\t{g[i].bindings[j].path}"); } } }

#

except for .isComposite, thankfully

#

not to mention the path part isnt just the name of the key or anything

#

its stuff like <Keyboard>/shift

#

not sure how editing works yet, hopefully it isnt as bad as i feel like it will be

plush wasp
#

Oh interesting, I hadn't needed to do any kind of processing on the bindings so I haven't discovered that side of it yet

#

I'm worried about how crazy custom user binding is going to be, especially since I have a lot of composite bindings

olive loom
#

yesss the composite thing is so freaking annoying

#

wish there was a way to return a consistent class that has everything separated neatly

haughty spire
#

Hey guys. I created a game using WASD keyboard and mouse. Older people are struggling to use it so I am thinking of converting to an xbox controller. Is this something that can be done easily?

abstract jasper
#

What's the difference between
controls.Ball.Enable();
and
playerInput.SwitchCurrentActionMap("Ball");
?
The second one doesn't seem to do anything on my end

#

This doesn't even work

    playerInput.currentActionMap.Disable();
playerInput.SwitchCurrentActionMap("Ball");
playerInput.currentActionMap.Enable();```
#

Do you need to keep track of all action maps, disabling and enabling manually?

indigo patrol
#

they both are functions...

#

the later receives string as it's param

abstract jasper
#

@indigo patrol

On that page it says Use SwitchCurrentActionMap(String) or just call Enable() directly to enable a specific map.
So they seem to be equivalent. But when this is set to Invoke C Sharp Events, the SwitchCurrentActionMap(String) function doesn't seem to do anything.

#

Setting it to Send Messages seems to work like expected

indigo patrol
abstract jasper
#

I'm trying to get Invoke C Sharp Events working

indigo patrol
#

yes yes.. see the link above

abstract jasper
#

Yep I'm looking, but can't see any mention of switching action maps?

indigo patrol
#

did you you scroll down ?

abstract jasper
#

Yes

#

So I'm thinking it's probably because I'm using the auto generated interface to hook up to the events.
public class PlayerInputReader : MonoBehaviour, Controls.IPlayerActions
...

controls.Player.SetCallbacks(this);```
#

Since I'm hooking up to the callbacks like this, it seems like switching action maps on the PlayerInput component doesn't have any effect

#

Yeah I guess that's it. Since this is like rolling your own instance of the input, you need to enable and disable the action maps manually

#

Would've been nice to use the same function as the other systems

#

Found this thread that provides some insight into why using the wrapper class is different from using PlayerInput, in case anyone's interested
https://forum.unity.com/threads/input-system-generate-c-code-what-its-good-for.995674/#post-6465724
Seems like it's easiest to use one or the other for now

fallow haven
#

How can I read inputs from within the editor for custom tools? I have the new input system installed. Do these need to be actions? I'm trying to read input for scroll wheel (to change brush size) and escape (to cancel painting) from the editor scene view.

neat marten
fallow haven
#

Is it Key.current then?

neat marten
#

Well, I haven't used it in the EditorWindow yet, but this seems to work

if (Keyboard.current.escapeKey.isPressed) {
    Debug.Log("lol");
}
#

Oh, sorry, I missed Editor Scene View part, above example is reading key press from specific EditorWindow, don't know how to read presses from Scene View

fallow haven
#

That's alright thanks for the help, doing most of my scripting in UVS. Someone on their discord just helped me set it up in a script graph.

neat marten
#

Looked at it, alright, so using OnDrawGizmos works

fallow haven
#

nice that's exactly what I'm doing in visual scripting

timber robin
gritty gazelle
#

sorry

timber robin
#

No worries, good luck.

gritty gazelle
#

thx

west oracle
hoary hemlock
#

I need someone to explain local multiplayer to me. I have two Gamepads, and I don't want to use PlayerInputManager because I don't want to "spawn" players.

I have two players in the scene, with int PlayerId = 1 and int PlayerId = 2. I want Player1 to use the first controller (if there is one), Player2 to use the second controller (if there is one), and I also have a keyboard control scheme (one on WASD, other on arrow keys).

Please help.

west oracle
hoary hemlock
#

I don't think that's what I'm looking for. The keyboard works fine. It's the gamepads I'm struggling with.

west oracle
#

also PlayerInput / PlayerInputManager is the easiest path out of the box to wrangle more players. You can spawn all of them at the start too.

#

you can also enumerate gamepads ie:

Gamepad.all[0]

#

will give you the first connected pad

#

are you trying to use InputActions or just raw access to the devices?

hoary hemlock
#

This is my first time using the input system. So I guess I'm using InputActions.

west oracle
#

I also made these 🙂

hoary hemlock
#

I have a PlayerInput component on my player object. How do I tell the player 1 PlayerInput to only listen for Gamepad.all[0], and the player 2 PlayerInput to listen for Gamepad.all[1]?

I guess that's where I'm stuck.

west oracle
#

thats where PlayerInputManager comes in.

#

The gist of it is a PlayerInput object registers an InputUser

#

PlayerInputManager handles binding Device(s) --> InputUser for --> PlayerInput instance

#

you can do that process manually as well, but PlayerInputManager makes it much simpler

hoary hemlock
#

Do you have a tutorial for doing it manually?

west oracle
#

nope, but I should probably make one lol

#

(not the first time these questions have come up)

#

in the meantime this should get ya started 🙂

hoary hemlock
#

Okay, thank you

west oracle
#

additionally, I still recommend using PlayerInput / PlayerInputManager even if you intend on joining players manually. it helps with much of the shenanigans

#

you can manually tell PlayerInputManager to bind/join a PlayerInput instance with the above function

#

(of course be sure to set the Join Behaviour of the manager to "Join Manually" or it will try to do everything for you and fuck it all up)

finite citrus
#

how i can add my joystick as input?

timber robin
#

Damn you're all over this discord.

#

Just so everyone is on the same page, is this a physical joystick you're talking about?

#

Because you're extremely vague about it.

atomic meteor
#

hey all 👋 i've been trying to use this package https://github.com/nullkal/UniSense since Unity doesn't have official DualSense support for the Input System yet. however, the package doesn't work in IL2CPP builds. i'm pretty sure it has something to do with the [FieldOffset] attributes, which IL2CPP doesn't support, according to the documentation https://docs.unity3d.com/Manual/ScriptingRestrictions.html. the Input System itself does work in IL2CPP builds though, which im pretty sure is related to the "Fast" prefixed scripts. according to the comment at the top, this is pre-generated. is there any way that i can pre-generate the custom code so it works with IL2CPP?

finite citrus
#

im so lost with player input, i already have a movement script for player but how do i assign that movement to the player input?

timber robin
#

That's backwards. Input drives movement not the other way around.

finite citrus
#

yeah but, i've created a joystick with on-screen stick script and player input asset, that i assume it would get the same joystick i created, now im confused on how im gonna make that joystick move the player

timber robin
#

How are you reading the joystick input?

finite citrus
#

what do you mean reading

#

i've put my player input in my joystick and now i am trying to access it through player movement script but i don't have axis in my joystick

timber robin
#

That doesn't really mean anything to me.

#

Is this a joystick you made completely yourself? What drives it?

finite citrus
#

or i could use the asset one, but the point is, i always need to create a joystick by myself, if i want to move my camera with cinemachine to put it as a input there, since cinemachine dont allow objects to get dragged there

#

i probably will maintain the movement as it was, or i could mess this up

timber robin
#

Sorry, I have no idea what you're on about.

#

https://youtu.be/YV5KOZHsIz4

Have you tried following a tutorial that would let you control the camera with an on screen joystick?

Learn how to make a third person controller for mobile using the new input system and Cinemachine. Works for Unity 2019.3 and up and am currently using version 2020.1.

At 15:10 I meant to say that the reason we set it to 0 is to avoid the gravity from accumulating when on the ground. If you fell off an edge without jumping your character would ...

▶ Play video
finite citrus
#

yea she creates a player input with the input asset, but then she goes over so much coding that i can't understand. i just want to access the axis of my created input joystick and be able to put it on cinemachine so i can rotate it around those axis, but she goes over quaternions, eulers and god knows what

marble mesa
#

In unity I'm trying have a 2d object rotate with a joystick, I already have set up a input action for it, how would I make that happen in script?

austere grotto
simple obsidian
#

What the input for screen pressed?

inner hinge
#

ive made a mouse look script but when i use a controller it continusly turns left```cs
public class MouseLook : MonoBehaviour
{

public float Xrotation = 0f;
public float mouseSensitivity = 1f;

public Transform playerTransform;
public void Update()
{
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;


    Xrotation -= mouseY;
    Xrotation = Mathf.Clamp(Xrotation, -90f, 90f);

    transform.localRotation = Quaternion.Euler(Xrotation, 0f, 0f);
    playerTransform.Rotate(Vector3.up * mouseX);
}

}

ill send you the input manager


there are 2 each
austere grotto
#

mouse axes report the delta of the mouse position

#

joystick reports how much the joystick is currently tilted

inner hinge
#

so how could i doo both?

austere grotto
#

I don't really understand what you're going for. I would expect the character to continuously turn as long as the joystick is held down

inner hinge
#

thats what i want

#

but it dosent work

#

it just turns left constantly

frosty raft
#

Debug.Log your controller
It could have drift

inner hinge
#

how would that work?

#

what would i log?

frosty raft
#

Whatever the input you're using to turn

#

Another trick is to just unplug the controller, if the turning stops it's probably your controller at fault

austere grotto
#

Why is your joystick axis also called "Mouse X"?

inner hinge
#

it dose that is whta im saying

austere grotto
#

that might be an issue too

inner hinge
#

ok

#

ill try that

frosty raft
inner hinge
frosty raft
#

Increase the input's deadzone I guess

inner hinge
#

ok*

frosty raft
#

If that doesn't help you need a new controller

#

Or to recalibrate it

inner hinge
#

ok i set the dead zone to 1 and it still turns the same

#

ok i pluged a modded ps4 ctrler and it didnt work period

#

ill try a new normal ps4 ctrller

finite citrus
#

why does the new input system does not detect android inputs?

glacial needle
#

I've been searching for 2 days and haven't found a straight answer that actually works yet, how do i implement customizable controls (new system)??? Everything I've found doesn't work and/or is way too far beyond my current coding knowledge for me to try to make it work

austere grotto
glacial needle
#

yeah i did

austere grotto
#

there are some video tutorials floating around for it

glacial needle
#

can you link one that actually works then

austere grotto
#

If it's above your knowledge - not sure what to do. Maybe look into Rewired?

glacial needle
#

i already have the movement script and i cant restart it

glacial needle
glacial needle
#

it just shows up as a different key, maybe it remaps something but when i switch scenes to actually use it, it's gone

mighty rain
#

i am missing publishing settings

#

please help me

finite citrus
#

how do i fix my android input system please

deft berry
finite citrus
#

idk whats wrong too

#

because it was working fine before i installed the new input manager

#

i already tried switch to the old one but isntr working

deft berry
#

did you select your event system in the hierarchy and make sure to click the button to update it to the input system?

#

it will look like this

finite citrus
#

yea i did that

deft berry
#

okay then you will need to provide more context. nobody here is going to magically know what is going wrong with your stuff if you cannot provide any errors, relevant code, or really anything

finite citrus
deft berry
#

is it responding to mouse input in the game view? is it only happening when you test on an android device? please actually describe your issue

finite citrus
#

i didnt change any coding so

deft berry
#

so when you updated to the new input system you didn't actually update any of your code to work with the input system?

finite citrus
#

not really, how could i update it?

finite citrus
#

thanks but where am i supposed to use this

deft berry
#

That information tells you which methods to switch to using if you are migrating from the old input to the new input system

tame oracle
#

SketchUp 2017:

#

Unity 2021:

#

How do i fix this lighting color changing thing? I mean it doesn't look the same

timber robin
#

@tame oracle What does this have to do with input?

The lighting and shading between Unity and sketch up are not going to be the same. You need to recreate the "look" in Unity as best as possible.

tame oracle
#

ohhh okah thank you!

polar compass
#

I'm tearing my hair out, There seems to be a million different ways to use the new input system, could anyone please link me a good tutorial to learn HOW to use it? To learn how it works, but necessarily how to make 2d/3d movement, but how it works

#

If that makes sense

timber robin
zinc stump
timber robin
#

You're right there's a lot of different ways to use it, which is a bit confusing. But also powerful. It took me a while to decide on the implementation that works best for my style of coding.

polar compass
polar compass
finite citrus
#

i have problem with my game, i want to rotate my cinemachine camera but this originates a problem that will cause my player to move and rotate the camera at the same time, how could i solve this issue? both movement and camera rotations are joystick so this is happening

timber robin
polar compass
polar compass
timber robin
#

Maybe. It had a Viking character.

polar compass
#

Yea, that's it then, thank you!

#

Active Input Handling, can i just put this on Both to avoid errors? Or should i force myself to use the new one?

#

Getting errors related to Conemachine

zinc stump
#

Some packages use Input system, I think they have settings to turn it off. But if you want to keep using both set it to both.

finite citrus
#

@timber robin can i ask this question in unity-talk? this channel is a bit inactive

olive loom
finite glen
#

Doesn't setting it to use both have a big overhead?*

zinc stump
#

Have no idea about that. You can look this up online.

finite citrus
austere grotto
polar compass
#

So if i post code, will the code be collapsed for others?

#

I've setup a very basic Vector2 movement in a 3d world, with a sprint option, and would love it if someone could have a quick look and let me know if im going in the right direction

#

I'm basically taking the V2, changing it into V3 (context.x, 0, context.y)

#

Multiply by movespeed/time.deltatime, and perform the move in an FixedUpdate method

#

And a button input checking context.performed (sets isSprinting = true), and contect.canceled sets isSprinting = false

#

And in my update, i check wether character is sprinting or not

#

I THINK I'm on the right track, but would love to get it confirmed de debunked ❤️

timber robin
#

That sounds right to me. Assuming you're using a rigidbody for the FixedUpdate.

south void
#

Been trying to make a simple jump button work with the new input system, but I can't get it to work, my button has the press interaction, then I read the value as context.performed because started doesn't work, but it keeps reading as true, so my player keeps jumping

austere grotto
south void
#

I thought that's how it's supposed to work

#

I just want it so that just pressing it at that moment enables a bool, then disables it afterwards

south void
# austere grotto why use the press interaction?

it says on the docs that you can use the Press interaction to detect it

UnityEngine.input.GetButtonDown
See UnityEngine.Input.GetAxis for how to set up a binding to a button or axis. You can use the Press interaction to detect when a button is pressed.
south void
#

I switched it to ButtonControl, still doesn't work

south void
#

I don't even know why it's not working as intended, it's set to Invoke Unity Events here, and it's called as is above

#

wasPressedThisFrame doesn't get set to false even if it's not that frame

austere grotto
austere grotto
#

No need to check the InputControl

#

Press interaction is only if you want to customize how it detects the press

south void
austere grotto
south void
#

I feel like there's a better way to do this, but I'll try it I guess, I swear I've done this before, but I don't have the project that has it

#

I used InputControl because wasPressedThisFrame sounds exactly like what I'm looking for @austere grotto

austere grotto
#

And it obeys the configuration rules of your input action

south void
#

not sure how to deal with this all honestly, since my player has states

austere grotto
#

States responding to input events is like the textbook paradigm for state machines.

#

Each state, it should have a defined response to each input event

south void
#

so, disable my jumping bool as my idle goes to jump?

austere grotto
#

for example If you're in the standing state, and you receive a jump input - you should transition to the jumping state

#

just an example

neon needle
#
    {
        if(Input.GetButtonDown("Oculus_CrossPlatform_PrimaryIndexTrigger"))
        {
            Debug.Log("P Index trigger pressed");
            FirePortal(0, leftController.gameObject.transform.position, leftController.gameObject.transform.forward, 250.0f);
        }
        else if (Input.GetButtonDown("Oculus_CrossPlatform_SecondaryIndexTrigger"))
        {
            Debug.Log("S Index trigger pressed");
            FirePortal(1, rightController.gameObject.transform.position, rightController.gameObject.transform.forward, 250.0f);
        }
    }``` i never get any output. any idea what im doing wrong?
austere grotto
#

Did you set those buttons up in your input manager?

neon needle
#

yeah

#

they get auto created by something else i dont know what

#

some oculus stuff probably lol

austere grotto
#

Put a debug.log outside of the if statements

#

make sure your Update() is actually running

neon needle
#

i cant even spell spam smh

austere grotto
neon needle
#

is it ok that some bindings have no button assigned and only an axis

#

actually wait its not really a button its aqn axis so would i have to have a loop that checks the value of the trigger

austere grotto
neon needle
#

i just changed it to that and will check if ti works after the battery charges, thx

austere grotto
#

oof

#

man I want to get a VR for fun and development but it really seems not ready for primetime yet

obsidian portal
#

Its pretty fun in certain scenarios

neon needle
#

i got the quest 2 and for how much it was id say it was worth it

obsidian portal
#

Love me some beat saber and Superhot

neon needle
#

pavlov >>>>>>>>>

obsidian portal
#

I really like the games where the space around you is the space you move in, as oppose to a joystick/teleport movement

#

But thats just me

#

Like Job Sim and Vacation Sim do that well

exotic root
#

Has anyone had any issues reading input from the InputSystem in DOTS? Particularly using buttons? I'm having the strangest problem with it, where I'll miss frames where .triggered is true. I switched to using the old Input and my code runs fine so I'm pretty sure its InputSystem.
It occasionally works, which is part of the strangeness.

austere grotto
exotic root
#

Attempting to read a button press just to jump

#

There is the input system (just using the "Fire" button to jump for now)

#
[UpdateInGroup(typeof(CopyManagedDataToComponentSystemGroup), OrderFirst = true)]
public class InputSystem : SystemBase
{

    // Get an instance of the InputSystem
    private readonly CCInput _input = new CCInput();

    protected override void OnCreate()
    {
        base.OnCreate();

        // Create Singleton Entities for each Action Map
        EntityManager.CreateEntity(typeof(PlayerInput));
        
    }

    protected override void OnUpdate()
    {
        
        // Populate input components with input data

        if (HasSingleton<PlayerInput>())
        {
            if (!_input.Player.enabled)
            {
                _input.Player.Enable();
            }
            var playerInput = new PlayerInput
            {
                Move = _input.Player.Move.ReadValue<Vector2>(),
                Look = _input.Player.Look.ReadValue<Vector2>(),
                Fire = _input.Player.Fire.triggered
            };
            SetSingleton(playerInput);
        }
        else
        {
            if (_input.Player.enabled)
            {
                _input.Player.Disable();
            }
....
#

Here is the code where I read from the InputSystem

#

Let me know if you'd like to see the rest of the code in that file

#
public class PlayerMovementSystem : SystemBase
{
    protected override void OnUpdate()
    {
        
        PlayerInput playerInput = GetSingleton<PlayerInput>();
        
        Entities.WithAll<PlayerTag>().ForEach((ref CharacterController characterController) =>
        {

            float movementX = playerInput.Move.x;
            float movementZ = playerInput.Move.y;
            
            if (!MathUtils.IsZero(movementX) || !MathUtils.IsZero(movementZ))
            {
                characterController.CurrentDirection = new Vector3(movementX, 0.0f, movementZ).normalized;
                characterController.CurrentMagnitude = true ? 1.5f : 1.0f;
            }
            else
            {
                characterController.CurrentMagnitude = 0.0f;
            }

            characterController.Jump = playerInput.Fire;

        }).ScheduleParallel();
        
    }
}

And here is where I read from the playerInput singleton and apply it to the charactercontroller of the player

#

When I swap characterController.Jump = playerInput.Fire with characterController.Jump = Input.GetButton("Fire") or something similar (I got rid of the code so that may not look exactly right) jumping worked fine, but otherwise the jumping only works occasionally/randomly;

#

Movement works fine with InputSystem so I'm assuming its something to do with the Action Type Button

austere grotto
# exotic root

I would recommend not using the Press interaction. it's only there for customizing the press point basically

exotic root
#

Thanks, I actually just added that to see if it would fix the problem

#

I'd been having the issue before without Press

#

I'll get rid of it now tho

austere grotto
#

Also try:

Fire = _input.Player.Fire.ReadValue<float>() > 0```
exotic root
#

whoooaaaaa

#

i think that worked

#

yes i think its good now

#

tyvm

#

was using .triggered not the right way to do this?

austere grotto
#

if you check the docs

#

Whether the action was triggered (i.e. had performed called) this frame.

exotic root
#

Yeah is that not what I wanted? I thought that made sense

austere grotto
#

You have Input.GetButton("Fire")

#

that's true every frame as long as it's held down

#

idk is that not what you want?

exotic root
#

Ah yeah I probably meant GetButtonDown

#

i mean it works so I'm happy haha

austere grotto
#

🤔

#

hmm

exotic root
#

I just wanted to read the frame the button was pressed

#

And have that make the char jump

austere grotto
#

You could also try:
Fire = _input.Player.Fire.phase == InputActionPhase.started

#

I'm not super familiar with DOTS but is OnUpdate guaranteed to run every frame?

exotic root
#

that also seems to work fine

#

hmm i believe so

#

i'm also new, this is all just me experimenting tbh

#

i wasn't expecting to get stuck so early tho hahaha

austere grotto
#

ok - the started phase thing should be more like GetButtonDown and checking if ReadValue > 0 should be more like GetButton

exotic root
#

makes sense

#

Issue is fixed so I'm happy, thanks again

austere grotto
#

np

exotic root
#

any idea why .triggered wasn't working?

austere grotto
#

but started is pretty consistently when you first start actuating the control

#

so...

#

¯_(ツ)_/¯

#

what binding do you have set up?

#

Space key?

exotic root
#

left mouse button

#

i'll try space key rn

#

same issue when i switch to space

austere grotto
#

idk - but it's working with the started phase thing?

exotic root
#

yes

austere grotto
#

cool

exotic root
#

so i'm happy, was just curious

#

appreciate the help

austere grotto
#

np

abstract jasper
#

Has anyone been able to get local splitscreen with per-player UI working with the new input system?

digital narwhal
digital narwhal
# exotic root any idea why .triggered wasn't working?

I use InputSystem with DOTS, it works perfect. .triggered will run ONLY one time (one frame) the moment the button passes the press threshold, and that's it. If you want to know if the button is being 'held' down in any given frame, you'll want .ReadValue instead.

For DOTS, depending on what I need, I have it setup like this:
var playerPrimary = input.Player.Primary.triggered;
var playerWantsPrimary = input.Player.Primary.ReadValue<float>() >= InputSystem.InputSettings.defaultButtonPressPoint;

olive loom
#

is enabling/disabling an input system action map actually this expensive?

nimble garnet
#

I'm messing around with a piece of code that I found that's meant to vary the height of your jump based on how long you press the button for. My only problem is that the code is written with the Unity's old input system and I'm trying to transfer it over to the new system.
Here's the original code:

if (rb.velocity.y < 0)
        {
            rb.AddForce(gravity * fallMultiplier, ForceMode.Acceleration);
        }
        else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            rb.AddForce(gravity * lowJumpMultiplier, ForceMode.Acceleration);
        }
        else
        {
            rb.AddForce(gravity, ForceMode.Acceleration);
        }
 }```
And here's what I have:
I have two scripts: PlayerController and JumpModifier.
PlayerController has:
```cs
    [SerializeField] public bool jumpButtonRelease;

public void Jump(InputAction.CallbackContext context)
    {
        if (isGrounded)
        {
            jumpRequest = true;
        }

        if (context.canceled)
        {
            jumpButtonRelease = true;
        }
}```
JumpModifier has:
```cs
[SerializeField] private float fallMultiplier = 2.5f;
    [SerializeField] private float lowJumpMultiplier = 2f;
    private float gravityScale = 1f;
    private float globalGravity = -9.81f;

void FixedUpdate()
    {
        Vector3 gravity = globalGravity * gravityScale * Vector3.up;

        if (rb.velocity.y < 0)
        {
            rb.AddForce(gravity * fallMultiplier, ForceMode.Acceleration);
        }
        else if (rb.velocity.y > 0 && playerController.jumpButtonRelease)
        {
            rb.AddForce(gravity * lowJumpMultiplier, ForceMode.Acceleration);
            playerController.jumpButtonRelease = false;
        }
        else
        {
            rb.AddForce(gravity, ForceMode.Acceleration);
        }
    }```
#

I thought that this would work but unfortunately it doesn't. From what I've gathered so far, when I used Debug.Log on jumpButtonRelease in FixedUpdate, it seemed like jumpButtonRelease only became true if you hold the jump button for long enough. So in the end, the player never does a short jump because jumpButtonRelease doesn't become true fast enough. Help would be appreciated. Either by fixing this or pointing me to a way where I can do short jumps with the new input system. I tried finding methods to this with the new input system, but no dice.

nimble garnet
#

Also based on the Migrate from Old Input System guide, the isPressed property seems like it could work but I can't quite figure out how to use it with the code that I have.

olive loom
#

What am i doing wrong? This is some insane performance hit for the new input system

#

Not even sure which part is actually doing this, just that it involves the mouse

austere grotto
olive loom
#

im just enabling/disabling the player maps while in the menu

tidal jackal
#

Hey guys I have installed rewired and I have used it and it works, my ds4 controller works perfectly.
It doesn't work in the build on mobile thought.
Pls help me
I have tried unity remote too, on pc it works, on mobile it doesn't

#

Idk if this is the right channel to ask but I am not understanding why on mobile it seems like not registering input

#

Ping me whenever you want to help me

dense ridge
#

what is the axis for right stick in untiy 2020

#

for joystick

uncut creek
#

hey, trying to get my menu working with the new input system, but I'm feeling a bit stuck. I added an InputSystemUIInputModule to my event system, and assigned it the player controls asset that has the UI controls mapped, but nothings working other than my mouse. not seeming to get any navigation events from keyboard or gamepad

austere grotto
#

(the one that's preconfigured on the module)?

uncut creek
#

nope 🙁

#

ok well I just removed the whole even system and made a new one, and now it works 😅 must have screwed something up along the way. thanks for the help

plucky flint
#

Using new unity input system.
I have a Player Input component that handles all player input for non-UI actions. And the eventSystem's "Input System UI Input Module"
The "Fire" button and the "Submit" button are the same keybind. The Fire button opens the menu, but then instantly clicks the selected button. This happens even if the UI Input Module is disbabled when the fire button is pressed. Has anyone seen this and know why this is happening?

austere grotto
#

my workaround is to alternately enable/disable the action maps as needed.

#

Only enable the UI action map when you open the menu

#

I think I may have even done something where I waited one frame after opening the menu before enabling the UI action map

plucky flint
#

Is the UI action map enabled while the UI input module is disabled?

austere grotto
#

They are independent

plucky flint
#

Ah, then that may be a simple fix. I thought disabling the UI input module would disable input... Let me try that

tender folio
#
playerControlsMap.Land.Move.ReadValue<float>();```Gives me the normalized value, so roughly the same functionality as `Input.GetAxisRaw("Horizontal")`. How do I get the same functionality as the non-normalized version, `Input.GetAxis("Horizontal")`?
austere grotto
#

GetAxis performs smoothing

tender folio
#

Yeah I noticed that

#

I'm doing my own smoothing now :p

#

Do you know any ways to smooth though?

austere grotto
#

have a separate float axisValue variable that you MoveTowards the actual input value

tender folio
#

That would mean I also smooth vertical velocity though

austere grotto
#

?

#

I'm talking about the input value

tender folio
#

It's a 2d platformer

austere grotto
#

Actual Input value -> feeds into your smoothed input value -> feeds into whatever you do with the input value

tender folio
#

Oh, cause I'm smoothing velocity now

austere grotto
#

that's different

tender folio
#

Well then I guess I should ask, do you know any ways to simulate acceleration?

austere grotto
#

do you know how acceleration works?

tender folio
#

I mean I know some people literally just increment the velocity until it reaches a certain max limit

austere grotto
#

that's how acceleration works basically so yeah

tender folio
#

Isn't that too linear though?

austere grotto
#

is it?

#

up to you

#

you can use any easing function you want

tender folio
#

Alright

austere grotto
#

THere's SmoothDamp

#

or get something like DOTween which offers 85 different easing functions or whatever

#

and do as you please

tender folio
#
playerControlsMap.Land.Jump.triggered```How do I get this, but for if the player is holding the button?
#

triggered seems to only return true the frame the player pressed the button.

austere grotto
#

set a bool to true in started

#

false in canceled

tender folio
#

Alright

austere grotto
#

or do : playerControlsMap.Land.Jump.ReadValue<float>() != 0

tender folio
#

Oh I like that better, thanks :)

whole solar
#

Hi i wasnt sure if this was the place to ask this, but is ther a way to change the input to scroll through a scroll rect? i know of pc is default to scroll wheel or click and drag but i want to set it to scroll with a custom input. is this posible?

austere grotto
#

whatever axis or InputAction is set there

whole solar
#

okay.. do you mean in input manager?

austere grotto
#

I mean the InputModule component

#

usually it's on your Event System GameObject

whole solar
#

ohhh. ill look

#

thanks

slate jetty
tidal jackal
#

Does new input system supports dualshock 4?

tidal jackal
#

I know it doesnt support usb wireless adaptor but does it supports bluetooth?

misty locust
#

It supports dualshock4, I don’t know about bluetooth though. I think it should.

leaden sequoia
#

i think it does as long as you use DS4 windows, i guess

misty locust
#

“We do not support the "DualShock 4 USB Wireless Adaptor" to connect a PlayStation controller to a desktop machine. Use USB or Bluetooth to connect it.”
Okay they do support it.

#

Not sure about dualsense though, I wanted to know about that. My dualsense just gives wrong input in game except leftstick 😐

tidal jackal
#

how about on mobile?

fringe veldt
#

Hey I need some help regarding input system on games for my project. Pls dm me I'll appreciate it very much

timber robin
fringe veldt
#

Ok thx for telling actually im new here

open breach
#

What is this channel? Its Input.Getkey gang?

neat marten
#

It's old and new Input System 🙂

west oracle
tidal jackal
#

does rewired can be used on unity remote too?

#

or I have to do a build?

#

basically I am using my dualshock 4 connected to my phone (bluetooth) connected via usb to my pc

#

doesn't seem to work

#

altought it works perfectly when ds4 is connected to pc

somber bluff
#

I'm creating a local multiplayer game using the new Input System.

I'd like a shared main menu where anyone can change the selected button. Followed by a character select screen whereby each player chooses their own character settings.

I can get multiple inputs mapped to 4 different sets of buttons on the screen. But I cannot figure out how to have a shared UI... anyone else come across this?

tidal jackal
#

ok I did the build

#

but rewired doesnt work

#

on mobile

#

I am using the ds4 but on mobile it doesnt work

#

but It works fine on editor

somber bluff
tidal jackal
#

yeah

#

maybe you could disable rendering for 3 out of 4

#

so maybe it works but you dont see them (to improve performance)

#

idk there is surely a better way

somber bluff
#

yea, because that way you're gonna have each player selecting different buttons on their own unrendered canvas

#

it's a pain in the ass, been trying to figure this out 3 or so days now

tidal jackal
#

and still I can't use cross to jump

#

in the editor it works

slow crest
#

does anyone know how to have an anolog stick control an object on a canvas? its currently controlling the object but it resets its position when i let go of the stick. i want the object to always be traveling additivly across the canvas (retaining its position)

tidal jackal
#

@slow crest maybe you can make a sort of "record" or maybe you save the position of the joystick in the last 2 frames, if it the stick gets close to the center really fast you block the stick

slow crest
#

@tidal jackal i hav already tried that. there should be a simpler way

tidal jackal
slow crest
#

yeah, it doesnt work becasue what if i want to move the stick back to the center slowly? it wont return the corect vector2 value i need @tidal jackal

tidal jackal
#

it should

tidal jackal
slow crest
#

how would you do it? or do you know of a link

tidal jackal
#

idk

#

I have done something similiar for my game tho

#

but instead with momentum

#

its a weird story of how I implemented a mechanic...

slow crest
#

@tidal jackal im just trying to translate an image across the screen uning the joystick and/or the mouse position at the same time

tidal jackal
#

oooh i know how to

#

you can create a fake mouse

slow crest
#

already did that

tidal jackal
#

instead of doing something like mouse_pos = get.axis
you can do mouse_pos += get.axis

slow crest
#

the problem is that the fake mouse needs to control the real mouse position as well as the image. and the mouse position needs to controll the fake mouse and the image at the same time. they clash

tidal jackal
#

you dont have to worry about the stick going back

tidal jackal
slow crest
#

how though?

#

how do i have two things control eachothers values?

#

thats like asking you to pick yourself up off the ground. its justy physically impossible

tidal jackal
#

//C#
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
int xPos = 30, yPos = 1000;
SetCursorPos(xPos,yPos);//Call this when you want to set the mouse position

#

idk what this is

#

i copy pasted

slow crest
#

ok better question. @tidal jackal do you know how to change the mouse position without moving the mouse

tidal jackal
#

but should work

tidal jackal
slow crest
#

oh i see

#

i don't understand the three middle lines of code and why they are necissary

tidal jackal
#

also ik nobody cares because this is a unity server but in python its
import pyautogui

pyautogui.move(100,100)

tidal jackal
#

I think first you immport namespace then a dll and then a bool from dll that makes everything work

slow crest
#

@tidal jackal im not a fan of copy pasting code into my project. there has to be a better solution

#

thanks for the help, i'll continue fighting my way through this

tidal jackal
slow crest
#

@tidal jackal im not looking for fast response time. im looking for a clean way to write the code

slow crest
tidal jackal
slow crest
#

Clean code does not mean "less" code

tidal jackal
# tidal jackal and still I can't use cross to jump

to anyone who wants to help me here is my question, also I didn't specify that I have this error:
Autoconnected Player Rewired: [ERROR] ControllerDataFiles is missing critical data! The serialized data may have been corrupted. Please see the Known Issues in the documentation for possible causes and solutions.
------- Rewired System Info -------
Unity version: 2020.1.3f1
Rewired version: 1.1.36.0.U2019
Platform: Android
Using Unity input: True
Native mouse handling: False
Enhanced device support: False
Android: Support Unknown Gamepads: True

tidal jackal
tidal jackal
#

pls somebody help me

slow crest
#

@tidal jackal ok so i figured out half of it just now, all i need to do is convert the mousposition value to a additive value i think?

tidal jackal
#

Yes

slow crest
#

@tidal jackal ok i actually figured it out with only 4 lines of code lmao

#

its done

tidal jackal
#

So that for example axis is negative mouse pos was 800 += axis (-1) * sensivity

tidal jackal
worn cape
#

is there a list that shows what to type in code if i want to get input from (spacebar) or (the letter g) or (right mouse click)

glad trail
#
    private void Update() {
        var input = Input.inputString;
        if (!string.IsNullOrEmpty(input))
            Debug.Log("Pressed char " + input);
            switch (input){
                case "q":
                    Debug.Log("Q Logic");
                    break;
                default:
                break;
            }

    }
#

using this to process input, is there an article on the best practises? this doesnt account for cases like mouse buttons or spacebars

worn cape
#

ty

quaint plume
#

anyone know why the player can only move right and backwards not forwards and left. ```c
using UnityEngine;

public class InputManager : MonoBehaviour
{
#region Variables
[Header("Movement Axis")]
[SerializeField]
private string m_forwardAxis = "Vertical";
[SerializeField]
private string m_sidewayAxis = "Horizontal";

[Header("Weapon Keys")]
private KeyCode m_aimKey = KeyCode.Mouse1;

[Header("Camera Axis")]
private string m_verticalLookAxis = "Mouse Y";
private string m_horizontalLookAxis = "Mouse X";
private float m_xAxisSensitivity = 0.5f;
private float m_yAxisSensitivity = 0.5f;

protected float m_forward;
protected float m_sideway;
protected bool m_aiming;
protected float m_xAxis;
protected float m_yAxis;
#endregion

#region Properties
public float Forward
{
    get { return m_forward; }
}

public float Sideway
{
    get { return m_sideway; }
}

public bool Aiming
{
    get { return m_aiming; }
}

public float XLookAxis
{
    get { return m_xAxis; }
}

public float YLookAxis
{
    get { return m_yAxis; }
}
#endregion

#region BuiltIn Methods
private void Update()
{
    HandleInput();
}
#endregion

#region Custom Methods
protected void HandleInput()
{
    m_forward = Input.GetAxis(m_forwardAxis);
    m_sideway = Input.GetAxis(m_sidewayAxis);
    m_aiming = Input.GetKey(m_aimKey);
    m_xAxis = Input.GetAxis(m_horizontalLookAxis) * m_xAxisSensitivity;
    m_yAxis = Input.GetAxis(m_verticalLookAxis) * m_yAxisSensitivity;
}
#endregion

}

austere grotto
quaint plume
#

ok well the project is using final ik maybe that is doing it?

austere grotto
#

no idea. It's definitely related to however you're moving the character, and this script is only part of that

#

how are you taking these input values and moving the character?

quaint plume
#

i have no idea i found this project on a website for unity tutorials and im just trying to learn from it

austere grotto
#

Well the first place I'd look is to do a "Find All References" on the public properties in this script like Forward

#

that should take you to the script that actually moves the player

#

assuming that script actually uses the input data from this one

quaint plume
#

ok well i got a lot of results

austere grotto
#

Do you know what "IK" is?

quaint plume
#

not really

austere grotto
#

It's "Inverse Kinematics". It's a technique to line up a character's appendages with things they are holding or reaching for or standing on or otherwise interacting with

#

It generally is not directly related to movement

quaint plume
#

oh ok so i need to not look in the stuff related to "IK".

austere grotto
#

You should be looking for a script called something like "Player Controller" "Player Movement" "Character Movement"

#

something along those lines

quaint plume
#

nothing with those names

austere grotto
#

Idk - without seeing the projetct I'm shooting in the dark here and it seems so are you

#

Maybe start by looking at the scripts that are attached to the player?

quaint plume
#

was just about to send a pic of that lol

#

and there's nothing ive not looked in before so

austere grotto
#

"Locomotion"

#

does that word mean anything to you?

quaint plume
#

i mean not really im stupid

austere grotto
#

it's what you're looking for

quaint plume
#

oh ok well if i send the script can you tell me why i can only use S and D to move the player but that arrow keys work fine

austere grotto
#

maybe

austere grotto
quaint plume
#

ok but i don't see anything in the Input Manager that would help me although i am stupid so maybe

austere grotto
#

Look at the "Horizontal" and "Vertical" axes and see what keys are bound to them

quaint plume
#

what one the player game object?

austere grotto
#

no, in the input manager

#

Proejct Settings -> Input Manager

quaint plume
#

oh that one i got a script with that name ok let me check

#

got it thanks

tidal jackal
hexed needle
#

hello everyone, is it possible to export a package of a scene including the input system?🤔

harsh narwhal
#

Is there a way to totally disable the input system, like during a transition?

austere grotto
harsh narwhal
#

thank

whole scroll
#

How can I get the position on Press action?

austere grotto
whole scroll
#

the press

austere grotto
#

The press of what

#

a press interaction can be on literally any input action

whole scroll
#

For example the press of a primary touch

austere grotto
#

Ok so touch position

whole scroll
#

yeah, or mouse

austere grotto
#

You'd make an InputAction that is bound to pointer position

#

and read the current value of that action with pointerPositionAction.ReadValue<Vector2>()

whole scroll
#

i mean i do right now but it's kind of state-machine-ish

#

cause i have to wait for the position event to come first before i know where he pressed

#

or does position come first, i wouldn't think so

austere grotto
#

you can read the current value of the action at any time

#

the entire input asset is refreshed at the same time

whole scroll
#

So when the Input Action Press is called, would the Position action hold the right value?

austere grotto
#

yes

whole scroll
#

cool

quaint plume
#

anyone know why this script is not working i have all the ground objects tags set just not working ```c
//jump script for a 3d object
//attach script to player

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

//make sure you save the script as "playerJump"
public class playerJump : MonoBehaviour {

//variables that are set
Rigidbody player; //allows what rigidbody the player will be
private float jumpForce = 1000f; //how much force you want when jumping
private bool onGround; //allows the functions to determine whether player is on the ground or not


//the first thing to happen at runtime
void Start() {
    //grabs the Rigidbody from the player
    player = GetComponent<Rigidbody>();
    //says that the player is on the ground at runtime
    onGround = true;
}

//checks every frome if the parameters are met to start the function
void Update() {
    //checks if the player is on the ground when the "Jump" button is pressed
    if (Input.GetButton("Jump") && onGround == true) {
        //adds force to player on the y axis by using the flaot set for the variable jumpForce. Causes the player to jump
        player.velocity = new Vector3(0f, jumpForce, 0f);
        //says the player is no longer on the ground
        onGround = false;
    }
}

//checks if player has hit a collider
void OnCollisionEnter(Collision other) {
    //checks if collider is tagged "ground"
    if (other.gameObject.CompareTag("ground")) {
        //if the collider is tagged "ground", sets onGround boolean to true
        onGround = true;
    }
}

}

austere grotto
#

What are you expecting to happen, and what is happening instead?

quaint plume
#

nothing is happening at all the player has the script and when i press space nothing happens and this time it is the right keys in the input manager

austere grotto
#

I'd guess then that your OnCollisionEnter is not running, or if it runs, the objct you collided with is not tagged properly

#

first step - Add some Debug.Logs

#
    void OnCollisionEnter(Collision other) {
        Debug.Log($"OnCollisionEnter called. We collided with {other.name} which has tag {other.tag}");
        //checks if collider is tagged "ground"
        if (other.gameObject.CompareTag("ground")) {
            //if the collider is tagged "ground", sets onGround boolean to true
            onGround = true;
        }
    }```
#

that's the first one I'd add - look for that in the console and see what's going on

#

I'd also add one here to make sure the jump code is running:

        if (Input.GetButton("Jump") && onGround == true) {
            Debug.Log($"Ok we're jumping now!");
            //adds force to player on the y axis by using the flaot set for the variable jumpForce. Causes the player to jump
            player.velocity = new Vector3(0f, jumpForce, 0f);```
quaint plume
#

ok ill give this a try

#

ok fixed that error but now its saying im jumping but the player doesn't move

austere grotto
quaint plume
#

my Locomotion script i think is controlling the rigidbody

austere grotto
quaint plume
#

would you be able to add the jump script into that file for me as i don't know how i did try but got really confused

olive loom
#

How do i detect if its a controller being used or a mouse?

hearty lance
#

its not tracking my mouse delta for some reason, even when moving the trackpad, any reason why this would be?

austere grotto
hearty lance
austere grotto
teal yacht
#

Does anyone have a tutorial, article, or reference that I can follow to understand how to create a controller/input device key binding using the new unity input system? (say I want to allow the player to change JUMP from south button to R)

teal yacht
#

awesome thanks - runtime rebinding is what I was looking for

subtle moat
#

hello im using the new input system, im trying to do a hold button sprint, whats the action for that? e.g sprintControl.action.(?)

#

as far as i know .triggered is when the button is pressed, is there one where when the button is being held?

austere grotto
subtle moat
#

thanks! : )

hearty lance
#

i started using the new input system and everything was working great until i realized that now for some reason the character controller only moves the player by the world position rather than local position, any help with this would be appreciated

rustic plume
#

you can set playerVariable.transform.localPosition instead of playerVariable.transform.position

#

@hearty lance

hearty lance
#

public void Update()
{
controller.SimpleMove(PlayerMove * playerSpeed);
}

public void Move(InputAction.CallbackContext context)
{
Vector2 move = context.ReadValue<Vector2>();

    PlayerMove = new Vector3(move.x, 0, move.y);
}
rustic plume
#

oh i see

hearty lance
#

thats the movement

rustic plume
#

well you can use its world position plus an offset to effectively change its local position

hearty lance
#

any examples on how to do that..?

rustic plume
#

like Vector2.move = transform.position + context.ReadValue<Vector2>();

#

so offsetting it from its world position by the input amount which i assume is what context.readvalue is

#

idk if that would work any differently it probably wouldn't now that i think about it

hearty lance
#

i hate that it went from local to global just because i switched input systems

hearty lance
austere grotto
cobalt mason
#

Would it be possible to assign scroll wheel +/- to the same input as dpad up/down? I'm having no luck so far

storm hearth
#

i downloaded the new input system but then regretted it and removed it. how do i switch back to the input manager?

#

nvm found solution (project settings, player, active input system)

flat raft
#

Just tested a WebGL build using the new Input System, and IMGUI buttons don't seem to be recognized. Changing to the old input system, the buttons works as normal. Any tips as to why?

austere grotto
#

New Input system uses its own input module

flat raft
#

The exact same setup works just fine in a windows build too

austere grotto
#

Would seem to be a bug then 🤔

flat raft
#

Thanks for the info

worthy phoenix
#

Does anyone know how to get a Playstation 5 controller to be recognised properly by Unity?

glass yacht
#

I'd love to know how you're meant to multiply just joystick input by deltaTime when using it in combination with mouse input for a look action. Where of course the mouse portion of the input does not need to be scaled.

#

The docs have an example that does not do it

#

and just says "You can write code that is agnostic to where the input is coming from", yahuh, I could write something broken

#

I imagine you could write a processor that scales by deltaTime and only apply it to the joystick?

novel lance
#

Hello im using Unity 2018.3.8f1 and my player character suddenly stopped being able to look up and down. I imported images from a different project to use as sprites for a UI but that was all. I restarted Unity but that didnt fix it. Would anyone have any suggestions for how to fix this? (For now I cant switch out of 2018.3.8 to the newer engines)

wild orchid
#

Hello everyone 🖐️ , i wanted to ask something

at the moment I am trying to learn the new input system. I would like to know if you use the component "Player Input" or if you use the C# auto generated class, and why

I'm a bit lost at the moment and clearly there are 30 different ways to use it, I prefer to ask for help

hazy jetty
#

hi all

#

i can not get my public void to show up as a input action, how come?

#

does not show in the dropdown

hazy jetty
#

ok wtf?

glass yacht
#

Look at your event system

hazy jetty
#

got it

#

Also is UIInputs a reserved keyword?

deft burrow
#

How would I be able to get the value of this callback context?

            
            if(value.phase == InputActionPhase.Started){
                Debug.Log(value);        }        }```
#

I'm trying to get the -1 from this debug.log

glass yacht
#

is it not value.value?

#

Or, value.ReadValue<int>(); perhaps

deft burrow
#

ill try it out

#

Debug.Log(value.ReadValue<int>());
Doesnt work unfortauntely

hazy jetty
#
using UnityEngine;
using UnityEngine.InputSystem;

public class UIInputs : MonoBehaviour
{

    public void StartGame(InputAction.CallbackContext context)
    {
        Debug.Log("You pressed start! Good girl!");
    }
}

#

is my code not right

#

?

glass yacht
#

What's appearing in the functions list?

hazy jetty
#

No Function

#

Mono Script

glass yacht
#

Then you should have continued down my website

hazy jetty
#

hmm

glass yacht
deft burrow
#

so i want to get the factor value here

hazy jetty
#

well that did something

#

but when i press Start nothing happens

#

What would cause that part?

#

ill watch this video:

#

later, sleep well

frigid ridge
hazy jetty
#

all good now 😄

trim shadow
#

How can i make the mouse delta from the new input system deterministic i tried multiplying by delta time on update but it doest work it is sometimes slow and sometimes fast, same if i dont multiply by delta time

ocean jacinth
#

Got a question I am finding it very difficult to get an answer to. I know I could just use the default gamepad for my new input system bindings but if I'm planning on making this cross platform, I should use specific button mappings... so my issue is the nintendo switch. The input system has to option for pro controller mapping but will that mapping also work for joycons?

vital prawn
#

anyone else experience lag time during play mode startup before the input system accepts input? I see it consistently, about 1-5 seconds

delicate burrow
#

Editor? Might just be the editor compile time

vital prawn
#

yeah, i can't recall if i also see it in builds. but i was not experiencing it when i was using the old input module

delicate burrow
#

oh then dont know. by editor compilation lag it would have been same for both.

brazen crater
#

not sure what channel to put this in, so Ill put it here. I want to turn up my Camera's far clipping plane to be able to see a larger area of my map, but when I rotate my camera using a script while the clipping plane is set to a higher number, it becomes laggy (it skips a few pixels when turning every second or so)