#🖱️┃input-system

1 messages · Page 5 of 1

potent iris
#

I started to actually blame the mouse lol

#

(until I tried another one)

frigid ridge
#

Are you reading and applying the input in Update?

potent iris
#

yep

#

lookInput = GetLookInput();
ProcessLook();

This is the GetLookInput

private Vector2 GetLookInput() => new Vector2(inputHandler.lookInput.x, inputHandler.lookInput.y);

This is the look around

private void ProcessLook() {
        if (playerSettings.invertLook) {
            cameraPitch += lookInput.y * -playerSettings.lookSensitivity;
        } else {
            cameraPitch += lookInput.y * playerSettings.lookSensitivity;
        }

        cameraYaw += lookInput.x * playerSettings.lookSensitivity;

        cameraPitch = Mathf.Clamp(cameraPitch, playerSettings.upperLookLimit, playerSettings.lowerLookLimit);
        cameraEyeLevel.rotation = Quaternion.Euler(cameraPitch, cameraYaw, cameraEyeLevel.rotation.eulerAngles.z);
        transform.localRotation = Quaternion.Euler(transform.rotation.x, cameraYaw, transform.rotation.z);
    }```
#

With gamepad it's super smooth

south void
#

I just noticed it's been duplicating itself when I load a new scene

#

what does this warning mean?

potent iris
#

O_o

frigid ridge
potent iris
#

guess so haha 😛

earnest sparrow
#

you guys think this is gonna generate any problem?

potent iris
frigid ridge
#

I would try creating a separate action for mouse delta to make sure there isn't any issues coming from the controller setup

oblique jackal
#

OK guys

#

I'm very very confused about the input system. I started my project with the default InputHandler that comes with the thirdperson template

#

And it's working ok, i guess

#

thing is, i want to create a different interaction for my movement. For example, i want the character to dash whenever i double tap WASD. And thats just a new interaction. Got it

#

not sure how im supossed to get that with the functions i get like OnMove(InputValue value)

#

should i change it to be event based?

#

Every single video i watch tells me something different

#

I have even tried to create a new action like "DashLeft", add a binding to it to my A key, add the multitap interaction. Go to the script, do OnDashLeft(Inputvalue value)... and it doesnt really compute

#

im pretty lost and ive lost more time on this than im proud to admit, would apprecciate any help i could get

potent iris
glossy flower
#

I THINK I've got a pretty simple problem, any help would be greatly appreciated.
Ok so I can move around my UI with my controller just fine, but I can't actually press any of the UI buttons with my controller. Anyone know how to do UI input from controller? (I've found tutorials online of how to navigate with controller which works but I can't find anything on how to accept the controller input)

glossy flower
#

Fixed it

teal yacht
#

If you are using the new input system, you can always detect with "OnDeviceChange"

public void OnDeviceChange(PlayerInput playerInput)
{
    isGamepad = playerInput.currentControlScheme.Equals("Controller") ? true : false;
}

in this case -- I have two control schemes set up in the input system which I named "KBM" and "Controller"

glossy flower
#

that's what I was doing but when I went to assign the function to player Input it wouldn't appear

#

I tried to do at least

teal yacht
#

so even setting up 2 separate control schemes inside the input system, the result is always false?

glossy flower
#

yep

zenith carbon
#

ok so i have done some further testing around my wasd and arrow key problem.

if i use two different input actions asset files (one for player input, one for the event system / input system ui input mpdule) i can use wasd and arrow keys as normal

if i have the wasd and arrow keys action bindings be under a up/down/left/right composite it works.

so:
if both the ui and player input use the same input action asset while UI/Navigate has wasd and arrow keys, then i can't use those keys for player movement unless i put those under a up/down/left/right composite.

that seems very weird, and i don't think i had those problems before updating from 2022.1.11f1 to 2022.2.20f1

#

oh it's even weirder than that. i thought that the composite worked in general. but seemingly only when it's taken from a new input action file and renamed.

#

both files (named 3333 and 2222) are new. in 2222 i removed all actions beside Move, and then removed all bindings beside the WASD composite, then renamed move to WalkRight

#

in 3333 i remove all actions, then made a new action called WalkRight, then added a up/down/left/right composite. and added the bindings for WASD, then renamed the composite to WASD, then made sure that all the properties of the action, composite and individual bindings are the same as 2222. but that one don't work

#

the code they are supposed to run is:

#

so the fault can't be with that

#

the player input looks like this:

#

(although Actions field uses 2222 when i was testing that obviusly)

#

event system looks like this:

brisk cove
#

hey all im having some real issues of my onTap triggers after my OnTouch event. does anyone have any idea how to handle this?

brisk cove
#

basically I have a ui im trying to show and hide. the default is to hide on user touch but allow the user to tap the screen to show on and off the menu

brisk cove
#

basically my primary touch always triggers and conflicts my ontap logic

craggy stream
#

Does this code that I took from Unity's manual works?

austere grotto
craggy stream
#

Ok then

quaint patrol
#

Trying to make a Dash ability for my character, would this be correct setup for such a thing?

brisk cove
#

any smiple way to trigger tap and press separately?

#

currently they are always together

marble current
#

Hey folks ,this might be a stupid question but is there a way to use the generated C# class when querying a PlayerInput object directly?

Like right now I'm doing playerInput.actions["Move"].ReadValue<Vector2>(), but I'd like to somehow use the Input Action Assets generated code and do something like playerInput.actions.testMap.Move.ReadValue<Vector2>();. I'm using different maps in multiple places and being able to use strongly typed names as opposed to strings would make it easier to know which map I'm using where and avoid breaking changes going unnoticed. Thanks!

austere grotto
#

PlayerInput and the generated C# class are two different approaches to doing the same thing.

#

Also if you're doing this: playerInput.actions["Move"].ReadValue<Vector2>() there's probably not a great reason for you to be using the PlayerInput component in the first place.

#

Unless you're doing local multiplayer

marble current
austere grotto
#

well, no then 😛

marble current
#

I'd be fine with migrating away from PlayerInput, I'm still getting my bearings with this system. I like it a lot but I feel like I have some gaps of understanding

#

If I ditch PlayerInput, would it be possible? I don't see how to then grab a specific player's input from the action map itself

austere grotto
#

generally with PlayerInput you don't access actions manually

#

generally you use one of its modes - typically send messages or unity events

#

to listen for input

austere grotto
#

like device management/ assigning players to devices etc

marble current
#

Hmm... In a way it would make some things easier for me, but realistically looking at the underlying source for PlayerInput I think it does more than I'm willing to deal with by hand

#

Well, I appreciate the answer! I'll keep playing with it and maybe switch to constant strings to at least get a tiny bit of safety

opal kiln
#

Is there any way to store System.Action<InputAction.CallbackContext> in a terser delegate? I tried making a delegate "delegate void ControlAction(InputAction.CallbackContext context)" but when I tried assigning it to an InputAction it said it couldn't cast ControlAction to System.Action<InputAction.CallbackContext> (even though the parameters are identical)

#

I just want to avoid writing System.Action<InputAction.CallbackContext> all the time.
Currently i'm doing a using alias by doing "using ControlAction = System.Action<InputAction.CallbackContext>" but I'd rather just define one delegate that's equivalent to System.Action<InputAction.CallbackContext> and be able to use that directly.

eager kraken
#

wtf is this error?? (using inputfields btw)

#

this just started showing up

austere grotto
#

e.g. via GetAxis or GetButton

eager kraken
#

cos the only time im asking for input is the G button, which i have configured

#

the rest just started happening, and now i cant write in my inputfield

austere grotto
eager kraken
#

its the inputfield

#

but how do i fix this

#

reinstall the base plugin? if thats even possible

austere grotto
#

input fields don't generally read input axes directly

#

you can click on the error

#

and see the fulls tack trace

#

to get a better idea of the source of the problem

eager kraken
#

it leads back to the inputfields BaseInput.cs script, and the input module

#

also the eventsystem, but thats just UI stuff

austere grotto
#

Ok so check out your input module

eager kraken
#

this is what i dont get, cos it was literally working earlier

#

this just happend

austere grotto
#

what axis bindings do you have set on your input module

eager kraken
#

and one for f and b

austere grotto
eager kraken
#

just to double check, do you mean Input Manager?

cloud cliff
#

Hey! I've been messing with this for hours and I'm losing my mind. I'm getting this error. All it is is the ThirdPersonController script and I changed like 2 lines because I'm using Mirror and want to make sure the player has authority. http://pastie.org/p/6jIbJpP4jVAtcSLBU4ywBl

austere grotto
#

I mean input module

austere grotto
eager kraken
austere grotto
#

on your EventSystem gameobject

#

show the inspector for it

#

yes the StandaloneInputModule

eager kraken
#

oh this

austere grotto
eager kraken
austere grotto
#

I would recommend deleting your event system object and creating a fresh one from the menu

#

that's where those weird axis names are coming from

cloud cliff
eager kraken
#

yes ok thnaks

austere grotto
cloud cliff
#

sorry i wasnt trying to sound rude lol. so I took a look and the camera reference wasnt on either of those lines

cloud cliff
cloud cliff
austere grotto
thorny osprey
#

Hey! How can I call a method every frame that the click button is pressed? I know I can check the performed and cancelled and make a bool isPressed, but I'm wondering if there is any way to call performed every frame that is pressed

lyric mountain
austere grotto
unborn ocean
#

I started a new indie horror game project with my friend and I'm getting this problem;

I am using an FPS Controller and Unity's character controller asset.

Please let me know if there's a way to code camera movement for playstation 5 input 🙂
(sorry for bad video quality)

unborn ocean
devout wagon
#

I have objects in my scene with colliders, and i can trigger OnMouseOver on them, and i can raycast to hit them (as shown in the below code). But, if i move the object at runtime, i can only hit it/hover it if i put the cursor on the original position of the object. I checked that the collider is indeed following. Any ideas?

austere grotto
#

I don't see anything immediately wrong with the code...

devout wagon
#

tomorrow :/

devout wagon
austere grotto
#

also what is logging

#

"hit something...: <name"

devout wagon
#

Its not static. See the code i made above to raycast. Im trying to figure out what is hitting what 🙂

austere grotto
#

what is it logging?

devout wagon
#

It also logs the right objekt, but on its original position if I move it

austere grotto
#
Debug.Log("hit something..." + selection.name, selection.gameObject);```
#

