#🖱️┃input-system

1 messages · Page 54 of 1

crimson frost
#

@austere grotto Outputted twice, but with the same number

#

I placed it in Awake

austere grotto
#

Awake shouldn't run twice 🤔

crimson frost
#

Oh wow, it is twice on the same object, but since there's a bunch of other components in between, I didn't spot them together

#

Mystery solved 😄

subtle igloo
#

hey guys, could someone help me out, this should be easy but its somehow elluding me, I updated my script to make the movement relative to the camera, and it works great, but the portion that alligns the character to the groundnormal no longer works. I bet a million people have done this before, it probably obvious, what am I doing wrong? oh and also, target rotation and cameraY only rotate on the y axis, I tried making the normal move the x and z axis but this never worked

winged patio
#

I am making a fps game in unity using a rigidbody for my movements. I have also added a freelook cam for my game, but the movement isnt realative to the angle of the camera. Is there any thing that can help me? I used a tutorial by Plai but this never worked out for me.

sudden lagoon
#

@winged patio For camera i would suggest you use CinemaMachine. It haaave a lot of stuffs.

#

it have free look mode, follow target and etc.

#

To make movement related to camera you need to pass camera rotation to your movement script and add it there.

#

most likely you want to pass only y rotation

winged patio
#

ohk

winged patio
#