add that second parameter

#

and then when you see the log, click on the log one time and see which object it takes you to in the hierarchy.

#

but also.. can you do the log in OnMouseOver? That's where the highlighting is happening right?

devout wagon
#

I might not be able to do it today

#

But I will do it asap

south void
#

I need some help with the input system and I can't figure out how to fix it

#

whenever I load a new scene (in this case Level 2 from Level 1), my input system stops working and I can't move my player anymore

strange fox
#

Is there a built in way to detect whether you've release an input with unitys new input system?

Similar to using an InputValue and value.isPressed?

I'm looking to detect when a player has released a button with the new input system.

sullen lintel
#

InputAction.WasReleasedThisFrame is one

strange fox
austere grotto
south void
strange fox
#

@austere grotto @sullen lintel Thank you so much 🙏

sullen lintel
#

persist it maybe /

south void
#

Every level just has a player prefab because the game is on a level-by-level basis

#

they actions variable on PlayerInput just clones itself or something when a new scene is loaded

south void
sullen lintel
south void
#

the Player gameobject

slate shoal
#

I'm hooking into the right-click input action used by the ui input module and trying to listen for when it is clicked down. im struggling to distinguish between the press and release stages of a right click.

the action.performed event is invoked when pressed and released, but the started and canceled are never invoked. any tips on how to tell if the right click is pressed or released when the only event that works is performed which fires for both?

#

ah looks like ctx.ReadValueAsButton() returns true on press and false on release

austere grotto
#

should make your own

#

with action type: button

#

and no interactions

#

by default started will happen when it's first pressed. canceled when it's released.

slate shoal
austere grotto
#

use the event systenm

#

Put a script on the button with IPointerClickHandler

#

and read the mouse button from the PointerEventData

slate shoal
#

In this case I cannot use that interface for structural reasons

austere grotto
#

I don't know what that means but that's the right way to do it

#

explain your "structural reasons"

#

You can also use the EventTrigger component to get the callback as a UnityEvent

austere grotto
slate shoal
#

I'm working on a context menu system. Any UI in any scene may have a component which implements an interface which provides items for said context menu. These components do not have a reference to the context menu system, they simply provide items when asked. I cannot easily have them all reference the context menu and tell it to Show, and I do not want to use a static. Thus I want a single, higher level input component that handles detecting clicked game-objects and asking them for their context menu items.

austere grotto
slate shoal
#

How's that?

austere grotto
#

that's what events do, they invert dependencies.

#

static event would be simplest

#

of course

#

with a sender param

#

but you could also have your context menu syustem susbcribe to every button if you insist on avoiding static

#

either way one of these things is going to have to reference the other

slate shoal
#

The ContextMenuUI does not know about all the other ui across the app which should show a context menu when clicked. It is simply a view for a list of context menu data

austere grotto
#

you're going to need to devise some way for these things to get data to each other

#

that's probably going to be through some kind of singleton or static event.

#

even if it pains you

#

the alternative is much nastier

#

doing manual raycasts etc.

slate shoal
#

I don't see why?

austere grotto
#

because you're duplicating work the event system is doing already

slate shoal
#

Sure but is it really that big of a perf hit to do on a right click? It's makes everything else much easier. Everything is decoupled, simply implement some IContextMenuItemSource on any component on a UI object that provides relevant menu items and just like that it works.
But yes my next step was going to be modifying the input module to expose an event

#

InputSystemUIInputModule already provides GetLastRaycastResult so I may just be able to use that. I haven't confirmed the order of operations yet tho (whether separate right click event is invoked before m_PointerStates is updated int the input module)

slate shoal
#

This test seems to work. No extra raycasts and no input module modifications

public class ContextMenuInput : MonoBehaviour
{
    [SerializeField] private InputSystemUIInputModule inputModule;
    private Vector2 _pressPoint;
    
    private void OnEnable() => inputModule.rightClick.action.performed += OnRightClick;
    private void OnDisable() => inputModule.rightClick.action.performed -= OnRightClick;
    private void OnRightClick(InputAction.CallbackContext ctx)
    {
        var pressed = ctx.ReadValueAsButton();
        if (pressed)
        {
            _pressPoint = inputModule.point.action.ReadValue<Vector2>();
            return;
        }

        var result = inputModule.GetLastRaycastResult(0);
        if (!result.isValid)
            return;
        
        var releasePoint = inputModule.point.action.ReadValue<Vector2>();
        if (Vector2.Distance(_pressPoint, releasePoint) > 1) // Mouse was dragged
            return;
        
        string gameObjectPath = "";
        var parent = result.gameObject.transform;
        while (parent != null)
        {
            gameObjectPath = gameObjectPath.Insert(0, "/" + parent.name);
            parent = parent.parent;
        }
        
        print($"Clicked: {gameObjectPath}");
    }
}
marble current
#

Hey peeps, would it make sense to add a way to confirm a player should join in PlayerInputManager? I guess this is more of a a feature suggestion than a question, but it would be nice to be able to accept/deny a request. For example, if I only want the player to join when playing start rather than any button, the class doesn't seem to have any logical override point to add it in

austere grotto
marble current
#

That's fair, I could just listen for new players joining, but then put them in a holding state until I get the input I want

#

Thanks!

#

My only concern would be to miss the original input that triggered the join if it was already what I wanted, but I guess I'll play with it to see if it's actually an issue

austere grotto
#

And require a short holding time or whatever. Could have a separate action map for the holding state even.

marble current
#

Interesting, I'll play with it thanks for the suggestion!

hazy silo
#

Getting some weird drift on my right xbox controller joystick while idle.
I've tried setting the deadzones with no change..
any ideas?

#

Can this be solved in unity or is it a hardware issue?

charred wagon
#

0.79 is a lot

#

Dunno what you could do, except try another controller if possible

hazy silo
#

Yeah will have to grab another nearby I just had one handy thought it odd to drift this bad, probably hardware its an older controller.

devout wagon
# austere grotto Can you add something to the log statement?

Hi again. So, i recorded a video of the issue, and a screenshot of the inspector + code. Notice how the rigidbody on the sphere doesn't let it fall down, and how the hover effect is only triggered at the original spot. This is true for any object in my scene. There are no scripts enabled, its not static and i checked that the project settings for Time is fine.

austere grotto
devout wagon
austere grotto
#

maybe show screenshot of them

devout wagon
#

Does it look alright?

austere grotto
#

see how you have Auto Simulation disabled

#

that's your problem

devout wagon
austere grotto
devout wagon
austere grotto
devout wagon
austere grotto
#

auto simulation syncs transforms but it also does a lot of other things you might not want

#

like resolving collisions

devout wagon
austere grotto
#

moving Rigidbodies

#

etc.

devout wagon
#

ah ok

austere grotto
#

If you want collisions etc to work you'll want to leave the physics simulation enabled

devout wagon
#

Awesome. Thanks a million for the clearup..!

iron orbit
#

Question, is there a way to reference the connected controllers and assign them to their respective player when moving to a new scene? Right now it seems to be decided by whoever clicks a button the fastest.

iron orbit
#

Im just gonna use don't destroy on load or something

gusty herald
#

does somebody know how I can make it so an interactive rebind will only work on axis

#

or would that be automatic

#

cause I don't want that players can accidently rebind movement (currently Vector2) to like, ... the A button

gusty herald
#

nvm it seems to be automatic to understand that

#

great

misty crow
#

hello everyone, does anyone know a great tutorial for shooting with the input system

midnight pebble
#

Hey, does anyone know how to navigate UI using a joystick with the new input system? 🙂

tame oracle
#

throw one of those bad boys on the singleton game object you have your event system added to. Its also a good idea to create a new schema for your UI actions.

wintry hawk
#