wait it still doesnt work :((

feral latch
#

Hey!
I would like to add a NumKeys for the new input system but using only one map. How can I do this?

feral latch
#

Someone ? 😭

winged patio
#

numberlock keys or the ones above the qwerty keys?

#

also nice

#

4:20

feral latch
#

&é"'(-è_çà = 1234567890

winged patio
#

just put Input.Getkeydown("(number or symbol that you wanna put)"){*insert code here}

feral latch
#

yes but with the new ?

winged patio
#

?

feral latch
#

new input system

winged patio
#

it should work

feral latch
#

hmm no

winged patio
#

it should ork nyways

#

can anyone help me with my camera?

#

why doesn't it stop when i move my mouse all the way down?

#

It goes upside down for some reason

feral latch
winged patio
#

no lol

#

but i used a tutorial

#

here is teh link :

feral latch
#

well how do you expect me to help you if you don't give anything

winged patio
#

ok ok ill do it

#

wait a sec im logging on to unity

#

idk if u can fix it

#

i dont understand it

#

the problem

#

i dont understand teh problem

austere grotto
#

You should clamp it between -89 and 89 or something

winged patio
#

ok

#

its xRot -= mathf.clamp(PlayerMouseInput * sensitivity) right?

#

or is it for playercam.transform.localRotation?

crimson frost
winged patio
#

im not using it

#

idk

#

but it doesn work for me

#

ok clamping isnt working for me :((

#

sorry but i have NO clue on how to clamp it

hollow tundra
#

how do i make a button pressed even after i clicked the screen
?

#

when i click a button it changes color, as soon as i click the screen it changes back. i wish for it to come to its original color AFTER i click a different button

crimson frost
tame wadi
#

please someone lmk why this aint working

austere grotto
tame wadi
#

Oh yea

#

that was just

#

me copy and pasting code

#

It is there

austere grotto
#

where

tame wadi
#

i copied and pasted my code into gdl forgot to add that bit

austere grotto
#

Why not just paste the whole script

#

hard to help without all the context

#

Also you never explained in what way it's not working

#

What are you expecting to happen, and what happens instead

tame wadi
#

I managed to fix it, its basically meant to be a button that resets the scene

austere grotto
#

Also why this whole complicated thing with Update etc

#

just load the scene in the performed callback

tame wadi
#

uh im p terrible at c# so i find this easier to understand somehow

austere grotto
#

what you are doing:

  • when button is pressed, set a bool to true.
  • every frame check if bool is true, and load the scene if it is

The simpler way:

  • when button is pressed, load the scene
tame wadi
#

I cant find a tutorial that explains it like that lmao, this is the only way i have managed to get it to work, ill try and find a more efficient way of doing it tho if thats how its working atm

austere grotto
#

Try experimenting outside of exactly what tutorials say sometimes

#

They are only meant to be educational, not as the only way or best or correct way to do something

tame wadi
#

I have been trying haha, I spent a good few hours before just nicking this

#

i get what you mean tho

west oracle
winged patio
#

hey thanks :))

normal cliff
#

So, I did some reading, and it seems that the new input system is pretty useless for handling mouse clicks in the game world if there is any clickable overlay UI - because it will still trigger the input system click callback even if I clicked on a UI button or any element that blocks raycasts.

It seems that the workaround is to use an invisible full-screen UI button, and when that is clicked, treat that as a click in the world, bypassing the input system.

Is this right, or am I missing something?

austere grotto
#

As long as you're actually using the event system

#

If you're using a manual Raycast or OnMouseDown it won't work properly

kindred sparrow
#

how does the "Send Messages" work?

I have a button action for jumping but if I define a OnJump() in the MonoBehaviour attached to the same GameObject as the PlayerInputcomponent, it doesn't get called

#

already tried to make it public void OnJump() or public void OnJump(InputValue value), both dont work

normal cliff
#

@austere grotto All I can say is that it doesn't work that way for me. UI works just fine but if I click on a Button it'll fire off an event via the input system too.

real bone
#

I just thought of something while playing another game that does not allow the user to bind actions to button combos or hold/toggle.
Is that going to be a possibility for me to implement in my own game using the Input System?

#

For instance, in the game I am playing:
I want to bind "Open Inventory" to holding Y while "Perform Takedown" is pressing Y.
And I'd like to bind "Zoom In" to RS-Click + D-pad Up, and "Zoom Out" to RS-Click + D-pad Down, while pressing RS-Click by itself is bound to melee attack.

real bone
#

I applaud whoever designed and implemented that.

spark pumice
#

I haven't tried implementing rebinding and the combinations of keys that you're asking about may be somewhat more complicated than a simple redirect to a new key binding

#

but its definitely implemented with rebinding in mind

real bone
#

Yeah. I knew that much. I'm just really curious about combos and holding.

#

There are "modifiers"... I wonder if they do what I want...

spark pumice
#

I'm fairly certain you can construct whole InputActions at runtime, so as long as you can make your binding with the InputAction GUI you should be able to do it via code. It may just be very complicated.

real bone
#

Yeah.

spark pumice
#

processors and interactions do the kinds of hold things you're asking about

#

I don't think you can do key combinations built in, so you would probably need to implement your own layer to handle that (or a custom interaction, I guess)

real bone
#

If someone has a config menu that uses these in their project, I'd love to see it!

spark pumice
#

I don't recall seeing very many games that allow users to rebind controls to combinations or use hold/etc in the rebindings. I think it is probably just more dev-time than it is worth for most games.

austere grotto
austere grotto
#

Because just detecting a click in general as in listening for an input action bound to the mouse, then yeah, that part is completely unrelated to the UI event system

#

Because that's what that forum post is about

#

The input system is unrelated to the event system. The only thing that ties them together is the UI Input Module

tame oracle
#

Does anyone know if there is a way to trigger a button's Click event on an input action? For example, press A on a gamepad and have the button appear to have been pressed. I can invoke the OnClick event easy enough, but the button art doesn't respond as normal.

austere grotto
tame oracle
#

thanks for the heads up!

dapper furnace
#

Hi Everyone, I'm struggling with the OnGUI event vs. the input system. What I mainly want to do is to detect hold/press action and get mouse/touch position.

I've researched several tutorials and documentation, and it seems like they both work for my case?Any suggestions on which one to use?

austere grotto
#

It's an archaic way of dealing with input

dapper furnace
ruby pollen
#

hello, i have an problem in movement character that use new input system. the character cant be stand as I want when I press joystick for controller. I'm new in new input system unity, i confused where's the source of that problem. The movement when I press joystick be like this

#

I want the character stay stand when I do movement

#

My input actions like this

#

any idea? please help

normal cliff
# austere grotto The input system is unrelated to the event system. The only thing that ties them...

Thanks for the response, but let me take a step back and try to explain from a more general position:
Usually, an application or game engine would detect a click in exactly one place and then forward it to systems in turn until it gets handled, at which point it normally stops.
I want Unity to do this, in that I want clicks on a UGUI button to not also generate an unrelated event via the input system.

timber robin
vapid yarrow
sleek pasture
#

How can I check a Vector2 arrows simulteanous key press (Left and Right)? It returns the first value (key) pressed. If I press the other, it doesn't change.

austere grotto
# normal cliff Thanks for the response, but let me take a step back and try to explain from a m...

I understand what you want. I don't know how other game engines handle it but in unity the UI event system (the thing that handles detecting clicks on UI elements etc) is downstream from the input system. The "click" is first handled in the input system and gets turned into a UI event by the UI Input Module. But this doesn't "consume" the mouse click from the input system.

This is apparently on their radar though https://forum.unity.com/threads/have-ui-consume-mouse-click.840013/#post-5552542

If you want this behavior you'll need to use a workaround like the "invisible button" thing or the "is mouse over GameObject" thing, or something else.

Event system documentation is here https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/EventSystem.html

thorny osprey
#

Can anyone guide me in how to have a cursor with a controller? I dont want to use the system cursor since im using splitscreen

thorny osprey
#

@austere grotto Yeah! I need that multiplayer event system, now im trying to learn how the virtual mouse input class works. Thx ❤️

sleek pasture
#

Input.GetAxis("Horizontal") equivalent in Input System? I googled but it seems whatever I do it's the same thing (-1, 0, 1)

sleek pasture
sleek pasture
#

How do I prevent the keyboard+mouse and xbox controller from interfering with each other? If my controller is off it's ok, but when its on keyboard movement is altered.

spark pumice
#

sorry, action map is not what I meant

#

control scheme

sleek pasture
#

you mean default scheme?

spark pumice
#

upper left corner

#

All Control Scemes

#

You want to make a keyboard control scheme and a gamepad control scheme

sleek pasture
#

Yeah I have both

spark pumice
#

and specify which bindings belong to which scheme

sleek pasture
#

I have a weird behaviour. I have a Better Jump script (really known video out there). And when I long press when Xbox Controller is as default scheme, sometimes it jumps higher, sometimes it doesn't

#

I actually spam "long press" and jumps the lowest jump. Then it somehow decides to do several high jumps for each long press

#

Ok nvm, I feel stupid. It was registering also the down stick movement, making it jump less. 🤦‍♂️

sweet roost
#

Hi, under windows gamecontroller configuration i got a controller with a slider that works there, but the output isn't recognized in the input debugger of unity. Any idea how to add this slider?

#

I know that this specific controller and slider works in unity, as other games support it, but those used rewired which uses the old Input

halcyon lynx
#

hi, for some reason, even though i have set up my jump to be on my dualshock's x button and my look to be on the right joystick, the look is done on the left joystick and the jump is set on the right joystick, even though my actions maps are explicitly set to the right joystick and the x button. how can i fix this?

sage ice
#

hi, I'm completely new to unity and in the process of learning, and I heard it's best to keep anything input-related in its own class. How exactly does this work- how would I make certain inputs invoke certain methods, and is there any example code I could look at?

spark pumice
halcyon lynx
#

I should also point out that I am using DS4Windows, if that makes any sort of difference.

rose hearth
#

Ive been reading the Documentation and i just dont get it, can someone explain to me how i can increase the accuracy of GetAxis("Mouse X") to more than 0.05 steps ?

#

why did they even change it, didnt it use to be how many PIXELS the mouse has moved ?

rose hearth
#

I guess what im asking is what is the preferred way to do a camera look script in Unity 2020.3 ? Cause it feels like theyre trying to make it as complicated as possible

minor solstice
#

Hello, I've been using the new input system and I'm having a remarkably specific problem. Basically I'm doing this:

return action.GetBindingDisplayString(bindingIndex);

In a function to get a suitable binding name to display in the UI. Perfect. Only problem is, for some reason it returns the name in Italian. I'm Italian, but I think I have Unity set up in English, so...
For most keys, this isn't a problem, but for example with the "Spacebar", instead of "Spacebar", that line returns "Barra spaziatrice", which is "Spacebar" in Italian. Is there any way I can change this language setting thing?

minor solstice
#

oof so apparently

#

it uses the OS lang

#

kinda sucks tbh

tired mural
#

So i recently changed the input system to the new one and turns out i have no idea how to work with it yet and i just want to make a basic movement so how do I revert back to the old input system?

#

unless someone has a good tutorial about the new one

timber robin
#

You can change which version you're using in Player Settings.

tired mural
#

alr thanks

shadow raptor
#

how can i make a input cancel right after occurring , i am trying to make a dash but i cant make it work (2D). My problem is if u keep holding down the dash button u would keep dashing forever and the dash cooldown would only start when you let go of the dash

timber robin
#

Use a Boolean value which toggles true and false based on the dash. Don't allow anymore dashing while isDashing = true.

shadow raptor
#

the thing is the way my player moves is
hMove = context.ReadValue<Vector2>().x;
and the way I do my dash is setting hmove to a value

#

so do i have to change that

#

hmove is a float

timber robin
#

No, you have to add a bool to your whole movement logic. Before you change the value of hmove, check if you're dashing.

#

Then set it to false when it's not. When you press the dash button, don't set it to true if, say, the timer that handles the length of the dash is still ticking.

shadow raptor
#

my Dash is a whole other action so when I am done dashing I cant set the context back to readvalue , I am having trouble putting them under one action

#

my dash keeps going unless i let go of it how can i make it so it stop after a certain time or after a certain amount of movement

sleek pasture
#

whenever I try to add a binding to the Logitech Attack 3, it switches control scheme to all devices. I try to make Input System Listen to a button and doesn't recognize it

#

no events

tropic sage
#

I've been trying to get the mouse position with delta and it never registers when i move my cursor, does anyone else have this problem?

tropic sage
austere grotto
#

Why do you have Delta piinter and delta mouse

#

those are redundant

#

same with right stick/right stick gamepad

#

Input System can get kinda buggy when you have a lot of different bindings on a single action

tropic sage
#

aight i got rid of the redundancies

austere grotto
#

Anyway how are you trying to read/listen for this action in your code?

tropic sage
#

sure, let me post a screenie

austere grotto
# tropic sage
  1. Did you enable your playerControls object?
  2. Did you try Value instead of Pass Through?
tropic sage
#

yes and yes

#

still not working :u

austere grotto
#

And what is playerController? Seems unrelated

tropic sage
#

So I have two classes, one I attached to the camera that manages tilting and following the player

#

and I pass the playercontroller into the camera to get where to follow

#

i enable the playerController object at the top

austere grotto
#

Can you show the line of code where you enable playerControls?

#

not PlayerController

tropic sage
#

it enables in playerController

austere grotto
#

That's not enabling it

#

playerControls.Enable(); would enable it

tropic sage
austere grotto
#

ok thank you

austere grotto
# tropic sage

So if you put a Debug.Log in this OnLook method what happens

#

it never runs?

tropic sage
#

nope, never

tropic sage
#

if anyone has any advice, id really appreciate it since i can't move the camera otherwise

spark sage
#

I want to an instance of an input system generated class to only record and report input happening when it happens on an specific control scheme. How can I achieve this?

#

Currently it raises events and .ReadValue<>() gives a value for every input scheme, doesn't matter if its keyboard and mouse or controller.

#

I want an instance of the generated class that only raises events when I use the keyboard, for example.

#

I'm not using the PlayerInput component and hope I don't have to use it later either.

shadow raptor
#

if someone has the freetime to review my player movement code and help me figure out why my dash is sometimes short and sometimes longer in distance that would be great, been trying to fix it for the past 2 days I need a different set of eyes to maybe spot a mistake.

#

cant find any tutorials that do it with the new input system

#

just tell me and I will send u the code

gleaming nest
shadow raptor
#

should i DM it to u ?

gleaming nest
#

sure

versed egret
#

I installed the input system package, but my input settings are looking so:

austere grotto
#

You can ignore that section.

austere grotto
#

NOT project folder oops lol 😅

#

Also looks like your project folder is inside OneDrive?

#

That's probably not a good idea

#

It will probably cause issues

versed egret
austere grotto
#

Delete your library folder and restart Unity

versed egret
austere grotto
versed egret
#

I found my issue thanks for the help

glass atlas
#

Does anyone know why in 2021.2 I am not allowed anymore to use 2D axis?

#

Or is that called 2D vector now?

tropic sage
#

Yup, 2d vector

#

X and Y of the 2d vector are your horizontal and vertical

buoyant peak
#

the new input system isn't working for me, this is my code (some irrelevant parts removed, its a simple script that moves the camera):

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraScript : MonoBehaviour
{
    public Controls controls;
    private void Awake()
    {
        controls = new Controls();
    }
    private void Update()
    {
        Vector3 pos = transform.position;
        if (controls.Game.Up.triggered) pos.z += 15 * (float)Math.Sqrt(pos.y) * Time.deltaTime;
        if (controls.Game.Left.triggered) pos.x -= 15 * (float)Math.Sqrt(pos.y) * Time.deltaTime;
        if (controls.Game.Right.triggered) pos.x += 15 * (float)Math.Sqrt(pos.y) * Time.deltaTime;
        if (controls.Game.Down.triggered) pos.z -= 15 * (float)Math.Sqrt(pos.y) * Time.deltaTime;
        transform.position = pos;
    }
}
#

the .triggered doesnt seem to work, it always returns false

#

no errors, it just doesnt do anything, the script worked fine before i switched over

misty locust
# buoyant peak the new input system isn't working for me, this is my code (some irrelevant part...

You have to enable your map or all action maps. Something like this:
controls.Game.Enable() for enabling Game action map or controls.Enable() for all the action maps. Do it in Awake() or Start after creating new Controls() instance.

Also if you have Input System 1.1 or above you have similar api to old input system — controls.Game.Down.isPressed for GetKey, controls.Game.Down.wasPressedThisFrame for GetKeyDown and controls.Game.Down.wasReleasedThisFrame for GetKeyUp.

buoyant peak
#

ill try that

#

it works but triggered only checks when its starting to be pressed, and it does not recognize isPressed/wasPressedThisFrame/wasReleasedThisFrame

misty locust
buoyant peak
#

1.0.2

misty locust
#

Those 3 checks are only for 1.1 and above.

misty locust
buoyant peak
#

i dont see the button to update it

misty locust
#

Unity version?

buoyant peak
#

2020.3.22f1

misty locust
#

It should be there to update it. Can I see screenshot of your package manager?

buoyant peak
#

and i updated some packages earlier today

misty locust
#

Click See Other Versions under it, just for checking.

buoyant peak
#

it gives the option to update it

#

so ill do that

misty locust
#

Alright

buoyant peak
#

i guess its because the 'verified' version is 1.0.2 even though the latest version is 1.2.0

misty locust
#

Oh yes, I forgot about that. You can upgrade to 1.2.0.

misty locust
#

Anytime 🙂

hallow flicker
#

I'm having trouble with an event.

When the scroll actions are performed below, selectUpDownLoad isn't called. No error or anything.

Can you see anything broken in my setup?


playerControls = new PlayerControls;

void Awake()
    {
        playerControls = new PlayerControls();
    }
void OnEnable()
    {
    playerControls.UICustom.ScrollUp.performed += selectUpDownLoad;
    playerControls.UICustom.ScrollDown.performed += selectUpDownLoad;
    }

void OnDisable()
    {
    playerControls.UICustom.ScrollUp.performed -= selectUpDownLoad;
    playerControls.UICustom.ScrollDown.performed -= selectUpDownLoad;
    }

void selectUpDownLoad(InputAction.CallbackContext context)
    {
        print("event happened");
        uiAudioManager.UIAudioSource.PlayOneShot(uiAudioManager.navigation,0.7f);
        print("should have played audio");
    }
shrewd vapor
#

I'm stuck at this issue for a while so asking here. For my XR controller, if I set the control type to value, I get a loop of started, performed, cancelled repeatedly when holding the button down. I understand performed, but why is cancelled getting called in between when the button isn't released. Same behavior with thumbstick, a loop of actual input and a vector2.zero. the input debugger does not have this issue so I assume things are read from hardware correctly. Setting control type to button leads to nothing being called for release. Nothing happens even on explicitly setting interaction to release.
Everything works perfectly well for keyboard input and gamepad input though. It's just the XR controller

austere grotto
lunar drift
#

how can i change wepons when i scroll the mouse whell

spark pumice
worldly charm
#

im trying to have various gameobjects be "clickable", I tried following this tutorial https://stackoverflow.com/a/41392130/15157083 however, It doesn't print anything on mouse down
i have an event system object, the camera has the raycaster, im just not sure what im doing wrong

#

any help on this would be appreciated

spiral galleon
#

What you linked is mostly for UI

worldly charm
#

normal gameobjects, I tried following part 7 which seems to be for 2d objects

#

I may be wrong though

tired jetty
#

probably a common question here but can someone send me a full guide on how to implement mobile touch inputs to unity 2d games i wanna make my first mobile project but not sure how to implement touch inputs

jagged wyvern
tired jetty
#

which ?

jagged wyvern
#

in the package manager

tired jetty
#

whats it called

tidal sedge
tired jetty
#

1 finger Touch input

#

but i alr figured it out

#

thank you anyways :)

tidal sedge
tame oracle
#

hi.. I set up the input system and it works BUT when in the main menu it doesn't take input from my gamepad ... only the up/down/left and right ... it doesn't take select, start or one of the buttons on the right... any idea why that is?

#

i think that's related to the evnt system and the inputsystemUI Input module

#

but i dont know how to make it work

#

any help please?

#

after many tests ... none of the gamepad controls work for some reason... I dont know why or how

austere grotto
#

You have two different actions to start and stop sprinting?

#

How are they set up? What are they bound to?

#

And how are you calling ProcessMove()

#

Seems overcomplicated, you could just use one action and listen for started and cancelled

#

Can you move at all?

#

Anyway it doesn't seem like your ProcessMove code cares about the isSprinting variable at all

#

So not sure what you're expecting to happen

#

Forget all that

#

The main point here is that your movement code is ignoring the sprinting variable entirely

#

If you want it to do anything, you need to make the movement code care about when you're sprinting

#

You could just have the sprintpress and sprintrelease change the speed variable

#

Then you wouldn't have to change the movement code at all

#

So do that

#

That much is obvious ☺️

dusk portal
#

Hello I have a problem with the new input system. It works with the mouse on PC but doesn't work with touch screen on Android. Here is my config:

austere grotto
#

How are you reading the input

dusk portal
#

I have an OnPointerPress method in my player entity

austere grotto
#

And you're using the PlayerInput component in Send Messages mode?

dusk portal
#

it is called when I left click the mouse button when running on PC when not called when running on android

dusk portal
#

Behavirous "send messages"

austere grotto
#

Are you using the PlayerInput component?

dusk portal
#

yes

austere grotto
#

Ok and what mode is it set to?

dusk portal
#

I just check it's a playerinput component with the behavior "Send messages"

austere grotto
#

Ok good thanks

dusk portal
#

Default scheme Any

austere grotto
dusk portal
#

yes I just want to get the "on press"

austere grotto
#

But you don't need that interaction for that

#

Read the message

#

It explains

#

Wait this again with the separate actions for press and release?

#

What kinda crazy tutorials are you guys all following today

dusk portal
#

I need to get notifications for press and notifications for release

austere grotto
#

Yeah I understand. That can be done with a single action

dusk portal
#

depending on the press and release position they are different kind of interactions

#

Oh, could you please tell me what is the correct way to do that ?

austere grotto
#

Just use one action and check in the CallbackContext whether it's started or cancelled

dusk portal
#

you mean I can get only the press action and depending on the callbackcontext I can see if this is a release ?

#

the problem is that currently on android, the pointerpress is never called at all

#

@austere grotto sorry but I probably missed something

stark notch
#

I have a question, is there a way to make a global script that works across scenes for input? so it's not bound to an object, i feel like that would be better and safer for stuff like menu's

dusk portal
austere grotto
dusk portal
lunar drift
#

i have this code
defaultInput.Weapon.ChangeGun.performed += e => CG();
that executes function 2 tieme(idk why tho)
and there is the input thing

lunar drift
#

A sec

austere grotto
#

nvm I see it

#

missed it at first

lunar drift
#

Lol

austere grotto
#

How do you know it's being called twice?

lunar drift
#

I made it type smthin in debug log

austere grotto
#

& do you have any interactions on your action?

austere grotto
lunar drift
#

No cuz im on phone rn

#

Sry

#

I will do it in moring

austere grotto
#

Can't help you much rn then. Either you've got two copies of the script in the scene, or you've got an interaction on the action that causes it to be performed twice

lunar drift
#

Lol

#

Idk

#

Bye for now

terse aurora
#

anyone know what this is / how to fix?

glass yacht
tame oracle
#

what is the suggested way in receiving the input from the new unity input system? (Send Messages/ Broadcast Messages/ Unity Events/ C# events)

jagged wyvern
#

send messages if you want simplicity

tame oracle
#

hmm i heard it's better to use UnityEvents or the c# events any reason for that?

jagged wyvern
#

they provide callback context so you can get more accurate data about the buttons

#

takes a bit more to set up tho

tame oracle
#

hmm thats fine with me

#

im making a game where you mostly just drag and drop. (eg placing units and removing units)

#

and im using the new input system cause it's easy for changing platforms

lunar drift
lunar drift
#

didnt expact anything else

lunar drift
#

@austere grotto

misty locust
lunar drift
#

oh thx

#

btw what does it do ?

lunar drift
#

@austere grotto u here?

timber anchor
#

can someone tell me where I can find the basics for the new input system?

spark pumice
timber anchor
lunar drift
#

@austere grotto it say -1382 on both

lunar drift
#

so what shall i do

#

chceck if it dont have an interaction

#

btw the gameobject is child of prefab cant that be why?

lunar drift
#

so what shall i do

fleet pasture
#

I'm trying to add d-pad support to my game. Right now for movement I'm using Input.GetAxisRaw("Horizontal") is there a way to add d-pad as an alternative to the joystick?

#

I'm using the old input system btw because that's what I'm used to.

olive loom
#

Hey, i got a fire perform and canceled callbacks but sometimes (seemingly randomly) after just tap-firing, the firing bool is set to true even though doing debug logs shows it being canceled after a fire

private void Fire_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        if (fireDelay == 0)
            firing = true;
        else
            StartCoroutine(nameof(ChargedFire));
    }

    private void Fire_canceled(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        StopFiring();
    }```
#

and it being true basically fires as if the key is held

dreamy umbra
#

There is not enough code there for me to determine the problem, I would assume somewhere in the coroutine you are setting fireDelay within an if statement that relies on the button being pressed or something similar.

olive loom
#

debugging both methods show that they are being called in the right order always; even when the issue happens

dreamy umbra
#

hmm

#

Maybe run debug.log with different messages any place you modify the firing bool, making sure to mention what modification is being made.

olive loom
dreamy umbra
#

the do the same with fireDelay

olive loom
#

and StopFiring has it false at the end

#

why?

#

ignore the if check, its always gonna call firing = true; on that weapon i tested the bug on

olive loom
#
private void Fire_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        firing = true;
    }

    private void Fire_canceled(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        if (gatling.gatlingStarted && gatling.isGatling && gatling.gatlingDischarge)
        {
            if (weaponAudioSource.isPlaying && gatling.forceEndSound)
            {
                weaponAudioSource.Stop();
            }
            weaponAudioSource.loop = false;
            weaponAudioSource.PlayOneShot(gatling.gatlingDischarge);
        }

        StopCoroutine(nameof(ChargedFire));

        gatling.gatlingStarted = false;
        firing = false;
    }```
here, made it better
dreamy umbra
#

are any errors being thrown in that script that would stop it running to completion?

olive loom
#

no.

#

as i said, the bloody thing works just fine

#

but if i tap-fire rapidly the firing gets stuck to true

#

but not always

#

¯_(ツ)_/¯

dreamy umbra
#

:P where and under what circumstances is the Fire_cancled method being called

olive loom
#

mouse up.

#

when the button is un-pressed

dreamy umbra
#

try this:

    private void Fire_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        firing = true;
        Debug.Log("firing set to true");
    }

    private void Fire_canceled(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        if (gatling.gatlingStarted && gatling.isGatling && gatling.gatlingDischarge)
        {
            if (weaponAudioSource.isPlaying && gatling.forceEndSound)
            {
                weaponAudioSource.Stop();
            }
            weaponAudioSource.loop = false;
            weaponAudioSource.PlayOneShot(gatling.gatlingDischarge);
        }

        StopCoroutine(nameof(ChargedFire));

        gatling.gatlingStarted = false;
        firing = false;
        Debug.Log("firing set to false");
    }