Hey, just wondering if there's something wrong with having two instances of PlayerInput in two different scripts. I have an instance of it in my first script, and when I Debug the Vector2 movement it works perfectly fine. But its not working with the second script. It's doing the exact same thing code wise but I keep getting (0, 0). Even without the instance in the second script I can still access its parameters (I.E. input.CharacterControls.Movement.ReadValue<Vector2>(), but I get an object reference error without it. Any suggestions?

frail spear
#

Hello everyone, I'm trying to use the 'new' input system to create a local multiplayer game in which the first player uses WASD and the second uses the arrow keys. I don't know why, but only the last player added to the scene can use the input system.

What I did:

  • Create the Input Action and configure 2 action maps (player1, player2) each one with their own actions and bindings.
  • Defined Player Input for each player, setting the default scheme and map for each one, and changing the behavior to 'Invoke Unity Events'
  • Set the callback context for 'Move' in Events
  • Defined public void onMove(InputAction.CallbackContext context) {.....} in PlayerController

And that's it. I can't manage to get both players moving, only the last one.

austere grotto
tawny kraken
#

i'm having a really odd issue with the InputSystem and would love some help! I'm building a multiplayer game, and my player prefab has a PlayerInput component directly on the prefab's root object.

When connecting to the game as a remote client, the PlayerInput component just doesn't fire events. However, if I run the client in the editor and toggle the PlayerInput off/on again at runtime, it starts working.

Seems like there's an issue with the other player prefabs in the scene all having their own PlayerInput and they're conflicting with each other on the local client.

Is there a best practice I'm missing with PlayerInput? What's the best way to deal with this component in multiplayer?

austere grotto
#

It's really for local multiplayer

#

And you definitely don't want the other player objects to have active ones if you do use it.

tawny kraken
#

i'm not using the InputSystemManager or anything. only reason I really wanted to use this component is for the interactive rebinding features.

austere grotto
#

You don't need PlayerInput to get interactive rebinding

tawny kraken
tawny kraken
austere grotto
tawny kraken
austere grotto
#

That's a solution

#

Each PlayerInput tries to grab a control scheme/device

tawny kraken
#

it seemed like the last activated player input component was the one awarded control over the input scheme, which would explain why toggling it off/on again would put it at the top of the stack and give it control again

#

but i don't understand why it didn't work for me to just set all the player input components to be disabled, and only enable it for the sole local client

idle trail
#

So I had my InputAction generate code, but I am not sure how to get it. I can't make a variable to assign the generated code to. So like the code I generated is called GenericInput with an action Interact. How do I get to that from the InputAction?

#

found it

idle trail
#

Is it true that if you use generated code, the keybinds can't be rebound at runtime?

frail spear
dawn fjord
#

Hey guys! Can I ask question about the old Input Manager here too?

coarse rune
#

hi everyone, im trying to make a topdown game in 2d, i have this code to rotate weapons but it only works with mouse input. Is there a way to get something similar to work with controller/joystick as well using new inputsystem? this has stumped me for like the past 2 days

glossy flower
#

My Controller Haptics are not working, any help would be much appreciated, here's my code (I'm using a Nintendo Pro Controller connected by bluetooth to my windows laptop)
IEnumerator SetControllerHaptics()
{
if(controllerCheck.usingGamepad)
{
Gamepad.current.SetMotorSpeeds(0.5f, 0.5f);
yield return new WaitForSeconds(1);
InputSystem.ResetHaptics();
}
}

earnest sparrow
#

i can't understand how to make the input's code

#

Why do i need to give a Private void and add an "On"X thing?

austere grotto
austere grotto
glossy flower
#

It's just not vibrating my controller

austere grotto
#

Have you added Debug.Log to verify?

earnest sparrow
austere grotto
#

have you considered following a tutorial or some examples?

earnest sparrow
delicate pollen
#

I've been going through the Unity Open Project ("Chop Chop") for architecture examples and I was reading up on how they're using the Input system. They're generating a custom c# script (which is what I've used in the past)... but I've heard there's a better way to use the Input System so it's more flexible for multiplayer applications - using the Input System component. Does anybody with experience using the Input System have any thoughts on this?

#

Just looking for advice from some old hands.

austere grotto
#

it gives you mostly automatic device management

glossy flower
austere grotto
glossy flower
#

I just printed a log to the console

austere grotto
#

where

glossy flower
#

In the coroutine

#

outside and inside the if statment

#

I've been stuck on this for while and I'm pretty sure it's not the code

delicate pollen
#

So this is doing the whole thing through components. I think you were the guy I was talking to about this before. Would you say there are many downsides to doing things this way? In your experience, would you say you could easily use the Scriptable Object 'Channel' pattern with this? I guess you'd put the PlayerInput/PlayerInputManager on a gameobject in a persistent Initialisation scene...

austere grotto
glossy flower
#

I'm actually not sure, do you know how I can check that?

austere grotto
#

seems kinda iffy

#

"implements basic gamepad functionality."

#

good chance that doesn't include haptics

glossy flower
#

I should try another controller to see if it works

#

I don't have one on me right now but I can get one soon, thanks for the help

delicate pollen
#

Sorry to bother you again, @austere grotto , but would you say there are downsides to using the Input System through the PlayerInput/PlayerInputManager ?

austere grotto
delicate pollen
#

Could I not also do a custom C# script? I'm... not sure what the problems of being locked into handling input through that component would be. If it's basically... serving the input I've set up in the Input System to me, then what are the issues? Sorry to keep bugging you, I'd just love to game out what I need before I start this project.

austere grotto
delicate pollen
#

10-4. One last one? As above, would you say you could easily use the Scriptable Object 'Channel' pattern with this? I guess you'd put the PlayerInput/PlayerInputManager on a gameobject in a persistent Initialisation scene. No worries if you can't respond to this, figured I'd take a shot. =)

austere grotto
#

I'm actually not familiar with the ScriptableObject "Channel" pattern.

delicate pollen
#

Gotcha, no probs, thanks. =)

austere grotto
#

Is that like using an SO as an intermediate reference that multiple objects have reference to in order to communicate with each other?

delicate pollen
#

Yeah, basically... Hang on.

austere grotto
#

yeah ok, figured

delicate pollen
#

I'm thinking 'yes', but I've yet to sit down with it (and I'm about to hit the hay now, so... =D)

austere grotto
#

I don't think there'd be any problem using such a Channel approach as long as you're comfortable with using and creating delegates dynamically. You'd need to have the SO basically do a Dictionary<Player, SomeDelegate> to do this properly

#

since the players are dynamically spawned with PlayerInputManager

delicate pollen
#

...Right. Okay. I'll have to think about that. =) Thank you for your advice.

tawny kraken
idle trail
#

Could someone link a good tutorial on how to use generated code for the new input system. I have it all setup, but my actions aren't being performed, and not sure why.

#

never mind, had to call enable on it.

fair siren
#

when using Debug.Log(Mouse.current.scroll.ReadValue().y); What does the 120 or -120 signal when scrolling ?

I find a bit odd from the old Input system one of just 1 or -1.

#

docs just say The input from the mouse scrolling control expressed as a delta in pixels since the last frame. Can come from a physical scroll wheel, or from touchpad gestures.

#

just wondering to what is the old mouseScrollDelta -1 or 1

#

I'm guessing magnitude?

limber gull
#

Not sure it can be counted as magnitude as its only about the delta Z value with the scrolling (i believe its z)

#

But its kinda the same deal either way i think

fair siren
old mulch
#

im trying to add local multiplayer to my game but ima having problems with the devices joining as one

#

does anybody know how to fix this

hazy silo
#

Woke up today and I'm no longer getting button release event data. Are we surprised? Not at all.

idle trail
#

Does Parallel.ForEach work in unity? I know there are issues with accessing engine resources on async calls, but are there issues here?

austere grotto
idle trail
austere grotto
#

the jobs system isn't so muhc a workaround as an officially sanctioned/optimized way to do multithreading in a unity-friendly way

idle trail
#

Yeah, I gotta look into it more, I think alot of what I am facing currently could be solved by it.

analog zenith
#

Anyone know why my WASD keys would stop working after upgrading from 2020.3.4f1 to 2021.3.12f1?

#

I'm reading the movement input of my player as a Vector2, it's coming back as 0,0 no matter what

#

All other inputs are working fine though

pulsar onyx
#

Hey guys, i have a little issue, whenever i move down my joystick on the gamepad, my character walks by himself to the right, VEEERY SLOWLY, but when i use the keyboard, it stays still, what's going on? i want him to stay still when i press down, but it only works win the keyboard

analog zenith
#

Any input that's just treated as a button press is working, but anything related to an input axis isn't

analog zenith
#

When you physically move the analog stick down, that's not going to always be a perfect x=0 y=-1 input

#

There's always going to be a little bit of error both from the way analog sticks work and the way humans work.

#

You need to ignore any values below a certain threshold and treat them as zero otherwise you'll run into issues like this

pulsar onyx
#

how do i set up deadzones?

analog zenith
#

To be honest I'm not sure, I haven't really done much with gamepads in Unity

#

But that's just my guess as to what's going on

pulsar onyx
#

yeah probably, initially i thought it was an issue with the fact that i added a vertical check variable, but i tried removing every single vertical check and it still SLOWLY walks to the right, so i probably have to set up dead zones

analog zenith
#

Meanwhile I just can't get my player movement input axis (or literally any other input axis action) to read anything but 0

#

The only thing I changed is my Unity version

#

Hmmm setting it to Pass Through fixes it. Weird.

pulsar onyx
analog zenith
#

Your movement script will need to check and process the x and y values of the movement input before actually applying them to the player

analog zenith
#

That's up to you to figure out, I don't know your code 😛

pulsar onyx
#

i can send a screenshot of my movement code if it's not a problem for you

#

i'm a beginner so there are a lot of things i still have to learn

analog zenith
#

(heads up that I'm blind and cannot read screenshots)

pulsar onyx
#

don't worry they aren't THAT illegible

#

i HOPE

analog zenith
#

No I'm being serious, I'm blind

pulsar onyx
analog zenith
#

I cannot read without a screen reader

pulsar onyx
analog zenith
#

Hehehe turns out my bugs were not mine

#

Input System 1.4.2 and 1.4.3 are heavily smashed

#

I reverted to 1.3.0 and all the issues went away

fading ruin
#

어몽어스 써씨 바카

analog zenith
fading ruin
#

So I'm guessing it can't read foreign languages 😞

slim nest
#

Using the new input system, I'm getting opposite mouse scrolls in editor and the linux build (eg 1;-1 vs -1;1)

sharp geode
#

is there a way to prevent player input manager / the multiplayer input from associating the editor with user 0?

austere grotto
night island
#

Hi, I am having a issue where unity is getting a input from somewhere and controllers I make keep moving off to the left. I have no idea why I have unplugged all input devices and it still happens. Please any help would be AWESOME!

night island
grim swan
#

getting scrolling seems super unsensitive I need to scroll waaay too much to get any response

austere grotto
grim swan
#

I am

#

I think I am

#

Like this?

night island
#

I think I figured out the issue. In the Input Manager there is two Horizontal options, one is for joystick and the other for keyboard. It seems that the joystick one is the one returning the false input

#

Any advice on how to get it to stop doing it

austere grotto
# grim swan Like this?

if that's the data you're using, sure. Though I would print some more useful info out too so you know wtf you're looking at:

Debug.Log($"Mouse scroll delta is [{Input.mouseScrollDelta}]");```
grim swan
#

well am i getting the scrolling wrong?

#

is there like a better way to get it?

austere grotto
grim swan
#

wdym

austere grotto
grim swan
austere grotto
#

where is this happening

grim swan
#

in update

austere grotto
#

etc.

#

Then it's fine

#

well

grim swan
austere grotto
#

it also depends on what you're doing with this Scroll thing

grim swan
#

I wanted to make it like in an rts how you can scroll in and out to zoom

austere grotto
grim swan
#

I'm not using it yes I'd never used scroll before

#

yet*

austere grotto
#

Then what is the issue you're asking about?

grim swan
#

I'll probably use it like
main.size = 5 + scroll

#

well

austere grotto
#

it's a delta

grim swan
#

here I'll try it and see if its as insensitive as it seems

austere grotto
#

not an absolute value

grim swan
#

ah

#

theres my issue

#

ok yeah its not as insensitive

#

cool

#

thanks!

copper matrix
#

Is there a way to make a event based input system and not check foe input.getkey every frame?

austere grotto
copper matrix
#

Oh there is? Let me check that out

harsh oriole
#

and ideas how I should handle mouse input in a game where my Physics Tickrate is higher than my Framerate?

#

i use mouse to control physics and I'm having issues because there are multiple ticks in-between each frame and I'm assuming the mouse input becomes 0 during them

austere grotto
harsh oriole
#

But my physics tick rate is 360hz

#

At 60fps that’s 5 physics ticks for every frame

#

So I think that gist/concept goes out the window

#

Right now I’m attempting to reuse the last mouse value and decay it slowly over time which is working alright

#

But that is obviously very dependent on frame rate and will produce inconsistent mouse movement across devices

analog siren
#

my brain isnt working

#

how do i use the input actions asset without the playerinput asset

austere grotto
#

But why do you need 360hz physics anyway

harsh oriole
#

It's a golf physics simulation

#

with a fast swinging club

#

swinging a club from a rigidbody with 2 connected hinge joints, actually

harsh oriole
#

I.E does the value remain unchanged until the next frame?

#

because if so, that concept absolutely goes out the window and it should be trivial to understand why

#

my only thought is to try to sample/calculate the mouse's acceleration/deceleration and use that to predict/extrapolate the mouse inputs in between now and the next Input frame

#

the issue is that if your mouse is decelerating, the game continues to process the same input value instead of continuing along that same acceleration which causes extreme inaccuracies

charred wagon
#

int bindingIndex = playerInput.actions["Move"].GetBindingIndex(InputBinding.MaskByGroup("KeyboardMouse"));
why does bindingIndex doesn't return the index of the composite? It instead returns the first binding in that composite, which is annoying cos I want to check if the binding is a composite.
I want to get the name of all of the inputs in that composite, but it seems so complicated to do. I guess I can shortcut to just setting the index of all the binding manually and never change it but it doesn't feel right T_T.

#

I guess there's isPartOfComposite so I'll work around it. Seems convoluted...

#

It feels like it'd be easier to construct the whole PlayerInput from scratch than make it in editor and going backwards to get the name of the inputs.

austere grotto
#

Once you act on it*

harsh oriole
#

That's legit like day one stuff imo

#

How do you read data that's not there though?

austere grotto
#

But perhaps it'd be better to show your code

harsh oriole
#

I have stated countless times that my fixedupdate loop runs at a higher frequency than Update

#

lol

austere grotto
#

Yes and you don't seem to be understanding what I mean by consuming input

harsh oriole
#

I just wrote this for you

#

is this what you mean?

austere grotto
#

Yes basically.

harsh oriole
#

okay now that we've established that I'm not an idiot...

#

lol

#

Do you understand my problem?

#

FixedUpdate will run the next time and inputAccumulator obviously = 0

#

because another Update() hasn't been called

austere grotto
#

Why is this a problem?

#

All user input is being accounted for

harsh oriole
#

I need to have a framerate independent physics simulation

#

my physics simulation is tied to mouse data

austere grotto
#

You do

harsh oriole
#

no you're answering a question without enough context

#

how the mouse data is being used matters lol

austere grotto
#

Yes it does

#

But you haven't provided that context

harsh oriole
#

I.E in this case mouse data is being used to increase/decrease the velocity of a HingeJoint

#

and every physics tick that HingeJoint slows down by a small amount

#

i think my only choice is to try to extrapolate the mouse movement

austere grotto
#

You could limit how much of the mouse input you want to consume in a given physics update.

Instead of zeroing it out as in your example above

harsh oriole
#

I guess my main issues stems from the value going into an exponential equation and not a linear one

#

i think that's the best summary

#

if the equation was linear this isn't a problem

#

unfortunately missing a frame of mouse data and then adding the delta doesn't get you at the same result

austere grotto
#

Yeah I'm assuming a linear response to input here. If you estimate your current framerate and do a best effort attempt to spread the input consumption out evenly over the next N FixedUpdates (before the next input frame) maybe it'd be smooth?

#

Say you do the math and expect 5 physics updates before the next frame, you consume only 1/5th of the accumulated input per FixedUpdate until the next frame comes where you repeat that estimation and re-amortize

#

If that makes sense

harsh oriole
#

i like that idea tbh

#

because at a fixed framerate, it's 100% framerate independent i think

#

as long as the framerate is stable and fixed

austere grotto
#

Yes if your framerate is steady it should be

harsh oriole
#

that's all I need

austere grotto
#

Which isn't realistic lol but it should usually be ok

harsh oriole
#

i mean these days most game lock pretty steady

#

and it's definitely something I can be open about

#

most shooters deal with this I believe and favor a steady framerate

#

sorry not most, but something like Overwatch that runs at 120 tick physics

#

a 60fps player would have this issue

austere grotto
#

Well try it and let me know how it goes.

#

Honestly

#

If this doesn't work

#

Maybe look into the new input system

#

It has the option to poll input in FixedUpdate

#

Maybe that should even be plan A

harsh oriole
#

I was looking at that but unfortunately the actual values just get updated by frame still for mouse

#

i just tried your idea and liking it so far

#

seems to produce consistent results across any framerate so far

rapid girder
#

is there a way I can combine one functionality that return different values depending on button pressed?

#

or am I cursed to have one for each type of interaction

#

guess this will do

humble socket
austere grotto
humble socket
# austere grotto no those are completely unrelated

i see, my lecture was recommending me Invoke C shar event but i think thats just his preference , since Invoke unity event works just as well and then there is generating C# class which is more flexible.

what method do you think people at an industry or indie developers will use?

austere grotto
austere grotto
#

and if they did

#

I don't think they understoon what it means

#

because that is one of the least understood features of the input system - the Invoke C# events mode on PlayerInput

#

Almost nobody actually knows what it does

humble socket
#

and i agree with u 100%

austere grotto
humble socket
#

He went through it and he made it sound like he knows what hes doing but when u go home and try it out it doesn't work as he describes it.

austere grotto
#

( and 3 other events, for things like OnControlsChanged etc )

humble socket
#

yes i had a quick read through this doc

austere grotto
#

Let me guess he referenced the PlayerInput component and did something like playerInput.actions["AcitonMap/ActionName"].performed += _ => SomeFunction();

#

in the lecture

austere grotto
# humble socket

yep your lecture does not understand "Invoke C# events" mode 😉

austere grotto
# humble socket

to be clear, you can do this regardless of what mode the PlayerInput component is. What this actually is, is sidestepping the PlayerInput's normal functionality and listening to the actions yourself manually

humble socket
#

as a student who spend hours searching about input system. I aggree with u here, it felt wrong when he showed us the code, and I was right lectures are useless >.>

humble socket
#

thx to u am better off learning C# class for input system and Invoke Unity event

high girder
#

Hey everyone. I've got an issue that drives me crazy atm.
I have a UI with some buttons. When the player opens the UI for the first time, a tutorial notification appears. This notification can be closed by using the submit button on the controller.
When the notification is closed, it sets the button focus back to the last selected button and for some reason - the submit event for this button is triggered - even though the button was not selected when the player pressed the submit button to close the notification.

Is there any solution to this?

shrewd shuttle
#

Hi, I'm following a tutorial for a gamepad virtual mouse, and it's not pressing buttons correctly. I opened up the input debugger, and it looks like the left button is getting set to 1 and 0 properly, but numClicks isn't increasing, which makes me think that there's a difference between the left button going down and it "clicking" internally.

#

this is what I have:

private void UpdateMotion()
        {
            if (_virtualMouse == null || Gamepad.current == null)
            {
                Debug.Log("Either Mouse or Gamepad is null.");
                return;
            }

            Vector2 deltaValue = Gamepad.current.leftStick.ReadValue();
            deltaValue *= cursorSpeed * Time.deltaTime;

            Vector2 currentPosition = _virtualMouse.position.ReadValue();
            Vector2 newPosition = currentPosition + deltaValue;

            newPosition.x = Mathf.Clamp(newPosition.x, 0, Screen.width);
            newPosition.y = Mathf.Clamp(newPosition.y, 0, Screen.height);

            InputState.Change(_virtualMouse.position, newPosition);
            InputState.Change(_virtualMouse.delta, deltaValue);
            AnchorCursor(newPosition);
            bool pressed = Gamepad.current.aButton.isPressed;
            if (_previousMouseState != pressed)
            {
                Debug.Log("Button Pressed");  
                _virtualMouse.CopyState<MouseState>(out MouseState mouseState);
                mouseState.WithButton(MouseButton.Left, pressed);
                InputState.Change(_virtualMouse, mouseState);
                _previousMouseState = pressed;
            }
        }

        private void AnchorCursor(Vector2 position)
        {
            Vector2 anchoredPosition;
            RectTransformUtility.ScreenPointToLocalPointInRectangle
            (canvas.GetComponent<RectTransform>(), position, 
                canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : Camera.main,
                out anchoredPosition);
            cursorTransform.anchoredPosition = anchoredPosition;


        }
viral flicker
#

does anyone know how i can extract the position of the mouse in relation to the playr? im trying to make it so the player has different idle animation frames depending on the angle between the mouse and the player

dim sinew
viral flicker
dim sinew
#

That should be the function that I'm thinking of

viral flicker
#

thank

#

you

sharp geode
#

i'm trying to build a sample input system local multiplayer project. my goal is to use two distinct game views, one rendering each player's camera, with a different display specified in editor. this is a good model for my actual platform. in editor, i would like pointer clicks going through display 1 to be attributed to player 0, and pointers in display 2 going to player 1, etc. is there a built in way to do this?

#

my thought right now is to create a FakeMouse for each player, never associate the editor mouse with a player, and modify which fake mouse device sends the event based on which display the editor mouse device is interacting with

#

i suspect this already exists though, does it?

#

paging @austere grotto for some good input system science

austere grotto
#

I never used it

#

So I don't know the details

sharp geode
#

yeah i have seen that

#

it doesn't really deal with the local editor problem

sharp geode
#

how can i copy input event data, cast them, make a small change, and requeue? it's the copy and make a change part that is a bit mysterious

analog siren
#

So I have an input actions asset, and i want to retrieve the actions within it

#

how do i acquire them

shrewd shuttle
#

Hi, I'm getting these errors when disabling and removing a VirtualMouse. I'm using Input System 1.3. Anyone know where this is coming from/if there's anything to do?

austere grotto
austere grotto
shrewd shuttle
#

button east is disabling a canvas, and one of the elements on the canvas has an OnDisable() function that de-assigns and removes a virtual mouse

#

I can post that

#

but the error is from an input system script

#
private void OnDisable()
{
    _playerInput.user.UnpairDevice(_virtualMouse);
    InputSystem.RemoveDevice(_virtualMouse);
    InputSystem.onAfterUpdate -= UpdateMotion;
}
austere grotto
shrewd shuttle
#

lemme see if i can recreate it rq

austere grotto
shrewd shuttle
#

oh it looks like it's actually an action map issue

#

this is part 1

#

that action map absolutely exists this is an issue that's only started popping up with the gamepad cursor implementation

#

does it think it's an empty action map?

austere grotto
#

Is that some kind of enhanced stack trace something

#

I find it harder to read lol

shrewd shuttle
#

oh yeah this is console pro 3

#

i can find unity's default

#

is this better? or are you looking for something else

normal cliff
#

New input system - seems like they want a InputSystemUIInputModule enabled for UI stuff, but then that completely overrides my active ActionMap and I only get the events from the input module. Is that expected? Is it documented?

normal cliff
#

Looks like the answer was... disable the InputSystemUIInputModule then re-enable it again, and now I get both events. 😐

prisma pine
#

Hello. I have a question I would like to move the player (3D) by 1 on a grid using the input system with WASD and arrows. Tips?

fallow haven
#

So I have my input system all set up and working great. What I'd like to do now is simply detect where the last input came from (determine if it was Mouse and Keyboard OR Gamepad). What is the best way to do this?

normal cliff
prisma pine
normal cliff
#

Do you want it to move instantly, or over time?

prisma pine
#

move instantly

normal cliff
#

Okay, so the main thing is to translate the input movement vector into a world space movement vector. That probably just means multiplying it by the tile size. Then just add that to the transform position - no speed, no delta time.

fallow haven
normal cliff
#

Why not just store playerInput.currentControlScheme?

fallow haven
normal cliff
#

Why do you want it in the inspector, if you're setting the value at runtime? Just for visibility?

fallow haven
#

My targeting system has inputs for press, hold, release and I need that system to know if the input came from Mouse and Keyboard or Gamepad

#

the system needs to function slightly differently

#

but yes for debugging and play testing it is nice to be able to see when the scheme has been changed too

normal cliff
#

I would probably just try and use separate inputs for each one, rather than trying to inspect the scheme separately

fallow haven
#

Yeah I was just kinda realizing that might be a smarter way 😅

charred wagon
#

So I'm trying to get the display name of one of my inputs, but it somehow changes between "View" (expected one) and "Select" (the gamepad one, even tho I've set all my input in PS4 and Xbox and none in gamepad). I'm typing this :
Debug.Log(playerInput.actions["OpenSettingsMenu"].GetBindingDisplayString(InputBinding.MaskByGroup("Xbox")));
I think it happens when I use the controller, still I have not idea why it happens, playerInput being the only thing that could change between the debugs and I have only one of those.

#

Yup, only happens when I'm using the controller, if I switch back to keyboard it goes back to "View" again

stiff oar
#

when i select another window then unity again while the game is running i get null exception errors every frame

austere grotto
stiff oar
#

I cant find anything online if thats what you mean (i stupid)

austere grotto
#

You can't find anything online? It's the most common error in existence

#

-figure out what's null

  • figure out why
  • fix it
autumn ridge
#

I started a new indie horror game project with my friend and I'm getting this problem;

I am using an FPS Controller and Unity's character controller asset.

Please let me know if there's a way to code camera movement for playstation 5 input 🙂
(sorry for bad video quality)

dusty timber
#

Hello!

I am making a mock up of something in Unity for VR, ive followed a beginners setup of an XR system for it and ive gotten to a point where i have hands and (i think) the input system set up... the only problem is i have zero idea how to use it.

There are the L and R hand controllers that have the prefab for the hand models, this prefab contains the model and a particle system along with a controller script called "RegenController". All i need to make, is something that when on either hand, if you pull the main trigger it starts the particle system on the relevant hand, and if BOTH trigger and grip is pulled it runs a different particle system on the same hand.

I can make the activation stuff, i just need to know, basically, how do i use the inputs from the XR stuff on the "RegenController" script

#

Thanks!

dusty timber
#

tldr ; basically i just need to know how VR input works for things like the trigger or grip

pliant copper
#

I'm trying to assign 1 single input action in a script and then check for the input in Update, but for some reason, whenever I press the key I assigned, it doesn't trigger. Here is an example of my code:

public InputAction action;
 
void Update()
{
     if(action.triggered) Debug.Log("Input pressed");
}

It doesn't print the Debug.Log in the console even when I press the button that I assigned in the inspector. Is there something I'm missing?

night bear
#

Hello! This might have already been talked about, but I can't seem to really understand it. I'm trying to have a character rotate depending on gamepad input (vector2). I got the values of this Vector2 and understand what they mean, but I can't seem to have my character rotate using those values. I tried

Vector2 move

public HandleMovement()
{
  transform.rotation = Quaternion.Euler(move.x, 0 , move.z);
}

But this only seem to add the 1 and -1 to the rotation of the object which goes up to 180.

#

I hope this is understandable

austere grotto
austere grotto
ivory thicket
#

Hi guys! I have a fully working character with my controller so that's nice. Though, I have 2 different playable characters, and I want to have local multiplayer. Right now, if I have both character prefabs on my screen with different scripts attached (they have different controls but some are the same, like moving with the left pad), they will move together, jump together, etc, from one controller. Like, it isn't split into two controllers. I'm not sure what to do

#

pls help 😭

mint adder
#

Hi!
Does anyone know a good topic about the "Update mode" especially which one to use in different contexts?
For example the dynamic is the default, but some in some cases the fixed one is better?

rocky scroll
#

when do I need the EventSystem object?

#

I saw that I need it when I'm making buttons that switch scenes

#

I don't really understand what it says on the documentation

viral flicker
#

i want it so if shift is pressed, the player speed changes, but how do i get it to change back after i let go of shift?

#

is there like a method for when the button is no longer pressed?

pliant copper
austere grotto
# rocky scroll when do I need the EventSystem object?

Event system is needed if you want to use anything that involves the event system which includes:

  • any interactive UI elements
  • any scripts using the Event trigger component
  • any scripts using event system listener interfaces for example IPointerEnterHandler, IDragHandler, etc
austere grotto
fleet dock
#

Quick question, given an InputAction.CallbackContext, is there any way you can make a device leave and allow them to join back on button press again? I'm making a multiplayer game where players can hop in and out with gamepads with buttons and not by disconnecting the controller, and I've tried InputSystem.DisableDevice( context.control.device ) and InputSystem.RemoveDevice( context.control.device ) and neither seem to let me join back with that device again.

viral flicker
#

and movement method interprets the moveinput like this

night bear
#

Hello! Sorry for not following up with my message yesterday. I have followed Brackeys Tutorial on a third person controller, but I'm trying to have camera stay on the same position. So the only thing I want is the player forward to be the same as the camera. I also tried to implement moving with a joystick, with the new input system as a pass through vector2. The issue is, I might have missed some things and tweaked the wrong ones, because the character keeps drifing without any input, like it has a constant force being applied to it. Could someone help me review the code?
https://paste.ofcode.org/c5t7cxwmjDRrNnhaNmRaCR

light silo
#

Is there a way to get text-input with the new input system? I imagine marking all keys as actions corresponding to the key and then filtering that into text is a very good idea if there's an in-built system.

viral flicker
#

why doesnt this work?

#

im using send messages for sprint

timber robin
#

Do you have a Sprint action in your input actions?

viral flicker
#

@timber robin

#

i feel like this might be important too

#

also this happened

austere grotto
austere grotto
#

If it's 0 it was released

viral flicker
#

it feels very like

#

band-aid idk

austere grotto
#

That's the way to do it with Send Messages

viral flicker
#

ah okay

#

i could do if else but i heard return is good

#

how can i change animation speed

sharp geode
#

is there a way to get the display index of a mouse input event (MouseState)? my goal is to use a single editor mouse to simulate two distinct devices, depending on which display is interacted with in the editor

#

or maybe is there a way to get the unprocessed position of the mouse pointer (yes) and determine which display editor window it is currently over?

#

i see this:

    public struct MouseState : IInputStateTypeInfo
    {
 ...
        // Not currently used, but still needed in this struct for padding,
        // as il2cpp does not implement FieldOffset.
        [FieldOffset(26)]
        ushort displayIndex;

my attempts to read it with

            var displayIndexStateBlock = new InputStateBlock
            {
                byteOffset = 26,
                sizeInBits = 16,
                bitOffset = 0,
                format = editorMouse.clickCount.stateBlock.format
            };
            var displayIndexControl = new IntegerControl();
            displayIndexControl.Setup()
                .At(editorMouse,0)
                .WithStateBlock(displayIndexStateBlock)
                .Finish();
...
                    var displayIndex = displayIndexControl.ReadValueFromEvent(stateEvent);

are not succeeding

#

i get nonsense

sharp geode
#

well it looks like displayIndex is correctly set in the state, it is hard to read but it is there

sharp geode
#

okay better question: how do i get the MouseState struct from a InputEventPtr for a Mouse??

#

this is shockingly hard

silver laurel
#

Hey guys, I’m working on a 2D platformer and I want a good viable movement system using the new input system.
Does anyone have any tutorials or anything?

dim sinew
#

So I'm having an issue with UI not receiving input events after a game object with the PlayerInput component has been destroyed.

At first I thought it was because the Multiplayer Event System was destroyed, but then I have them in a persistent scene to see if that fixes the issue, but I get the same result.

This issue happens even when switching scenes. And I don't understand what is going on. The PlayerInputManager component doesn't have a destroy player function so I have to do it manually.

I tried getting it to work with a normal Event System and 2 Multiplayer Event System objects just to see if that works and then I tried with just 2 Multiplayer Event System objects, but still nothing works.

austere grotto
dim sinew
#

That makes sense but if that is the case why does it allow me to process UI events before the PlayerInput component has been added?

#

If anything I'm probably going to have to add a PlayerInput at the startup of the game and then if I need to add Player 2 just add and remove the second input ass needed.

austere grotto
#

If you use the normal Event System - it interacts with the input system via the Input Module component

dim sinew
#

and that is it

#

What I thought would happen is if I set the Player Root field to null the Multiplayer Event System would be ignored and the normal Event System would take over input processing, but apparently that isn't the case.

sharp geode
# dim sinew So I'm having an issue with UI not receiving input events after a game object wi...

having just done this

#

you should have an event system & input system ui input module for every user

sharp geode
dim sinew
#

Not needing the Player Input Manager is kind of weird, but if it will work without it then I guess that is fine.

sharp geode
#

then associate the devices

#

it really depends what game it is

dim sinew
sharp geode
#

the player root field is only used for the MoveEvent

#

that root field will only allow the user to Select via directional navigation the UI elements under that root field.

dim sinew
#

So when I enter the character select each player should be able to select their character and hit the ready button. And the Ui should update when a player has changed the character.

sharp geode
#

directional navigation makes sense if it's 4x controllers for example

#

it's liek a super smash game?

dim sinew
#

This works for me but when I leave the screen everything breaks.

sharp geode
#

what do you mean?

#

it's not an input system issue

#

it's a scenes issue

#

you probably do not want to use scenes

dim sinew
#

Well no I have my character select screen on a separate canvas. that isn't the issue.

#

The issue only happens when I remove Player Input objects then no UI events are processed

sharp geode
#

what kind of game is it?

dim sinew
dim sinew
sharp geode
#

well destroying or disabling a PlayerInput disconnects / destroys / disables the user

dim sinew
#

Also I remove players because there is no reason to have multiple players for a single player mode (At least that is what I would think 😅 )

sharp geode
#

huh?

#

when you say single player mode...

#

you're making a multiplayer game

#

it's tetris attack. it's 4 people sharing a screen with controllers right?

#

and each player has his own little column of tetronimos

#

sure

dim sinew
#

Yeah but if a player is playing against bots no need for CPU to have a Player Input Object right?

sharp geode
#

every real living breathing human needs a corresponding PlayerInput if you want to use the local multiplayer components from Input System

#

so the right answer is not 0

dim sinew
#

That actually makes sense

#

What is odd is in my other games (which are single player) I delete/disable the Player Input on Screen which have no gameplay and everything works fine. But in those cases I'm not using Multiplayer Event System

sharp geode
#

i think what is extremely confusing in the unity editor is that it joins the editor mouse and keyboard to User 0 (i.e. the first player input in the hierarch)

#

and schemes are an extremely janky way to test multiple users

#

they expect you to use controllers for local multiplayer games

dim sinew
#

Which kind of doesn't work if you are also targeting PC. Someone will need/want to use keyboard/mouse

sharp geode
#

well the player inputs have a lot going on

#

including stuff like schemes

dim sinew
#

So basically to solve my issue just don't delete/disable Player Input objects and I should be fine because the rest of the system works as intended.

sharp geode
#

yes

dim sinew
sharp geode
#

the multiplayer event system also does very little

#

it doens't do what it sounds like it should do

dim sinew
#

Thing is I could probably make my own PlayerInput using the API but using what is there is just far more convenient

dim sinew
coral tree
#

Hi everyone! in openXR project I develop interacting with the UI InputField I use locks my other inputs (character movements etc) why that might be?

#
  • In build, Input field locks/freezes my character and doesnt read on-screen keyboard inputs
  • In editor, everything works perfectly, I can move while I write, also I can write
quaint quartz
#

Hey Everyone, Im having a weird glitch with the input of my character. when using a joy stick and is spin the stick at Max dead zone it stutters, moving the stick (xbox controller) quickly not at max deadzone the movement is smooth

#
Vector3 move = new Vector3(moveInput.x, 0, moveInput.y);
        if (move != Vector3.zero)
        {
            gameObject.transform.forward = move;
        }
        controller.Move(move * Time.deltaTime * playerSpeed);
#

here is a snip of my movement code on update, since i cant post pictures here

#

and yes the input system is already set to dynamic update

burnt knoll
#

Hey all, any thoughts on why my test fails? If I run them all together MouseRightClickUpdatesNavigation fails because the mouse event seems to not fire. But when I run the test on its own it passes

Here are the tests in question

    [UnityTest]
    public IEnumerator MouseLeftClickSelectsUnit()
    {
        var clickDestination = Object.FindObjectOfType<Unit>().transform.position + new Vector3(0, 0.1f, 0);
        var clickDestinationScreenPosition = _camera.WorldToScreenPoint(clickDestination);
        var mouse = InputSystem.AddDevice<Mouse>();
        Set(mouse.position, clickDestinationScreenPosition);
        Click(mouse.leftButton);

        yield return null;

        var selection = Object.FindObjectOfType<PlayerSelection>();
        Assert.AreEqual(selection.units.Count, 1);
    }

    [UnityTest]
    public IEnumerator MouseRightClickUpdatesNavigation()
    {
        var clickDestination = new Vector3(2, 0, 0);
        var clickDestinationScreenPosition = _camera.WorldToScreenPoint(clickDestination);
        var mouse = InputSystem.AddDevice<Mouse>();
        Set(mouse.position, clickDestinationScreenPosition);
        Click(mouse.rightButton);

        yield return null;

        // NOTE(jesse): NavMeshAgent floats above the ground by design, so can't test y
        // https://answers.unity.com/questions/1519276/navmesh-is-floating-above-ground.html
        var unit = Object.FindObjectOfType<Unit>();
        var navMeshAgent = unit.GetComponent<NavMeshAgent>();
        Assert.AreApproximatelyEqual(clickDestination.x, navMeshAgent.destination.x);
        Assert.AreApproximatelyEqual(clickDestination.z, navMeshAgent.destination.z);
    }
fallen wasp
#

How can I detect mouse up? I have this:

#

With gamepad it works

#

My script looks like this:

#

It fires twice when I click it and once when I release it

#

I have no idea what these things do:

#

But by looking at the documentation maybe that's how?

#

Or maybe somewhere in here?

normal cliff
#

I only get 2 events though, not 3 like you, so perhaps you have something else going on as well. Maybe grab the action object which is inside the callback context and print that out, look at its fields, etc

#

It's kind of impossible to use a debugger for this because then you're changing the input state while it's in the debugger, so this really needs to be documented clearly and properly.

fallen wasp
#

I get 2 on mouse down for some reason

normal cliff
#

Yes, I mean one on down, one on up.

fallen wasp
normal cliff
#

Ah, that's something at least.

#

Do you have a InputSystemUIInputModule in the scene? I was finding that it could emit extra events from there, so I'd get one click from "UI/Click" and another from "Player/Select". I can't remember how I fixed that - there was a point where the InputModule was blocking all my Player inputs entirely until I disabled and re-enabled the module and then magically it started working 😐

fallen wasp
#

Maybe I have more than one. I can't remember how to search the scene for components. Do you know?

normal cliff
#

t:ComponentTypeName in the search bar at the top of the Hierarchy

fallen wasp
#

Nope, just the one

#

I did come up with a work-around, but I will have to fix it at some point

#

Thanks for your help anyway

flat blaze
#

How can i convert this to the new input system?

        private void MyInput()
        {
            // If auto weapon, allow holding, else, you must click to fire
            if(allowButtonHold) shooting = Input.GetButton("Fire1");
            else shooting = Input.GetButtonDown("Fire1");
    
            // Reload Input
            if(Input.GetKeyDown(KeyCode.R) && bulletsLeft < ammoCount && !reloading) Reload();
    
            //Shoot
            if (readyToShoot && shooting && !reloading && bulletsLeft > 0)
            {
                Debug.Log("Shoot");
                bulletsShot = bulletsPerShot;
            }
        }```
austere grotto
steady cypress
#

hello!

i've made a keyboard in VR that works with physics interactions. im now looking to set up each key press triggering the actual GetKeyDown so that it plugs and plays with whatever unity UI system the user wants to plug it into but everything i see has a lot of people saying "you cannot/should not simulate key presses because you can just call the function otherwise" but without simulating from the VR key presses, the keyboard will take some time to integrate into each different UI system

narrow bane
#

Using the "Send Messages" Behaviour is there a way to assign an event to the "canceled" event listener?

#

I have InputAction rotateAction = _PlayerInput.actions["Rotate"];

#

Later on I have

float rotateDirection = rotateAction.ReadValue<float>();
        if (rotateDirection != 0)
        {
            _CinemachineFramingTransposer.m_XDamping = 0;
            _CinemachineFramingTransposer.m_YDamping = 0;
            _CinemachineFramingTransposer.m_ZDamping = 0;
            _CinemachineFramingTransposer.m_DeadZoneWidth = 0;
            _CinemachineFramingTransposer.m_DeadZoneHeight = 0;
            _CinemachineFramingTransposer.m_SoftZoneWidth = 0;
            _CinemachineFramingTransposer.m_SoftZoneHeight = 0;
            _GameObjectMap.transform.Rotate(0, rotateDirection * rotateSpeed, 0, Space.Self);
        }
        else
        {
            _CinemachineFramingTransposer.m_XDamping = 1;
            _CinemachineFramingTransposer.m_YDamping = 1;
            _CinemachineFramingTransposer.m_ZDamping = 1;
            _CinemachineFramingTransposer.m_DeadZoneWidth = 0.65f;
            _CinemachineFramingTransposer.m_DeadZoneHeight = 0.65f;
            _CinemachineFramingTransposer.m_SoftZoneWidth = 0.8f;
            _CinemachineFramingTransposer.m_SoftZoneHeight = 0.8f;
        }
#

This is inside the Update function. This means that on every frame that else statement is running setting those values which I don't want taking up the extra resources.

#

I just want to set those values once when the action is canceled.

#

so something like rotateAction.canceled = ctx => functioncallhere? but that doesn't seem to work.

#

nevermind figured it out. for anyone else wondering:
rotateAction.canceled += ctx => Test(ctx);

...

void Test(InputAction.CallbackContext ctx)
    {
        Debug.Log("test");
    }
rapid lake
#

Hello everyone, I'm having a problem when pressing a joystick's trigger, it clicks on the last UI element I clicked. Is there a way to disable this? Thanks in advanced.

peak delta
#

how to make action
to works like old GetKeyDown()??

viral flicker
#

how do i make it so the new input system has things held down?

#

it only does things once right now

austere grotto
austere grotto
peak delta
#

for example?
i don't want to use

Mouse.current.leftButton.wasPressedThisFrame

cause it uses just one button

#

i want to get whole action

#

only for one frame
via InvokeUnityEvents

#

i have on big MonoBehaviour script which it gets input from InputSystem
and it saving it like in bool's or vector2 etc

#

and from this monobehaviour im taking input to others

peak delta
jagged wyvern
#

Dont save bools

#

Just execute code that relies on those bools

dusk tundra
#

Hi there, I'm a 3D artist, and I've been using unity for a good few years and have a fairly good understanding of C#
I'm wondering if anyone has been able to make input based events possible even when not focused on the window of a build? Im trying to make a simple little softwares that plays animations on an avatar based on the inputs ive set in the code

tame oracle
#

If text is entered into an inputfield, the text doesnt change to the second line if the first line is full of characters.
I also increased the size of the inputfield, but it stays the same

viral flicker
#

right now im using the send messages mode

narrow jacinth
#

Does Unity button have drag and drop or swipe? I have a game that left clicks and right clicks a certain button, but since I'm exporting it on Android, I want to replace the right click with a swipe. Is there a way for this?

pliant verge
#

What would be the best way to map input keys to a sprite?
I have images for all keyboard and gamepad inputs and would like to render them in e.g. a settings UI based on the active action

subtle maple
#

I installed Input system, and it does not show. Does anyone know what to do?

#

also, my compiler does not recognise it

burnt knoll
#

The InputSystem does not seem to work in [UnityTest]s.

    [UnityTest]
    public IEnumerator C_SelectAndMoveUnit()
    {
        var mouse = InputSystem.AddDevice<Mouse>();
        ...
    }

None of the events created by mouse are picked up, and the PlayerInput.devices count is 0

earnest sparrow
#

Digital normalizer and digital are the same thing?

glass forge
#

Anyone experience weird jittering with the new input system? I'm using a basic mouse look script here:

private void CameraControls()
    {
        lookInput = look.ReadValue<Vector2>();
        float mouseX = lookInput.x * cameraSensitivity * Time.deltaTime;
        float mouseY = lookInput.y * cameraSensitivity * Time.deltaTime;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);
        mainCam.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        transform.Rotate(Vector3.up * mouseX);
    }

But every so often, the camera would snap to a random position and jitter for a frame

glass forge
#

Also the Update mode is already Dynamic

austere grotto
timber ocean
#

Hi, can someone help me? I made player controller system in my game and made it so u can control it with PS4 Joystick. Movement works on x axes but wont work on y axes. This is script and Input manager settings.

young yew
#

Hey devs
I am having this weird behavior in InputSystem
Feels like Gamepad.current get cached when you connect your controller and when you disconnect it and try to run the game again, the current would still say as if it is connected to the device

What I did is create InputActions, add the maps and in code I would create an instance for these actions.

Is this issue common or did I do something wrong?

You can check the code here if needed:
https://hatebin.com/hgeytmfzvo

torpid raft
#

Can anyone help whenever I spawn my player using the new input system and using Don't Destroy On Load it dosen't spawn.

#

It also bugs my wave spawner because on spawn of the player it adds itself to the wave's targets and then it is just null in the list.

austere grotto
#

Sounds like your object is destroying itself

#

Also this is all completely unrelated to the input system

torpid raft
#

Gosh

humble socket
#

I been doing my research and it seems like the only way to access the Actions from an Action map without using string is to Generate C# class for that input system.
It does not matter if am using Invoke C sharp event or Invoke unity event.
Am I right?

austere grotto
humble socket
#

@austere grotto is it ok for u to show me an example of it being used to access the action

urban lintel
#

how can i use touch input in a similar way that i do mouse input?

#

got this

#

and using Mouse.current.position.ReadValue()

#

theres Touchscreen.current.position.ReadValue() but for some reason my raycasting and stuff is off for that

#

it sort of works when its in the bottom half

#

all the coordinates seem the same as with mouse so i dont know where the problem is

#

ohh nevermind

#

i forgot to change mouse to touchscreen in a different part of my code

#

oh but with touch input the if (ctx.cancelled) doesnt run

urban lintel
#

oh and IsPointerOverGameObject() doesnt work lol

#

the joy of mobile support

copper aurora
#

Hey, is there something like

Keyboard.current.anyKey.wasPressedThisFrame``` but for Gamepad and Mouse? 
I want to do a start screen, with "press any key to start" and I want it to be __any__ key. Mouse, gamepad, keyboard, whatever
jagged wyvern
#

InputSystem.onActionChange

random phoenix
#

Anyone know if the new input system allows for multi button inputs (like shift-click)?

#

It'll be easy to code manually if not, just figured I should check first

tepid fern
#

I can't seem to find much on joystick gestures. I could swear there was an asset on the Store that made such gestures easy to register, but I can't find it. This is the only link I can find info on it as well, and it's sparse.

https://forum.unity.com/threads/joystick-gestures.115315/

Does anyone know if such an asset still exists? Or, of writing more fleshed out on how I can achieve joystick gestures.

latent basin
#

Hey, bit of an urgent issue here. It seems I can't use eventSystem.SetSelectedGameObject, as EventSystem leaves the last object selected in my menu system selected still.

This menu system is 4 parent objects that get enabled or disabled in the hierarchy and contain UI buttons. An important part of functionality is having controller usability, however, it seems like I can't get it to "select" a button when switching menu tabs.

#

How do I set what button the EventSystem considers "selected"?

autumn hornet
#

anyone here able to help me with a phone and pc setup for new input system

limber swan
#

how do i get a vector from swiping on touchscreen?

austere grotto
wary storm
#

Hello I have some tile based movement using the MoveTowards function is there an easy way to change this from the arrow keys to a UI Joystick input?

Here is my current code incase that help

public IEnumerator Move(Vector2 moveVec, Action OnMoveOver = null)
    {
        animator.MoveX = Mathf.Clamp(moveVec.x, -1f, 1f);
        animator.MoveY = Mathf.Clamp(moveVec.y, -1f, 1f);

        var targetPos = transform.position;
        targetPos.x += moveVec.x;
        targetPos.y += moveVec.y;

        if (!IsPathClear(targetPos))
            yield break;

        IsMoving = true;

        while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
        {
            transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
            yield return null;
        }
        transform.position = targetPos;

        IsMoving = false;

        OnMoveOver?.Invoke();
    }
austere grotto
wary storm
tame oracle
#

i'm trying to just make the camera draggable with mouse input, but just a simple while (controls.Player.LeftClick.IsPressed()) in my Update() freezes unity

tame oracle
#

setting a bool while IsPressed and running a function when it's true has the same result

austere grotto
austere grotto
#

Sounds like you want if not while

wary storm
austere grotto
#

It is not code for reading input

wary storm
austere grotto
#

Presumably in the code that calls this function

wary storm
austere grotto
#

Or wherever moveVec gets set

wary storm
austere grotto
wary storm
austere grotto
#

and see what vector is being passed in as an argument

#

moveVec is a parameter so it's just a local variable in that function

wary storm
austere grotto
#

go to the call site

#

you said it's in Update

wary storm
# austere grotto you said it's in Update

Ahhhh I got you now thankyou for your patience

    public void HandleUpdate()
    {
        if (!character.IsMoving)
        {
            input.x = Input.GetAxisRaw("Horizontal");
            input.y = Input.GetAxisRaw("Vertical");

            // remove diagonal movement
            if (input.x != 0) input.y = 0;

            if (input != Vector2.zero)
            {
                StartCoroutine(character.Move(input, OnMoveOver));
            }
        }

        character.HandleUpdate();

        if (Input.GetKeyDown(KeyCode.Z))
            Interact();
    }

here?

austere grotto
#

yes this is where your input processing is happening

#

and unless you've changed some settings, this will handle both joysticks and keyboard automatically

austere grotto
#

If you want to use UI joysticks it's not really supported out of the box in the old input system

#

the new system has support for them

#

you'd have to program it all yourself in the old system

wary storm
#

Im not really sure what that entails

austere grotto
#

It is a big learning curve to use the new system though

#

especially if you're not a good programmer

wary storm
austere grotto
#

Learning the new system is probably easier simply because there's a lot of tutorials for it. You could even look up tutorials for "on screen sticks" which is a UI joystick.

#

implementing your own on screen joysticks is harder and there won't be as many tutorials/resources on it

tame oracle
# austere grotto Sounds like you want `if` not `while`
{
    controls.Player.LeftClick.started += ctx => MouseMove(true);
    controls.Player.LeftClick.performed += ctx => MouseMove(false);
}

public void MouseMove(bool performed)
{
    Debug.Log(performed);
    dragging = performed;
    difference = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue()) - cam.transform.position;
}


void Update()
{
    pointerOverUI = EventSystem.current.IsPointerOverGameObject();
    
    if (dragging == true)
    {
        cam.transform.position = cameraOrigin - difference;
    }
}```
this was my attempt at it but the debug.log shows true for a super short time then false again
do you get what i'm going for? how would you set this up?
wary storm
tame oracle
#

ooh i didn't think about that bet i'll give that a shot ty

tame oracle
austere grotto
#

You can use it for any object with a Collider

tame oracle
#

i don't have an object with a collider i think? like i'm clicking nothing because i'm trying to move the camera

#

and it doesn't seem to work when i click a collider either

austere grotto
#

you need:

  • a collider on the object
  • a physics raycaster on your camera (or physics2draycaster if using 2d collider)
  • an event system in the scene
tame oracle
#

i did not have a physics raycaster, added that, still doesn't work

austere grotto
#

and also a script which implements the interface

tame oracle
#

i do, already had the others

    {
        Debug.Log("OnDrag");
        cam.transform.position += new Vector3(eventData.delta.x, eventData.delta.y, 0);
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        Debug.Log("OnPointerDown");
        dragOrigin = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);
    }```
OnBeginDrag and OnEndDrag are implemented
austere grotto
tame oracle
#

Player : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IBeginDragHandler, IEndDragHandler, IDragHandler

austere grotto
#

and show your raycaster and your event system

tame oracle
austere grotto
# tame oracle

what other components are on the player? I don't see a collider in that screenshot

tame oracle
#

oh on the object that calls the drag stuff? i thought you meant an object to click on?

#

objects in the world with colliders

austere grotto
#

the script which has the IDragHandler needs to have a collider

tame oracle
#

gotcha

#

try that

#

box collider 2d?

#

didn't change anything

austere grotto
tame oracle
#

doesn't seem to be calling any debug.logs

austere grotto
#

are there any other objects / ui elements in the way?

tame oracle
#

grey is nothing just camera background, tiles are gameworld objects with colliders on them

#

clicking background or objects doesn't do anything

austere grotto
tame oracle
#

no do they need to?

austere grotto
#

Whatever object you're clicking on needs to have:

  • collider2D
  • script with IPointerClickHandler or whatever event interface you want (e.g. drag)
tame oracle
#

oh i misunderstood how it worked, i thought it was like a playerinputs thing you have one of rather than something that needs to be on the object itself

austere grotto
#

things you have one of are:

  • event system
  • raycaster
tame oracle
#

wouldn't that be a bit cumbersome for moving the camera? i'd need that on the background and every clickable thing in the world

austere grotto
#

and have your raycaster (graphic or physics, depending on whether the background is UI or game world object) ignore other layers

tame oracle
#

oh gotcha i'll try that out

austere grotto
tame oracle
#

gotcha np

austere grotto
#

which I guess you did say moving the camera before - kinda thought you meant like clicking on the camera and dragging it - which doesn't make sense now that I think about it

tame oracle
#

lmao

#

would you still recommend the draghandler or the input system then?

austere grotto
#

drag handler is kinda orthogonal to the input system tbh

#

it works with either input system

tame oracle
austere grotto
#

The in drag stuff is honestly probably kinda weird for what you're doing

tame oracle
#

yeah

austere grotto
#

Made more sense when I thought you were dragging an object around

tame oracle
#

yeye

#

i tried that and it drags the camera for one frame then stops, despite debug.log printing true to the condition

#
private void Start()
{
    controls.Player.LeftClick.started += ctx => MouseMove(true);
    controls.Player.LeftClick.canceled += ctx => MouseMove(false);
}

public void MouseMove(bool performed)
{
    dragging = performed;
    difference = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue()) - cam.transform.position;
}

void Update()
{
    Debug.Log(dragging);
    if (dragging == true)
    {
        cam.transform.position = cameraOrigin - difference;
    }
}
austere grotto
#

That's just for detecting the click and release

#

You need to check mouse delta in Update here

tame oracle
#

oh bet works now ty a bunch :)

{
    if (dragging == true)
    {
        difference = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue()) - cam.transform.position;
        cam.transform.position = cameraOrigin - difference;
    }
}


public void MouseMove(bool performed)
{
    mouseOrigin = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue());
    dragging = performed;
}

#

would controls.Player.LeftClick.ReadValue<bool>() work instead of the setting of the bool function btw?

#

and where do i put my * Time.deltaTime and * speed

#

aand final question, how do i make it not modify the z value? since it's 2d it's making it 0 which makes nothing visible

austere grotto
austere grotto
#

make your own vector

#

or set that vector's z to whatever you want

#

or provide a nonzero z in the parameter to ScreenToWorldPoint

tame oracle
tame oracle
#

that also involves just making a new vector3
would this work cam.transform.position = new Vector3(cameraOrigin.x - difference.x, cameraOrigin.y - difference.y, -10);

austere grotto
#

-10 will not work, no

#

that will put it behind the camera

gleaming idol
#

yeah

tame oracle
#

i'm moving the camera itself

gleaming idol
#

instead of -10 put cam.transform.position.z

tame oracle
#

behind everything else

#

it's already -10

austere grotto
#

I think it's probably better just to set the z afterwards to what you want

tame oracle
#

what i want is -10 lol that way i can actually see stuff

austere grotto
#
float camZ;

void Start() {
  camZ = transform.position.z;
}

void LateUpdate() {
  Vector3 desiredPos = whatever; (all those calculations)
  desiredPos.z = camZ;
  transform.position = desiredPos;
}```
#