make sure Collapse is toggled off on the console and see if the order of the logs matches the occurrence of the bug

olive loom
#

my dude i told u 😄

dreamy umbra
#

ok

olive loom
#

i did the same debug

#

the order was fine

#

fire first, false second; always

dreamy umbra
#

sorry, my brain says that is the likely culprit :P
I'll think of other possibilities ig

olive loom
#

i have no bloody clue why its doing it other than maybe the input system being bugged

hidden laurel
olive loom
#

actually let me debug my actual firing method calls

dreamy umbra
#

wait, what is indicating to you that you are still firing

#

is it an animation?

olive loom
#

firing = true

#

ive set it so if thats true it will fire

#
    {
        if (firing)
        {
            RemoteFire();//here is where we actually fire

            if (!automatic)
                StopFiring();
        }```
#

OnUpdate just Update using a delegate instead of having multiple Update methods- supposedly for speed

dreamy umbra
#

so the logs are saying the firing bool is off, when it isn't?

olive loom
#

no log said it called the StopFiring method

#

let me see if its still true if it gets stuck

#

yup, its true

dreamy umbra
#

so the logs are correctly determining when the bool is true when it shouldn't be?
or are you looking in the inspector?

olive loom
#

AHHA!

#

hold up im onto something

#

i fired 3 shots that were fine, and then the next one got stuck

#

it seems it doesnt reach the end of the StopFiring()

#

could it be me spamming the StopCoroutine(nameof(ChargedFire)); even though im not using it?

dreamy umbra
#

if its a possibility, and checking is attainable, check it

#

I'd also recommend adding more debug statements within that method to determine exactly where it stops.

olive loom
#

nope, i disabled the gatling-related code and just left the firing = false;

#

same issue

#

this is dumb....

dreamy umbra
#

so its probably an issue with where Fire_canceled is being called

olive loom
#

or where its not being called 🤔

dreamy umbra
#

exactally

#

so where/when is is supposed to be called

olive loom
#

as i said and say it again; mouse up

#

perhaps if i use started instead of performed for my mouse down?

dreamy umbra
#

try it

#

looks promising

olive loom
#

my only guess is the performed doesnt get called at the same order all the time

dreamy umbra
#

maybe it takes longer to perform for some reason

olive loom
#

same issue

dreamy umbra
#

unfortunate

olive loom
#

i think i know whats going on....

#

never mind, false

#

i thought it got stuck on firing only when i used my keyboard WASD to move

#

it wasnt that

dreamy umbra
#

Its probably either the mouse up is not being received properly or something is impeding the script that starts the Fire_canceled method? (edit: not the actual method the bit that calls it)

#

can I see that bit of script?

olive loom
#

if this doesnt work then something prevents from the actual callback from being called

#

yup, it sometimes doesnt get called

#

hell...

dreamy umbra
olive loom
#

wut

#

its an input system thing...

dreamy umbra
#

ah

#

well there you go

#

ill look into that then

olive loom
#

???

#

i dont....what?

dreamy umbra
#

I didn't know that method was called by the input system, never used it.

olive loom
#

my dude, we are in the input system xD

spark pumice
olive loom
#

they are actually TELLING you to use these event callbacks

#

in their docs

olive loom
#

GameManager.Instance.Inputs.Player.Fire.canceled += Fire_canceled;

#
    {
        get
        {
            if (_inputs == null)
            {
                _inputs = new PlayerControls();
            }```
#

@spark pumice no clue why it sometimes doesnt do the canceled callback

spark pumice
olive loom
spark pumice
olive loom
#

i mean...yeah?

spark pumice
#

just checking

#

looking for weirdnesses

olive loom
#

even the delegate ones i did

spark pumice
olive loom
#

it is

heavy aurora
#

is there any way to make the key a public variable?

olive loom
#

@spark pumice idk what could be wrong with the callback other than it being an actual system bug 🤔

#

if i create a settings asset; i assume the default settings are how it is without the custom asset?

spark pumice
spark pumice
olive loom
#

im gonna have to sleep now since its 4 in the morning; ping me if u find something

spark pumice
olive loom
spark pumice
#

😕

#

well, the next thing I'd look at is that coroutine, but you should sleep

olive loom
#

idk unless someone more experienced in this shit pops in; might need to file it as a bug

olive loom
#
private void Fire_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
            firing = true;
    }

    private void Fire_canceled(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        firing = false;
    }```
#

same issue

#

anyway bye for now

heavy aurora
austere grotto
half prairie
#

Hello guys how are you doing, I hope you are doing well. So I want to ask about something. I have used the new input system with cinemachine and I have made the joystick of the movement. But for rotating the camera I used an image and On-Screen Stick and set the control path to Right stick and the cinemachine Input provider with the input action with action type to value, control type to Vector 2 and blinding path with Right stick. But the problem that when I test it with my phone, the right joy stick acts like a right joy stick so If I pressed and hold the camera will be spinning for ever until I release it and the camera movement isn't accurate. So do you guys have any ideas on how to solve this problem?

dreamy umbra
#

you could set the joystick to reset itself back to 0,0 when inactive

half prairie
# dreamy umbra you could set the joystick to reset itself back to 0,0 when inactive

it isn't about the joystick. the movement with the joystick is working without problems but the right joystick is already programmed to be as a real right joystick of a controller so when you move the joystick to the right and keep holding it will keep moving the camera or spinning. that's why I want to remove the right joystick option but I tried to replace it with everything like touch, mouse but still not accurate and got problems too

#

I could use normal camera with script but I need cinemachine because it has great features which I really need

olive loom
#

@spark pumice well i think its a unity editor bug , this callback thing- i made a standalone build and im not getting it 🤔

ancient dagger
#

How can I save the place where the touch was, which I asked for with Input.Gettouch?

ancient dagger
narrow prairie
#

hey all, trying to setup an input-action that allows me to grab objects using the XR interaction toolkit, and am not exactly sure how to setup the bindings on the controllers --> can anyone point me in the right direction?

lunar drift
#

is it posible to detect if i scroll up or down on scroll wheel?

lunar drift
#

thx

lunar drift
#

how can i recreate this with the new input sytem : Input.GetAxis("Mouse ScrollWheel") > 0f

jagged wyvern
#
var mouse= mouse.current;
        if (mouse== null)
            return;

        if (mouse.scroll.x  > 0)
        {
            // 'Use' code here
        }
stark notch
#

Hello, i am having a few errors but can't seem to figure out why exactly

stark notch
#

It's always a MissingMethodException saying it can't find the method like OnDash but it is in my script so idk why this is happening.
it also shows some System libraries, here is a full error

#
MissingMethodException: Method 'InputReader.OnDash' not found.
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <00c558282d074245ab3496e2d108079b>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <e7c72e4b0bcb4085b636d7e8921f7453>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
#

The error isn't really useful, i can't make up from this what is wrong

tame oracle
#

hey uhh im trying to learn the new unity input system and i was struggeling with the unity events. How do i read input when using the unity events? Like i wanna get the callback but when i add the callback in the parameters i can find it on playerinput discovery

austere grotto
stark notch
austere grotto
stark notch
#

This is a very basic script i just made trying to get the callbackcontext working

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

[RequireComponent(typeof(CharacterController))]
public class Protagonist : MonoBehaviour
{
    private CharacterController m_CharacterController;

    private Vector2 m_MoveInput;

    private void Awake()
    {
        m_CharacterController = GetComponent<CharacterController>();
    }

    private void FixedUpdate()
    {
        m_CharacterController.Move(new Vector3(m_MoveInput.x, 0, m_MoveInput.y).normalized * Time.fixedDeltaTime);
    }

    public void OnMove(InputAction.CallbackContext context)
    {
        m_MoveInput = context.ReadValue<Vector2>();
    }
}
#

this is the setup

#

i am trying other settings for the messages too like c# events but none do the trick

#

and these are my inputs not much

#

I previously in did it using the InputValue but now want to try and use it with the callbackcontext

austere grotto
#

that's what it's complaining about

austere grotto
#

It's a totally different approach

#

and if you use UnityEvents you're supposed to assign the callbacks in the inspector.

stark notch
#

yeah, but that's what confuses me, not sure what i properly need to put in the code to make it work

austere grotto
#

Well if you stick with Broadcast Messages, you need to make an OnDash method

#

similar to your existing OnMove method

#

And an OnAttack

stark notch
#

that can change actually

#

i just want to get the callback context in my code to work

austere grotto
#

What's not working about it

stark notch
#
public void OnMove(InputAction.CallbackContext context)
    {
        m_MoveInput = context.ReadValue<Vector2>();
    }

    public void OnDash(InputAction.CallbackContext context)
    {
        return;
    }

    public void OnAttack(InputAction.CallbackContext context)
    {
        return;
    }

like now i have this

#

but my charactercontroller just doesn't move

austere grotto
#

Did you put a Debug.Log in OnMove to see if it's running?

stark notch
#

i know it works when setting moveinput to a vector1

#

it doesn't run

stark notch
#

but it also complains when i put send or broadcast messages that none of the OnAttack/OnMove/OnDash are found

austere grotto
#

You're supposed to use an InputValue parameter

#

not a CallbackContext

#

See the example in the link i sent

stark notch
#

but i saw some projects using callbackcontext and would like to use it too since it added more checks like if an input is canceled or peformed

austere grotto
stark notch
#

I would like keep using callbackcontext, i can change the behavior of my inputmanager if needed, i just would like to use the functionality of the callbackcontext

austere grotto
#

it's for different approaches

stark notch
#

I know, i can change that

austere grotto
#

You need to change your PlayerInput to use UnityEvents

#

and then assign your functions in the inspector

#

Or skip using PlayerInput altogether and then there's a whole world of ways to do things without it.

stark notch
#

How would you utilise the inputsystem without the playerinput component? would you generate the script from the inputsystem?

austere grotto
#

Another option is to use InputActionReference, or a direct reference to an InputActionsAsset

stark notch
#

if i used the generated input script how would i utilise the callback context from there

#

do i just implement the interface and it should work?

austere grotto
#

I believe you can implement the interface and then you need to instantiate your generated input class and register your object as a listener for it

stark notch
#

I have done this right now, but it's not yet working any idea why?

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

[RequireComponent(typeof(CharacterController))]
public class Protagonist : MonoBehaviour, GameInput.IGameplayActions
{
    private CharacterController m_CharacterController;
    private GameInput m_GameInput;

    private Vector2 m_MoveInput;

    private void Awake()
    {
        m_CharacterController = GetComponent<CharacterController>();
        m_GameInput = new GameInput();

        m_GameInput.Gameplay.SetCallbacks(this);
    }

    private void FixedUpdate()
    {
        m_CharacterController.Move(new Vector3(m_MoveInput.x, 0, m_MoveInput.y).normalized * Time.fixedDeltaTime);
    }

    public void OnMove(InputAction.CallbackContext context)
    {
        Debug.Log("move");
        m_MoveInput = context.ReadValue<Vector2>();
    }

    public void OnDash(InputAction.CallbackContext context)
    {
        return;
    }

    public void OnAttack(InputAction.CallbackContext context)
    {
        return;
    }
}
austere grotto
stark notch
#

oh

#

oh cool it works now thanks

#

now i can make a proper input script i hope

tranquil quartz
#

How is the input system meant to work in a networked multiplayer context? Tried searching stuff online but I can only find local multiplayer. Currently I'm having issues where the host of my multiplayer instance can look around no problem but any new clients cant. The player prefab has a player input and there is an event hooked up to my look function, it just never gets called on any client that isn't hosting the server as well.

#

I've disabled all other player inputs except for the local player, so I'm not sure whats up. I also checked that the reference to Player is correct for each client

#
public void OnLook(InputAction.CallbackContext context) {
        Debug.Log("hi2");
        if (!isLocalPlayer) return;

        Vector2 lookValue = context.ReadValue<Vector2>() * Time.deltaTime;
        if (looking)
        {
            float newRotationX = transform.localEulerAngles.y + lookValue.x * freeLookSensitivity;
            float newRotationY = transform.localEulerAngles.x - lookValue.y * freeLookSensitivity;
            transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);
        }
    }

The "hi2" message only ever appears for the host, other clients never have this outputted to console

#

My initial guess is it has to do with the fact that the host has the first instance of it, and there is something going wrong with there being multiple inputs

austere grotto
#

See if everything looks ok and all the components are enabled etc

valid geode
#

Does anyone know why the xbox controller or mouse/keyboard doesn't work on xbox series x/s in dev mode? (On windows 10 the xbox controller works perfect)
I can't find any useful information about controller input on xbox. Please help

frigid ridge
#

No idea, but would guess that maybe some SDK is required to extend support?

valid geode
#

Thank can you tell me where to find more documentation etc?

frigid ridge
#

No, just guessing. I would also try to check if there is any event activity happening in the input system

#

No idea how to access the lower levels of the input system either, but I assume there is a way at runtime to do something similar to what the input debugger does

valid geode
#

Okay thanks. Someone also said I should use an sdk for ID@XBOX but I can't find any information anywhere

dusk portal
#

Hello, when I use the new input system I have a problem. private void OnPointerPress() is correctly called when the user press the mouse button but if I use "private void OnPointerPress(CallbackContext context)" I get an MissingMethodException error. Why I can't have a CallbackContext and how to get one ?

austere grotto
dusk portal
#

ok thanks.

#

I have another question. Is there a way to get the "position" on a press event ?

austere grotto
#

and you just read from there

dusk portal
#

ok but when I "press" I need to know if this input is in the correct zone or not

austere grotto
#

yes... and?

#

You can also use the event system for this. Make a UI or game world object with IPointerClickHandler in the correct "zone"

dusk portal
#

The "onMove" (to get the position) callback is called before the onclick ?

austere grotto
#
myPointerPositionAction.ReadValue<Vector2>()```
dusk portal
#

Ok so to be able to read a vector2 I have a to set actiontype: value and controle type: vector2. Right ?

#

InvalidOperationException: Cannot read value of type 'Vector2' from control '/Mouse/leftButton' bound to action 'Player/PointerPress[/Mouse/leftButton]' (control is a 'ButtonControl' with value type 'float')

#

I get this error in the "on click"

#

void OnPointerPress(InputValue value) {
Debug.Log("TEST: " + value.Get<Vector2>());
}

#

(i'm using SendMessages)

#

Something missing ? Do I need another binding for this action ? a "mouse move" binding ?

#

@austere grotto could you please tell me how to get a position from an on click action ?

dusk portal
austere grotto
#

You can't get position from the click

dusk portal
#

Anyway I still have a problem. The OnMove is called AFTER the OnPress so I don't have a position value available for the first OnPress

tranquil quartz
austere grotto
vocal mesa
#

I'm having a few issues with Input System Manager. I followed the Roll-A-Ball tutorial, which used the movement section, and it worked perfectly. But, I've tried to modify it for moving the camera using Look, but nothing happens.

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

public class CameraRotate : MonoBehaviour
{
    private Vector2 lookVector;

    void OnLook (InputValue lookValue)
    {
        Vector2 lookVector = lookValue.Get<Vector2>();

    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(0, lookVector.y, 0);
        Debug.Log(lookVector);
    }
}

I should be getting back a vector of my mouse/right stick movement, or for the camera to rotate, but nothing happens. I've followed the same structure as my movement script, which works.

#

Here is the movement code, which works:

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

public class PlayerController : MonoBehaviour
{

    public float speed = 0;

    private Rigidbody rb;
    private float movementX;
    private float movementY;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void OnMove(InputValue movementValue)
    {
        // Function Body
        Vector2 movementVector = movementValue.Get<Vector2>();

        movementX = movementVector.x;
        movementY = movementVector.y;
    }

    void FixedUpdate()
    {
        Vector3 movement = new Vector3(movementX, 0.0f, movementY);
        rb.AddForce(movement * speed);
    }
}
lunar drift
#

Btw is it detectin scroll wheel?

bronze ridge
#

do you always have to declare a new Input Asset Pack when you use it in a script?

Like for my PlayerMovement I have to do playerActions = new PlayerActions(); and the OnEnable and OnDisable methods.
Do I also have to do the same thing for the CameraMovement script for example? Or am I just missing something really obvious?

austere grotto
#

You should instead write to the existing lookVector member variable

#

Notice your OnMove is writing to the member variables movementX/Y

#

From a code perspective this means simply deleting the word 'Vector2' from the first line of code inside your OnMove method

vocal mesa
#

Log still says 0.00, 0.00 for every frame

#

Yet, if I swap OnLook into my movement script, that works fine.

#
public class PlayerController : MonoBehaviour
{

    public float speed = 0;

    private Rigidbody rb;
    private float movementX;
    private float movementY;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void OnLook(InputValue movementValue)
    {
        // Function Body
        Vector2 movementVector = movementValue.Get<Vector2>();

        movementX = movementVector.x;
        movementY = movementVector.y;
        Debug.Log(movementX);
    }

This code works fine, and puts the value in the log every time I move my mouse left and right.

#
public class CameraRotate : MonoBehaviour
{
    private float lookX;
    private float lookY;

    void OnLook(InputValue lookValue)
    {
        Vector2 lookVector = lookValue.Get<Vector2>();

        lookX = lookVector.x;
        lookY = lookVector.y;
        Debug.Log(lookX);

    }
```But this code doesn't do anything?
#

I FIXED IT.

#

The camera didn't have the PlayerInput component...

delicate pollen
#

I'm working with my own inputActions asset and it's associated C# script and am trying to work out how to do an Input.GetMouseButtonUp(0) action. I'm a little confused tbh, can anybody provide clues? I can register to the performed event and read a bool value off the lambda, but that doesn't really let me know when it's 'released'. Am I going to have to code this myself? No real hardship, but it seems odd this isn't handled in Input...

hidden laurel
# delicate pollen I'm working with my own inputActions asset and it's associated C# script and am ...

I'd recommend glancing over this page, as it explains some things that I think the InputSystem docs don't explain well anywhere else: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Interactions.html#default-interaction
Basically there are different events for different steps in a control's lifetime; generally to listen for button up you will want to subscribe to the canceled (sic) event, but there are some subtleties depending on how you have your interactions set up.

austere grotto
#

As well as checking for the canceled phase on the action

#

So there's at least 3 ways to do it

delicate pollen
#

Thank you, @hidden laurel and @austere grotto . I still find myself getting confused over the events, though I appreciate the page you've linked! I'm currently registering functions with these events in Awake - though they don't seem to be called in-game. Additionally, should I be deregistering in OnDestroy? Not sure if that still holds true for InputAction events... =/

#

inputActions.ActionMap.MouseButton0.performed += MBut0 => StartDrag();

austere grotto
austere grotto
delicate pollen
#

? But presumably I can deregister with,

inputActions.ActionMap.MouseButton0.performed -= MBut0 => StartDrag();
...although I can see the lambda causing problems... =/

austere grotto
#

No you can't

delicate pollen
#

Shucks.

austere grotto
#

Exactly because of your unsaved lambda

#

It's a different lambda

delicate pollen
#

Yeah, right.

#

Yep.

#

I couldn't seem to immediately register the StartDrag() function, however...

austere grotto
#

To match the event's delegate type

delicate pollen
#

Also, goddamn, I can't believe I forgot 'enable'. I will get the hang of this thing.

austere grotto
#

It just comes with experience

#

And even then you'll forget sometimes 🙂

delicate pollen
#

Oh, I know, but... rrrgh. =)

austere grotto
#

Meatbrains do be like that

delicate pollen
#

Can you give me an example of the inputaction.callbackcontext parameter?

austere grotto
delicate pollen
#

...
0_o

austere grotto
#

Ignore everything except the parameter of his function

#

That's what your function needs

delicate pollen
#

So... I need to put this inside... a function which has a callback parameter?

#

So, not registering with the event at all?

austere grotto
#

You just need to add that parameter to your Start drag method, or another method that calls start drag

#

Then you'll be able to register that method directly to the event

delicate pollen
#

OHH.

austere grotto
#

Instead of using a lambda

delicate pollen
#

OHHHHHHHH.

#

OHHHHHH.

#

Yes.

#

Yes. Scales falling from my eyes.

#

I should have read the goddamn warning messages in Intellisense, in other words.

austere grotto
#

:P

delicate pollen
#

Thank you for sticking with me in my moment of idiocy.

#

Like, I've seen all this before, but didn't connect it to this... context... =/

#

Sorry to bother you again, man, but... my function signatures now read as,

private void StartDrag(InputAction.CallbackContext context)
but Visual Studio is still not happy...

#

It's suggesting making a function that begins,

private Action<InputAction.CallbackContext> StartDrag()
which seems contrary to the example you gave me above. Confused...

austere grotto
#

+= StartDrag;

#

You're not calling the function you're just registering it to the event

delicate pollen
#

Fucking hell. I'm so sorry I'm wasting your time with this. =) Thank you.

#

I knew that. But there we are. =/

#

I clearly don't use events enough. Need to do some practice.

heavy aurora
#

Guys my brain is melting about this one thing. I want to make split-screen co-op on my game, but I have coded the controls of my characters like this, for example (it is a separated code receiving input and signals):

#

But then someone told me that, in order to separate devices and what device will control which character, I have to use the "PlayerInput" component, which I do believe is this one

#

But then how do I reference this component and let the code know that the "_c" is this component? 🤔

#

Also, do I really need to use this component in order to do split-screen? Every hint and assistance would be highly appreciated ❤️

#

I've read the documentation a bit and it seems this component is used to invoke events, so I probably would have to change my entire code lol

delicate pollen
#

Uh, I'm kinda fumbling around in the dark with this myself at the moment, @heavy aurora , but my suspicion is that if you Generate a C# class (as seen in the inspector in the attached image), you should be able to have a reference to it in each player control script, eliminating the need for the PlayerInput component.

#

As I can see in your first screenshot, you have '_c = new Controls()', so that should basically make that instantiation of Controls independent of the other player.

heavy aurora
#

Yeah, I think this is what I have been doing, the thing that kills me is that I don't have a single clue on how to indicate which device will use which object hm :(

#

When I have two characters, every device I use control both of them

#

(Thank you for your reply btw, very kind of you!)

delicate pollen
#

Hmm.

#

I'd like to dig into this, as I'm about to try and do something similar here... Unfortunately, I need to run before the shops close! I'll check back in later, @heavy aurora !

heavy aurora
#

I'll do some tests and read a bit deeper into the documentation, I'll let you know if I discover something!

austere grotto
#

The PlayerInput component is what you should use along with a PlayerInputManager as that's the system designed for local multiplayer

#

Tldr get rid of your whole _c variable and set things up via the PlayerInput component

heavy aurora
#

I see, very interesting and nice that Unity has now an "official" approach to local multiplayer, which I will for sure look deeper into it.

heavy aurora
#

This may look terrible but helps me a lot since I don't have to rework everything from scratch.

#

Though I'm not sure why, the keyboard & mouse is doing nothing, auto-switch is enabled but I can only play using my controller. Any suggestions on that?

delicate pollen
heavy aurora
#

That's a good point, how would one handle online multiplayer while using this method?

austere grotto
#

For online multiplayer you would just only have an active PlayerInput component on player objects that belong to the local client

#

The other clients will handle their own input

heavy aurora
#

Oh, true, you have only to sync input and other things

#

So everyone would send their own inputs to the server

delicate pollen
#

Sure, no, I get that. But I'm confused why I should change methodology for PlayerInput - granted, I only have very little experience with the new input system. =/

#

I mean, you might do a duplicate InputAction or something for a different set of inputs, but surely once you've got them setup in the script, they shouldn't interfere with each other? No? Feel free to tell me to go research this myself, btw. =D

heavy aurora
#

I'm sorry, I didn't understand your message completely, what do you mean to interfere with each other?

delicate pollen
#

And what I'm thinking is that that makes sense as one set of InputActions is bound to a specific set of keys.

austere grotto
delicate pollen
#

If you hit the same keys on character's that are using the same InputActions, then you'd get the same output on both of them, no?

heavy aurora
#

Oh sorry, my bad haha. Now that I'm using the player input method this doesn't happen anymore, as I can set which character will use which controller in the component

delicate pollen
#

Hmm, I get that's the workaround.

#

But - and I'm thinking aloud here - I was thinking you'd have different InputActions for each player, which would allow each individual player to be bound differently.

#

Then you'd get a reference to the correct InputActions at Start or Awake and then register to the correct events then or something.

austere grotto
#

It takes care of linking different input devices to different input action assets automatically

heavy aurora
#

Oh that's nice to know, it is kind of a shortcut/easy way to achieve that

delicate pollen
#

Right. That's... fairly reasonable... I guess I need to study these more to work out what I'm more comfortable with.

#

I'd kinda resigned myself to using the class a while ago.

heavy aurora
#

I'll probably go with the PlayerInput/PlayerInputManager for now as I am really focused on local multiplayer, I've tried online multiplayer for some time but it gave me a lot of headaches, a lot of things to learn.

#

PlayerInput really hates my mouse and keyboard though, I can only play with my controller now somewhy

delicate pollen
#

Yeah, tons to learn. Thanks to both of you, btw, that was very educational! And please stay in touch, @heavy aurora , I'm going to be trying the input system with online multiplayer shortly and I'd love to hear how your local game gets on!

heavy aurora
#

Thanks, friend! I'll surely keep in touch, showing progress. :) Unfortunately at the moment, the PlayerInput is giving me some headache, as the action asset is always disappearing from the component, even applying it on the player prefab.

austere grotto
#

Are you using PlayerInputManager?

heavy aurora
#

(I'm sorry I'm spamming on new year's eve, please enjoy your day and reply when possible!!! UnityChanCheer)

lunar drift
#

hey can i ask what is a good binding to like zoom in while aiming (right mouse button)

#

in need 2

#

like zoom in , zoom out

still topaz
#

Hey, so I wanted to make this feature for a project i'm working on where when you tap and then hold the movement keys the character starts running (normal holding = walk / Tap + Hold = Run) but i don't think it was working as i planned by using the current Interactions. I tried coding another one but it was a bit unreliable (it took a while to detect the input and sometimes wouldn't trigger imedeatly)

The best solution i came up right now is having a single "Tap" action whose method will trigger a bool that will timeout and become false again. If i start walking in the meantime the walk (by the normal hold interaction) It will just turn into running and set the bool to false.

Does anyone know a better way to do this with the new input system? Am I overcomplicating stuff?

delicate pollen
#

I'm pretty sure that's how I achieved a similar effect while using the new input system on an older project, @still topaz . It seems straightforward enough - that said, I'd also be interested in hearing if there's a best practice for this sorta thing with the new input...!

sullen swallow
#

Using NEW unity input system:

I'm trying to have the Running Audio STOP IF I'm still holding down shift (running) and then press c afterwards (crouching). (Both being hold down at the same time, but crouching would stop the audio from playing).

Movement script = https://gdl.space/pokutewaxi.cs

Input Manager script just in case = https://gdl.space/imakobagal.cs

trim hollow
wintry cloak
#

might seem stupid but what mouse button would you use for firing and aiming a weapon. Keep thinking it is left aim and right shoot but not entirely sure

austere grotto
tame oracle
#

Was there an update to the new input system? I'm noticing differences in what I'm used to and I don't know what to do now

mortal ridge
#

there's always updates. but you have to do them manually. so if you didn't, there shouldn't be

tame oracle
#

I want to do a simple WASD movement system but I don't know how to go about that

mortal ridge
tame oracle
#

I get no option for that

austere grotto
#

Then you'll get the option

tame oracle
#

Ok. What would a simple FPS input system look like? Does it even require those pink things?

austere grotto
#

nothing requires them

#

they are a very nice way to handle a 2D input vector

#

For an example check out the Starter assets

mortal ridge
#

why are previews always collapsing again? that's what i'm curious about

austere grotto
#

I collapsed/removed it myself

mortal ridge
#

how?

austere grotto
#

By pressing the little x

mortal ridge
#

interesting

tame oracle
austere grotto
#

The input vector is 2D

tame oracle
#

Oh Ok

drifting lynx
#

How can I have binds like "Shift+e" with the new input system?

austere grotto
austere grotto
#

which part

drifting lynx
#

"check if Shift is currently depressed"

#

@austere grotto I have this

#

but thats just the E

#

not the shift+

austere grotto
#

You will need another action that is bound to shift

#

separate action

drifting lynx
#

wait what about this?

austere grotto
#

Oh wait yeah I forgot about that 😛

drifting lynx
#

and another question

#

how do i put this in a vector3 composite...

austere grotto
#

wdym

drifting lynx
#

im trying to set up the controls for a friend

austere grotto
#

what are you trying to achieve

drifting lynx
#

he doesnt like E/Q for strafe

#

he would like shift+E/Q

#

but those are in a vector3 composite

austere grotto
#

I don't think you can have composites with modifiers

drifting lynx
austere grotto
#

I think this is all a little too bespoke for the input system

#

you'll have to build some of it yourself in code

drifting lynx
#

what if i have each of the axes in their own binding

#

hmm but that still wont work cuz i need them as floats

#

thank u anyway though @austere grotto

mortal ridge
#

@drifting lynx it's pretty easy extending / writing your own interactions. limitless potential

drifting lynx
delicate pollen
#

Hey, just as I said I'd keep in touch with @heavy aurora and @austere grotto gave me some great advice earlier, some code that seems like it'd be useful for local multiplayer if you're hellbent on doing it all yourself...

        IInputActionCollection2[] iActions = new IInputActionCollection2[8]; // Ideally you'd set this up in the inspector.
        iActions[0] = new Controls(); // 'Controls'-> some InputActions setup in Inspector. Again, add these in the inspector.
        
        inputActions = PrepPlayerControls(PlayerEnum.Player2);
        inputActions.Enable();

        public Controls PrepPlayerControls (PlayerEnum playerNumber = 0)
        {// Make '0' in the array a dupe of '1', so you can index by pl int (or enum)
            return (Controls)iActions[(int)playerNumber];
        }

Haven't got around to implementing this yet, but seemed potentially useful...!

ivory eagle
#

Maybe this is already answered but can't find it:

Why it doesn't letting me add my Input system to my script?

frozen flame
#

so im here to get some help

#

im absolutely new to unity and code

#

and im trying to make an object move

#

how can I do this?

austere grotto
#

Have you considered looking at some tutorials?

frozen flame
#

oh uh I dont need help anymore im watching a tutorial

austere grotto
manic ravine
#

Hello Guys, this is my first time posting here. I would like to seek help, have you tried the new input system with mobile touch? My onclick UI Button event is working when running on editor but on IOS device it is not trigerring. Thanks in advance

sonic delta
#

Is it good practice to have multiple Player Input component on any game object that needs to read input? I also have an in-game console that needs to know when tilde is pressed, not sure if I should dispatch an event for it using my event manager or just put the player input component on the in-game console manager game object, any ideas?

mortal ridge
#

@sonic delta it's fine. to have multiple components. though the manual workflow can be much nicer

rare pilot
#

Quick question for yall, I am trying too add an attack key to the third person controller that unity includes in their package. I have felt like I have coded it in right, but clicking the mouse button ends up producing this error. Anyone know what I am doing wrong?
Parameter 'Hash 1331344109' does not exist. UnityEngine.Animator:SetBool (int,bool) StarterAssets.ThirdPersonController:Attack () (at Assets/StarterAssets/ThirdPersonController/Scripts/ThirdPersonController.cs:307) StarterAssets.ThirdPersonController:Update () (at Assets/StarterAssets/ThirdPersonController/Scripts/ThirdPersonController.cs:124)

valid basin
sonic delta
valid basin
sonic delta
sonic delta
mortal ridge
#

why would it be messier

brave path
#

Bruh I installed the input system in unity cuz I wanted to add controller support but i changed my mind.So i uninstalled it and now I cant move at all can someone help?

violet niche
#

Hey hi! Happy new year 🙂
I wonder if anybody knows about this:

On the old input system, i was using Input.GetAxis and using as input L (Positive) and M (Negative) on the Project Input Settings. This gave me 1 to -1 values.

How could i do this with the new input system using the mouse delta instead (-1 being left and 1 being right).

mortal ridge
mortal ridge
brave path
#

Oh bruh I already fixed it lol I was so scared cuz my friends and I were working on it.

violet niche
mortal ridge
violet niche
mortal ridge
spark pumice
violet niche
#

left** lol

spark pumice
#

okay well, use mouse delta and divide it by Screen.width or Screen.height

#

it should give you negative values. The normalize processor might have been breaking that

violet niche
#

okay thank you 🙂

spark pumice
#

but this will mean that -1 is "I moved all the way from the rigtht side of the screen to the left in 1 frame"

undone imp
#

Hello! Im trying to detect input from the new input system, and store the information into a scriptable object. My problem is that the performed call back is happening at the same time as the started one, so the ButtonClicked property gets overrode. I thought about making a timer that waits 1-2 sec but i dont think thats the best approach.

mortal ridge
undone imp
#

and is there any way i can check for the started callback?

#

and to store it for 1-2 sec ?

mortal ridge
#

i mean yeah you can cache them manually of course

potent iris
#

Hi ... I'm moving an object with "playerRigidbody.velocity = movementInput * playerSpeed;". With gamepad it works smoothly but with keyboard it's like it's normalizing the input (I don't have actions processors set). In fact, if i change the above line to movementInput.normalized , the gamepad works like the keyboard. Any way to make the keyboard work smoothly like the gamepad ?

undone imp
#

but im caching them into the properties, but in the performed callback, the ButtonClicked gets overrode @mortal ridge

spark pumice
potent iris
#

I also tried modes Digital and Digital Normalized .. both same effect

#

and Analog same effect too

spark pumice
# potent iris yes exactly

so... that's the way a keyboard works. When you press A, it gives you -1. When you press D, it gives you 1. With a gamepad stick, you can have the stick halfway between center and right, so you can get 0.5.

What buttons would you like to press to simulate the stick being halfway between center and right?

potent iris
#

right of course.... :/

spark pumice
#

but the right button can only be on or off. There is no halfway on.

potent iris
#

i forgot it's just a basic switch

#

hmmm i'm doing a local multiplayer and the gamepad user will have an unfair (more accurate) advantage over the keyboard user

#

and i guess there's no way around it

#

besides maybe switching to a mouse

spark pumice
#

yeah, its a tough issue. You could force the gamepad to work like the keyboard, but that doesn't feel good for them. lmk if you come up with a brilliant solution!

potent iris
#

sure thing... here it is... i'm switching to mouse instead of kb 🤣

spark pumice
#

yep, that's the best I've ever come up with. Though it does tend to cause the opposite problem, where the mouse is more accurate than the gamepad. But 🤷‍♂️ you can't win them all

potent iris
#

delta is the one i want aye ?

#

Oh damn you weren't kidding... mouse is now like twice as fast

undone imp
#

@mortal ridge previously i was setting the property like this ButtonClicked = Input.GetButtonDown(KeyCode.E); in the update, do u know why in this case it didnt override in the same frame?

mortal ridge
#

no idea really

undone imp
#

I think all the updates are call at the same time and thats why

#

not 100% sure

lunar drift
undone imp
#

In this case public bool ButtonReleased { get; private set; } u can access the value from every class, but u can only set it in the base class where the field is

lunar drift
#

nah i mean the scrool

#

so like the public Vector2Control Scrool

mortal ridge
lunar drift
#

yeah but im trying to understand it cuz like when u scroll up i do something , and when u scroll down it do smthin else

mortal ridge
#

yes

lunar drift
#

?

#

but like how can i detect where i scrool

#

when*

#

and where

#

so like

if(scrool.up){
type("loool")
}```
sonic delta
#

Is it bad practice to create multiple instances of the generated input actions class in different places?

sonic delta
#

Is it better to put it in a manager object do you think?

austere grotto
#

More memory, more CPU usage, as each one will be processed separately

#

Yeah that's what I do generally, if using the generated class.

sonic delta
#

Using the singleton pattern?

mortal ridge
#

the memory is neglectable tbh. there are more advantages to multiple instances than a manager

austere grotto
#

depends

#

It's quite useful to be able to globally disable/enable action maps

mortal ridge
#

yes thats true. but mostly you only need subsets of an action map and then you can enable and disable certain parts of input on all your objects and then you have more granular control

dim jolt
#

Can I remap Fire1

keen cobalt
#

Can someone help me with my mouse input manager? I would like to be able to move the camera around with drag

#

I have a working script but I refactored my entire camera controller and now got to combine those two

#

So this is the working drag script

private void LateUpdate() {

        Vector3 pos =  Camera.main.transform.position;

        if (Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            Difference = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + CameraSpeed)) - pos;
            if (!drag)
            {
                drag = true;
                Origin = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + CameraSpeed));
            }
        }
        else
        {
            drag = false;
        }

        if (drag)
        {
            pos = Origin - Difference;
        }

        if (Input.GetMouseButtonDown(1))
        {
            pos = ResetCamera;
        }

        pos.x = Mathf.Clamp(pos.x, -panLimit.x, panLimit.x);
        pos.z = Mathf.Clamp(pos.z, -panLimit.y, panLimit.y);

        transform.position = pos;
    }