^ Simplest best way in my opinion, and not subject to floating point arithmetic imprecision etc

tame oracle
#

gotcha
speaking of all those calculations i think i fucked it up because it does move the camera but at the start moves the camera to where you click, so it doesn't really end up moving at all

austere grotto
#

though in my case I'm doing click and drag in a 3D isometric view

#

and my plane is a horizontal (XY) plane

tame oracle
#

my brain is not braining rn

#
Vector3 desiredPos = new Vector3(difference.x - mouseOrigin.x, difference.y - mouseOrigin.y, -10);
desiredPos.z = cam.transform.position.z;
cam.transform.position = desiredPos;

this? idk

#

that kind of works except it's reversed and when i click on one spot it moves the camera for no reason

#

nvm fixed it, had to swap position of origin and difference

shut phoenix
#

OnMouseOver and OnMouseExit is fully working and has been in the editor when playing for ages, but when building the game it doesnt work - anyone know why?

the heirarchy is like this:

Top (Script + RigidBody)
|-> Middle (Empty)
  |-> BottomA (Collider)
  |-> BottomB (Collider)
#

there is of course always a chance its a bug elsewhere in the code but just difficult to track down editor / build differences

strong raptor
#

Hi, I'm having a problem with the new system where my controllers are combining all my inputs. Auto switch is off and I have no idea where to start with fixing it.