#

basically under the movement section I already implemented something like "if the cursor touches an edge... move towards it"

#

The MoveInputHandler is just a public delegate void MoveInputHandler(Vector3 moveVector);

manic ravine
#

Hello Guys, this is my first time posting here. I would like to seek help, have you tried the new input system with mobile touch? My onclick UI Button event is working when running on editor but on IOS device it is not trigerring. Thanks in advance

austere grotto
#

Pretty sure it explicitly doesn't support Unity remote right now or something

stark notch
#

Hello, i was wondering for topdown movement how i would best check if the mouse is currently being used or a different device like a gamepad.
I borrowed this code from the open project InputReader.

private bool IsDeviceMouse(InputAction.CallbackContext context) => context.control.device.name == "Mouse";

I was wondering if the mouse isn't being moved and you move the gamepad stick if it then will not say that the device is a Mouse but a gamepad?

#

Like it's mostly for aiming in topdown, if i have a mouse the character will go point to the position but if there is a gamepad then it will be pointing in the gamepads left stick direction

stark notch
#

I mostly need to make the player aim depending on the current input, if it's the mouse it will use the position in the world to look at the camera and if it's a gamepad anything where the movement is with a joystick it will use the direction the player points it in

ebon merlin
#
    public void Move(InputAction.CallbackContext context)
    {
        horizontal = context.ReadValue<Vector2>().x;
    }
``` This doesn't detect the input, I think I setup the Input Actions correctly
mortal ridge
#

did you enable the action?

ebon merlin
#

Depends what you mean by that

#

I made a Player Input on my player and assigned all properties with my Input Action, and made the buttons inside the Input Action

austere grotto
stark notch
#

you need to enable your action map i think

#

for me it's gameplay

ebon merlin
stark notch
#
void OnEnable()
{
  input.Game.Enable();
}

I am not fully sure how you would need to do it but something like this, you need to enable inputs when using callback context

austere grotto
#

you dont need to do this when using PLayerInput^

stark notch
#

oh yeah wasn't sure, i had this myself but i generated a custom class. I know that Inputvalue also works if you use that instead of callback context like this

void OnMove(InputValue value)
{
  moveVector = value.get<Vector2>();
}

something like this

ebon merlin
#

Any reason it wouldn't work then?

austere grotto
ebon merlin
#

Neither are being called not Jump or Move

stark notch
#

try checking the names of your inputs when it's on a component

#

like what methods it says

#

check if the name matches

#

could be you need to say OnMove not just Move

austere grotto
#

ideally showing the hierarchy, with it selected and the inspector

ebon merlin
austere grotto
#

ok dumb question - you're in play mode? You started the game?

ebon merlin
#

Yes

austere grotto
#

Can you try clicking on the game window to give it focus?

stark notch
#

could it be they do need to do the enable somewhere?

ebon merlin
#

Clicking didn’t do anything

austere grotto
#

also can you show a screenshot of your console window while playing

#

and after you did some input

ebon merlin
#

It's the same nothing changes or happens

austere grotto
#

wait

#

what if you change "Default Scheme"

#

to None?

#

What is the Player scheme?

ebon merlin
#

You mean Default Map? Default Scheme only has Any

austere grotto
#

on your PlayerInput component

ebon merlin
#

I put Default Scheme to any still nothing

austere grotto
#

I'm not really sure

ebon merlin
#

I think it might be something with the Input Actions but I have no clue what

austere grotto
#

seems like it should work

ebon merlin
#

I followed a tutorial so I'm thinking it should work too

stark notch
#

maybe you can temporarily try a different way of handling inputs if you don't mind

ebon merlin
#

Sure

stark notch
#

You can use the send messages method to handle inputs like this

so for move it would be

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

if i am correct something like that should work with the send messages method

austere grotto
#

yes that should work with SendMessages

stark notch
#

if you don't need any extra checks this method of handling input should be fine

ebon merlin
#

Doesn't work unless I did something wrong

stark notch
#

check if the playerinput is on send messages and if it shows methods like OnJump and OnMove

austere grotto
#

Hoenstly try a fresh scene

#

ANd maybe a fresh Input Actions Asset

#

with an empty GameObject with your script and nothing else

#

something fishy is happening here

ebon merlin
#

I made this project the other day added my player, today I switched to input system and made the script nothing else

stark notch
#

if you use the inputvalue this should be your setup, where my red arrow points at you need to see the 2 extra methods OnJump and OnMove

ebon merlin
#

Yeah I did see that

stark notch
#

also the methods right

ebon merlin
#

So I have this.

#
    public void OnMove(InputValue value)
    {
        horizontal = value.Get<Vector2>().x;
    }
``` And this
stark notch
#