dense ridge
#
            {
                Debug.Log("Shoot");
            }```
#

Why does this not work

sharp geode
#

without using PlayerInput, how would a script know which user an action is associated with in a local multiplayer game?

how can i see which user is associated with an event in a callback context?

what is the best way to create a script of the form

[SerializeField] public InputActionReference action;

OR using the generated input actions map classes and correctly only respond to "this user's" input?

sharp geode
shut phoenix
#

even for physical objects?

#

with 3d colliders

sharp geode
#

you can use event system with 3d objects

#

use a physics raycaster

dapper bloom
#

Hi im trying to make my Charakter Run only while Shift is pressed down but I cant find anything online on how to do it this is the code I used for running

tame oracle
# dapper bloom

With your current setup you could probably just do:
onFoot.Sprint.started += _ => motor.Sprint();
onFoot.Sprint.cancelled += _ => motor.Sprint();

.started callback will call Sprint() the frame the action is pressed.
.cancelled will call Sprint() again when the action is released.

dapper bloom
tame oracle
#

Replace the onFoot.Sprint.performed line with those 2 instead.

#

There are better ways to do this.. but based on what you have that should be a quick fix?

#

Basically just duplicate the .performed line.
And just replace the .performed with .started and .cancelled

dapper bloom
#

no definition for cancelled

tame oracle
#

Oh .canceled

#

Spelling OP

dapper bloom
#

=> still has errors

#

Identifier expected

tame oracle
#

Just leave the ctx. You could technically replace ctx with _ since you aren't using it but either is fine

#

+= ctx