normally that should work

stark notch
#

i guess you can try what Preator said, i don't think there is anything else that you need if you use inputvalue than this and it should work

ebon merlin
austere grotto
#

where did you put it

ebon merlin
#

Under the horizontal = line

austere grotto
#

and no errors in console? And errors are enabled in console?

ebon merlin
#

No errors, they should be enabled

#

The issue is just the input system, everything has worked in other projects with normal input, I don't think it would be anything with the script or the project

#

What are the default steps? Import, create Input Actions, make a script do the callbacks, assign them in the Player Input component then it should work? This is what I did

austere grotto
#

Project Settings -> Player -> Active Input Handling

#

what is it set to?

ebon merlin
#

Input System Package (New)

austere grotto
#

Try restarting Unity?

ebon merlin
#

Is there no other steps like enabling the input actions or anything?

#

Restarting didn't work either

stark notch
#

I myself use a generated class where i implement the interface from

#

i always need to do this for my inputs

#
private Input m_Input;

private void OnEnable()
    {
        if (m_Input == null)
        {
            m_Input = new Input();

            m_Input.Gameplay.SetCallbacks(this);

            m_Input.Gameplay.Enable();
        }
    }

Here input is my generated class, and gameplay is my collection of actions (action map)

ebon merlin
#

I have that too or something similar

stark notch
#

I mostly took code from the open project since it looked like a good way to implement inputs

stark notch
#

I am wondering about something myself now, i want to make my player rotate towards my mouse or if my gamepad is being used towards a sticks direction
But i am not sure how to properly handle the check if one or the other is currently being used