#🖱️┃input-system
1 messages · Page 46 of 1
I had to click a button in the Event System object
because computers aren't capable of doing that without human input
apparently
Hi guys, I hope this is the right channel, I use Input Actions
I follow tutorial, until step where I press control w,a,s,d is debug shown in play mode but the character is not moving yet is work very well, similar with the tutorial, and the next step I add character controller component and following tutorial that change the code, after I finish following the tutorial I can't go to play mode because some component is error
"come component is error" wdym?
I think this
what other errors do you have
It's all I have
looks like you are missing semicolons and brackets. Make sure your IDE is properly set up so it will show you those kinds of errors while writing the code. Check #854851968446365696 for the guide to set up the IDE
you have to fix those errors on AnimationAndMovementController
woa! it's works, first I need to set up the IDE, and I open the script again there is new tool that can check my error on script and last I can fix AnimationAndMovementController, thank you @deft berry@austere grotto
replacing standalone input module to the new input system event system, now I cant click buttons in my menus
select your eventsystem in your scene and click the button in the inspector to upgrade it to the new input system]
thank you , the solution was to simply click that button you are right
Dang it , but doing that the old event system to click with mouse doesnt work...
even though the two are active
ok it works when I disable the cursor
My package manager is whole empty 😭
And i got 3 errors and unalble to fix it , this error is of sprites and all , everytime i am opening any scene its showing this error idk what's the problem pls help
No I didn't, should I?
I did now and it works fine in the editor thanks
how do I return the InputUser of a device that's being used?
I want to check if a button is pressed, and then return the device that was being used when the button was pressed
Assuming you have an InputAction.CallbackContext context then it's context.control.device
thanks!
I want while my player is placing a thing I can rotate it 90 degrees every time they press the button, but i'm not sure how to do it with the new input system it's confusing me, atm I have the key set to R on keyboard - to check if it's pressed once I can jsut have it on/off a bool, but to check how many times it's pressed and then rotate it idk how to do that
void PlaceBuilding()
{
if (!placeLocations.Contains(curIndicatorPos) && !curBuildingPreset.twosquare)
{
if (cameraCo.rotatePlacementPressed) {
GameObject buildingObj = Instantiate(curBuildingPreset.prefab, curIndicatorPos, Quaternion.Euler(new Vector3(0, 90, 0)));
City.instance.OnPlaceBuilding(buildingObj.GetComponent<Building>());
placeLocations.Add(curIndicatorPos);
}
}```
this is what I have to place it, what I use for no rotation is Quaternion.identity
Can you keep a running counter in whatever method calls PlaceBuilding? Then pass in the (rotation % 4) * 90
I'm having trouble getting the new input system to recognize my gamepad at all. Its just a generic dinput pad and nothing works. I use XInput to emulate an xbox360 controller for games that don't support anything else and Unity doesn't even notice that. What am I missing here?
It shows the gamepad's name correctly in the inspector, it just doesn't seem to notice or care when a button is pressed
Hello. I kinda have an issue. I'm running Unity 2021.1.12f1 on Linux, and oddly enough, a Rock Candy Switch Pro Controller, which the PC detects just fine; is not supported? I think it believes it to be a walkman?
Bus 003 Device 007: ID 0e6f:0187 Logic3 Rock Candy Wired Controller for Nintendo SwitchBus 003 Device 007: ID 0e6f:0187 Logic3 Rock Candy Wired Controller for Nintendo Switch```
~~Unity however...~~
I am a silly dingus bird, I didnt know the input debugger had contextual menus.... adding it to the support devices (literally an option) solves it.
I'm having problems with binding Control Schemes to my InputUsers
every time I try to do anything with the InputUser class that has to do with ControlSchemes, I get this error message
I made sure that my InputUser wasn't null or anything, and that all the values were set correctly
here's my code
The error is coming from the line that says player.inputUser.ActivateControlScheme(scheme.Value);
inputUser is a reference to the Player's InputUser, and pairedDevice is a reference to the device connected to the Player
before this part of my code, I used the PerformDevicePairing to pair the device to the user
Whats the difference between these 2 events? I need calls when they has been pressed down
I also cant seem to figure out which event is called every frame while the key is held
Has anyone tried to implement mouse drag with the new input system? I tried the approach described https://forum.unity.com/threads/implement-a-mouse-drag-composite.807906/ here, but I'm getting weird results (last post)
How can I get the mouse position in the editor using the New Input System package?
Since actions can only be read while in-game
Does Mouse.current.position.ReadValue() work?
Yes!! Thank you!
Hey guys 🙂
Just migrated to the new Input System (after a while i know) and i have trouble because
EventSystem.IsPointerOverGameObject(); doesn't work anymore and
inputSystemUIInput.IsPointerOverGameObject(); doesn't work as well...
so i can't prevent touch events altough UI elements where clicked...
What's the new way of handling such things?
you could always use a raycast from the mouse position and see if it hits anything
that's what I do
Zipcar
okay yeah... so you mean i should simulate the mouse pos with my touches?
I'm not exactly sure what you're trying to accomplish, but I know that a way to test if the mouse is over something is by using raycasts
basically you can just use the ToWorldPos method to convert screen coordinates to world coordinates, and then raycast using that as a position to see if the raycast hits something
although, anything you want to be hoverable will need a boxcollider
okay thanks for the advice 🙂
I'm pretty sure there must be a simpler solution (as it was before i updated to the new input system) but if I'm not able to find one I'll have a deeper look at the raycast solution.
as i know those pointers are raycasts anyway.
I am having a problem where the Unity file MultipleDisplayUtilities.cs did not upgrade to the new system. It keeps crashing my project. The error line is highlighted. How do I fix it?
https://hatebin.com/knfqanykhm Try this?
Idk if there is any difference but it is working for me in 2021.1.10
Or you might need to check your EventSystem in your hierarchy and see if it shows a message about switching the input system.
Its not intuitive. Like at all.
Speaking of which, this is happening and I don't know why. I don't have any methods assigned to this event, so I don't know why it is trying to read a float from a composite. Note that this only happens with the mouse wheel. If I remove that it stops complaining.
We're using EventSystem.current.IsPointerOverGameObject() with new Input System and it works. Why do you think your code doesn't?
Is there a way to have a callback key event with the new input system that is called every frame while the key is being held?
No, you need to set a bool which is set on the performers and cancelled actions.
So i stil need to use the update methods?
Yes
hey, I'm new to Unity (though i do have six years of web dev experience) and I've got what i think is a pretty basic question.
How do I get the current user input device? I'm using the auto-detect input device setting to allow the user to change from KBM to controller on the fly, and it works well, but I want to also have it change the onscreen prompts to the proper buttons when that happens. I do know it fires an event when it happens, but inside the handler for that event, how can I access the current input device and get its type?
Check Rene's response
Thank you!
Hi, I'm new to unity and I just got stuck trying to understand something about the input system. The idea is: the player is a car, there will be 2 cars, one with WASD and the other with Arrows.
I made a player prefab of the car, and it uses invoke events to move, but when I spawn 2 game objects (each one of them having their own Player Input) only 1 of the cars move.
Can't multiple Player Inputs be activated at the same time?
What am I doing wrong?
I was expecting that, even if both cars had WASD, when moving it would move both cars.
So... this is awkward but it works. After a lot of searching on something that I have no idea what I'm doing, I finally got a work around.
This post suggests that PlayerInput will not assign the same device to more than one player..
https://forum.unity.com/threads/multiple-players-on-keyboard-new-input-system.725834/#post-4848698
So I managed to work around it by using the code on the car which has the PlayerInput:
void Start() {
PlayerInput input = GetComponent<PlayerInput>();
input.SwitchCurrentControlScheme(input.playerIndex == 1 ? "Keyboard (Arrows)" : "Keyboard (WASD)");
}
I'm not sure if that's the right thing to do or if there are easier ways, but it works... let me know tho.
How can I read an input value of an action in the editor?
okay well cause i got all sorts of bugs with ui elements and touch elements but it might be that I destroyed the sprite. Thanks for the info now i know where to look at 🙂
no not necessarily
what i did was an hold and release event
hey when i start my game and i can move around if i click the pause button nth happens it doesnt even become darker for a sec
which means it has been clicked
What pause button are you talking about?
a ui one
Do you have an Event System in your scene?
Hi I'd like to ask for help setting up Input System for controllers.
I have a few questions regarding this, firstly, do I explicitly need the Input Player Manager? It's a one peripheral device game
So would be based on Gamepad.current
You don't need the Player Input Manager component, no.
var playerGamepad = Gamepad.current; Vector2 joyStick = playerGamepad.leftStick.ReadValue();
I saw this in an example, but I'm using C#
thanks @timber robin already
this is C#
I rarely use var datatype
¯_(ツ)_/¯ it's just a keyword not a datatype
You don't need to cache your gamepad either, just set it up in your input asset.
I thought maybe @austere grotto
so my next challenge is linking to the input asset
I recommend using InputActionReference in your code, as needed, to refer to InputActions
Some other options are:
- use the generated C# code file from the Input Action Asset
- use PlayerInput component
I personally prefer using the code file, implementing the interface.
er, is there a walkthrough for PlayerInput?
I'm running out of time and it's an old project
Ah ok, so I should open the inspector up
Yep there ya go - there's a PlayerInput walkthrough there
The docs here really are kind of insufficient though. There's a ton of ways to use the new Input System that are just not really documented at all in the official docs.
Thanks.
I'm really foggy about this, but seems I've set up most of what I need in my code already
at least I know to investigate for my next project.
Problem is: I need to create controls for keyboard and or gamepad
So I'd prefer implementing the interface, rather than ad-hoc my own solution
in the end, that is
my unity is randomly closes when i am about to publish a vr chat world any thoughts?
Is this related to input system?
oh my bad
I'm not sure if I'm approaching this the right way, but here's my concern:
I have a few Action Maps. These control a few broad states of the player. Regardless of what state the player is in I want them to be able to zoom the camera in and out. This results in my defining the CameraZoom action in every Action Map. This feels like its the wrong way to do this, but I'm not sure what the best way to handle it is.
define it once in a separate action map.
just make sure to enable that separate map:
playerInput.actions.FindActionMap("CameraActions").Enable();```
Either the documentation isn't clear (possible) or I'm just dumb (probable) but I didn't realize there could be several enabled at once.
neat.
How do I make a key detect if its just pressed or pressed and held for a certain amount using the new input system?
My game pad does not work when I build my game using unity new input system
Is it working in Editor?
Yes
worst thing that can happen imo 👀
good luck 🥺
the Hold interaction will tell you if the key is pressed and held for a certain amount of time.
I set my 2020.3 LTS project to the newer input system
But it hasn't worked
It keeps telling me that the Input system stuff doesn't exist
Any idea what went wrong?
- Make sure you installed the new input system package in the project
- Go to preferences - code editor and do "regenerate project files"
I am not seeing where the code editor tab is
external tools sorry
For some reason that hasn't fixed the issue. It seems like Unity set the input system to the new one without getting the necessary files for new input system
Is the package installed in the package manager?
do you have the docs link for that?
what's the behavior you want?
If i just press, it does something, but if i hold and release for X seconds it adds more force to it
I'd probably just do something like listen to started and canceled events:
- start a timer on
started - on
canceledcheck how much time has passed. If it's been more than some threshold, add the extra force, otherwise do the normal thing.
mhmm
Ahh, well i guess its fine 
that's what the canceled event is for
yeah too bad there isnt a continuous-started event so it gets called every frame while something is being held 
wait
why isn't this working
public void OnCameraZoom(InputAction.CallbackContext context)
{
Debug.Log(context.ReadValue<>());
}
im having an error on the readvalue function. it's saying "Using the generic method group 'ReadValue' requires 1 type arguments [Assembly-CSharp]csharp(CS0305)"
so i assume it needs an argument, but what would i put as the argument lol?
You have to pass in the type into ReadValue.
ohhhhhh i see okay thanks mate!
Is there a proper way to prevent disabled gameobject from responding to UnityEvents? I have an object listening for a certain event and the method gets called even when the gameobject is disabled.
I could just have the method check if its gameobject is disabled and return immediately, but this seems clunky.
Not really. Either check if it's active or unsubscribe/resubscribe the listener when the object is disabled/enabled
do i need this in order to actually detect duration?
no - you can just track it yourself. This won't tell you the duration it is held at all. It will just send a performed event after .4 seconds
For some reason it doesnt want to work without this in it 
I also use it inside the canceled event
dont evne have a performed one registered
hi, could anyone point me to where can I get Device Orientation (e.g. upside down portrait) in the "new" Input System?
I can get it via Input.deviceOrientation, but I'd like to maybe += to some "OrientationChanged" event, instead of doing it in Update()
my ps4 controller doesnt register right triggrt up, is this inteended or is it broken? all other buttons work
(it registers right trigger down)
is there a way to have more than 1 input
in the old or new input system?
new
yes, im pretty sure you just add another binding
oh yea
Yes just add a new binding.
brackys has a great video on that
Let’s check out what Unity is working on for the new Input System!
► Go to https://expressvpn.com/brackeys to take back your Internet
privacy TODAY and find out how you can get 3 months free.
● Get the new input system here: https://bit.ly/2SiXsgS
👕Check out our merch! https://lineofcode.io/
♥ Support Brackeys on Patreon: http://patreon.com/b...
does anyone know why my ps4 controllers triggers only works with "press" and not press and release?
is this intended behaviour
I think so
nope
also the problem is the action is a vector 2
so it wil be hard to have more than 2
1
move, crouch, sprint
so you want help do add bindings for a controller?
yes and still want it to be able for computer
ok
click here
and add a new controll schem, name it something like "controller"
and you might aswell add one for the keyboard and mouse
Tell me when youve done that and ill explain the next step
done
ok so, select the controller input scheme
and in it, replace the old bindigs with the contollrt bindings
then save, and it should be it
but I have 2
ok now I have movemnt for computer and movement controller for controller
does it work
let me do the script
this one explains it
I already have one
ok
how do I change this to the new input system
its hard to explain, but id look at the video i sent, they explain it well
it doesn't say
It is kinda explained here
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Migration.html#getAxis
it does'
But in the latest version it's not GetValue, but ReadValue
It's also possible to read it from the action itself - if you want it in Update method
like in the last minue
Running
have you just the input system for controllers? if you have, do you have time to help me
ok so it says of the mouse.current.position.readvalue but mouse doesn't come up as an option
What? Mouse.current.position.ReadValue maps to Input.mousePosition, not Input.GetAxis
We haven't added controller support yet
I'm trying to get input.getaxis("Mouse X")
but i can find ps4 controller
they're talking about in their game
ohhh
have you used controller in the input system
i haven't no
Just ask your question, someone might help
i've only used mouse and keyboard
do you know how I can use input.getaxis("Mouse X")
Do you want it in Update method?
ok so, the triggers only works with "press" and nto "press and release" and the sticks doesnt give of a value of 0 when they are in the midle, they use the value they had last time they was moved
yes because it's a first person game and you rotate with the mouse
which means that the character doesnt stop shooting and always spins
try
Mouse.current.delta.x.ReadValue()
mouse doesn't exist in this context
have u added it to the action map?
for mouse?
yea, id put it under keyboard, so where you added movement, add look
and give it the mouse
which I made a new action map thing like Move called mouse for this what do I change this to
ehhhhh, ask dis_da_moe
dis da moe can you help
one sec it's been a while since i did this i'm trying to do it myself
how do I get delta mouse
But it should work without the action, just using Mouse.current.delta.x.ReadValue()
What do you mean by that? Add using
I can't find it in my path
using UnityEngine.InputSystem;
...
Mouse.current.delta.x.ReadValue()
how do you the the background thing
´´´ OwO ´´
missing one on the right
Or OwO with one on each side
this is coming up
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Mouse.current.delta.x.ReadValue() * mouseSensitivity * Time.deltaTime;
float mouseY = Mouse.current.delta.y.ReadValue() * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90, 90);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
``` code
input system is of the old one I think it's giving me an error
It's really strange
It works for me and I get such error only if I'm using Input.GetAxis
you saw my error
Have you restarted Unity after enabling new Input System?
yes
IDK, try going through https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/
Maybe you missed or broke something
Hi, does anybody know a good asset for displaying input bindings on screen? Bonus points if it can switch between keyboard/gamepad/VR
Essentially I just want something I can call to display a certain button on the GUI, and have it be able to change depending on which type of controller the player is using. I could make it myself but if anybody knows an asset that already exists for this, or what to search for, that'd save a lot of time
Hey Y'all, I've been trying to do something that feels a bit slopppy where I'm amalgamating the raycast input click with the UI PointerEventData for a card game that handles both. Does anyone have any recommendations for amalgamating UI clicks and 3d world clicks into 1 uniformed thing? the interface i've made is a bit janky and I could use some advice
I think rewired can handle that in its OnInputChange event i forget the syntax for the api but it does fire an event when changing input
Either embrace the EventSystem entirely or don't use it at all
that's my $0.02
I've got a question which I think I found but wanted to clarify. I have two Action Maps, one is "MenuInput" the other is "GameInput". I also have an action on both of these maps called "act_Point" which acts as the mouse, is this not possible to do as I'm noticing in my event handling that it's acting odd when I have two actions with the same name.
Define odd
I haven't played with actions of the same name in different action maps, but I expect it at least to work if only one action map is active at a time
Hey, i use a 1d Axis to rotate my player, but i just gives me values of 0 and 1 when i do .readValue<float> (i use a keyboard, so i figure it won't give a floating point value, but why are there no negative values showing up in the console?)
Controls.Player.Rotate.performed += _ => SteerKeys(_);
void SteerKeys(InputAction.CallbackContext context)
{
_torque = context.ReadValue<float>();
Debug.Log(_torque);}
Ye so did I, but I think it causes issues, even when I use the SwitchCurrentActionMap. So one of the Actions returns a Vector2 of the position of the mouse, the other returns the Delta of the mouse, but because they've got the same name "act_Point" it just always returns the position of the mouse rather than the delta, changing the names obviously fixes this.
Even if only one of the maps is active? Sounds strange, maybe a bug
hello, im adding local multiplayer for my game, and we are using InputValue, in the tutoral he presses alt + enter, but i dont get the same menu as him, does anyone how i acces the same menu as he did
Yep can't seem to find anything on it, thought by disabling the current action map and then switching it will actually help but doesn't seem to work o.o
or i get the same menu, he just has mor eoptions
How do I start editing an inputfield with a key?
Im making a fps, and the cursor is locked, cant click the inputfield.
You need to Select() it
is my question too stupid, not well enough explained, or does no one know an answer? 
ok fixed it buy regenerating the script and saving my controls 😅 and i turned auto save off bc it was too obnoxious. Sorry folks and happy coding! 🙂
With the new input system, I need input into several different scripts. Is there a way to poll the new input system?
For example, I have "Fire" and "Move" set up. On my Player game object, I have a Player Input component, and it works to move the Player, but I need the "Fire" input in the script on my Gun game object (child of Player). There will be several different gun game objects for different types of guns. I would like to be able to just poll "Fire" from the script on the Gun. Is this possible? If so, is there a tutorial or example of how to do this somewhere? Thank you.
@royal stream Better way to solve this would probably be to handle the fire input on the player object and have it use the weapon
You certainly can go without Player input, but doing so breaks a lot of features player input provides
@frigid ridge Do you mean get the input in the Player game object script, and then send a message to the Gun object script?
Generally I have the player object call something on the item it's using
This has the added benefit of allowing AIs to do the same, as the item is no longer directly tied to some sort of player input
@frigid ridge So, would you do this by calling a method in the Gun script?
Yes
@frigid ridge Thank you, I'll try this.
If you in the future end up having different types of items, they can implement some sort of C# interface that exposes the Use() method.
@frigid ridge Thank you for that. I'm planning on having at least 3 different types of guns, with each on a different game object (child of the Player). I'm just watching a video that is using interfaces (I've never used them before).
If the only item type you have is gun, they can probably just inherit from a base gun script
Inheritance and interfaces are ways to make things neater.
@frigid ridge One will be a laser, one projectile, and one particle. I'll analyze it from the inheritance and interface ways, once I learn more about interfaces.
Yea if they don't end up sharing functionality, interface would likely be a better option. They are great for exposing a common feature between more or less unrelated scripts.
@frigid ridge That's what I'm thinking, that they will have somewhat different functionality, which is why I was going to use 3 different game objects.
Any reason to disable action maps that dont have a device plugged in for?
Hello, i've created an input action asset for Mouse Inputs using the new input system. I'm also using the EnhancedTouchSupport for Touch inputs on a TouchScreen. The problem is that I can't make them work simultaneously on Windows because a touch on a windows touchscreen is also emulated / considered as a mouse input.
Do you guys have any idea how to solve that problem ? I'd be able to detect mouse inputs & touch inputs but they have to not interfer between each other.
hey ive made some ui buttons that i can press but when i add a panel i cant press them
pls help
...
You mean panel blocks input?
Difficult to understand your situation without examples
look i want to make a in-game menu and ive added some ui buttons. However when you trigger that menu you can still see the game and i want to add a backround
and when i add the panel to make the backround i cant press them
ill thry adding an image
try
now i cant even see the buttons
i need some help with ui actually but there is no channel for that
There is
I was wondering what's the link with Input system 😄
Is my question above clear enough?
Anyone?
this input system seems highly unoptimized; its using so many strings everywhere!
Is there anything similar to https://docs.unity3d.com/ScriptReference/Input-simulateMouseWithTouches.html for the New Input System?
As long as you're only interpreting the strings once (like in Awake() for example) then it doesn't really matter how slow they are
granted, I haven't looked into the new input system
can someone tell me why Keyboard.current[Key.LeftAlt].isPressed always returns true for me until i actually press and release that button to reset the state?
no one?
every tag, every name, every key assignment is in string 
You mean internally? From a user perspective I don't have any string-based lookup in my input handling code
@olive loom
Editing it requires to go around strings
the names have extras, control scheme is literally just a long string that contains what schemes it includes per action
@plush wasp heres a code i had to write yesterday to find all the player mappings , everything here is strings cs //gets all input bindings in `Player` Action Map that uses the Keyboard&Mouse control scheme var g = Inputs.Player.Get().actions; for (int i = 0; i < g.Count; i++) { if(g[i].name != "Look") { Debug.LogWarning($"{g[i].name}"); for (int j = 0; j < g[i].bindings.Count; j++) { if (!g[i].bindings[j].isComposite && g[i].bindings[j].groups.Contains("Keyboard&Mouse")) Debug.Log($"\t{g[i].bindings[j].path}"); } } }
except for .isComposite, thankfully
not to mention the path part isnt just the name of the key or anything
its stuff like <Keyboard>/shift
not sure how editing works yet, hopefully it isnt as bad as i feel like it will be
Oh interesting, I hadn't needed to do any kind of processing on the bindings so I haven't discovered that side of it yet
I'm worried about how crazy custom user binding is going to be, especially since I have a lot of composite bindings
yesss the composite thing is so freaking annoying
wish there was a way to return a consistent class that has everything separated neatly
Hey guys. I created a game using WASD keyboard and mouse. Older people are struggling to use it so I am thinking of converting to an xbox controller. Is this something that can be done easily?
What's the difference between
controls.Ball.Enable();
and
playerInput.SwitchCurrentActionMap("Ball");
?
The second one doesn't seem to do anything on my end
This doesn't even work
playerInput.currentActionMap.Disable();
playerInput.SwitchCurrentActionMap("Ball");
playerInput.currentActionMap.Enable();```
Do you need to keep track of all action maps, disabling and enabling manually?
@indigo patrol
On that page it says Use SwitchCurrentActionMap(String) or just call Enable() directly to enable a specific map.
So they seem to be equivalent. But when this is set to Invoke C Sharp Events, the SwitchCurrentActionMap(String) function doesn't seem to do anything.
Setting it to Send Messages seems to work like expected
Send Message is ugly, you know ... https://forum.unity.com/threads/using-playerinput-with-c-events.961129/
I'm trying to get Invoke C Sharp Events working
yes yes.. see the link above
Yep I'm looking, but can't see any mention of switching action maps?
did you you scroll down ?
Yes
So I'm thinking it's probably because I'm using the auto generated interface to hook up to the events.
public class PlayerInputReader : MonoBehaviour, Controls.IPlayerActions
...
controls.Player.SetCallbacks(this);```
Since I'm hooking up to the callbacks like this, it seems like switching action maps on the PlayerInput component doesn't have any effect
Yeah I guess that's it. Since this is like rolling your own instance of the input, you need to enable and disable the action maps manually
Would've been nice to use the same function as the other systems
Found this thread that provides some insight into why using the wrapper class is different from using PlayerInput, in case anyone's interested
https://forum.unity.com/threads/input-system-generate-c-code-what-its-good-for.995674/#post-6465724
Seems like it's easiest to use one or the other for now
How can I read inputs from within the editor for custom tools? I have the new input system installed. Do these need to be actions? I'm trying to read input for scroll wheel (to change brush size) and escape (to cancel painting) from the editor scene view.
You don't need Actions
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/UseInEditor.html
Thanks! Can you give me an example of how I can tweak this to return the current key code pressed?
Is it Key.current then?
Well, I haven't used it in the EditorWindow yet, but this seems to work
if (Keyboard.current.escapeKey.isPressed) {
Debug.Log("lol");
}
Oh, sorry, I missed Editor Scene View part, above example is reading key press from specific EditorWindow, don't know how to read presses from Scene View
That's alright thanks for the help, doing most of my scripting in UVS. Someone on their discord just helped me set it up in a script graph.
Looked at it, alright, so using OnDrawGizmos works
nice that's exactly what I'm doing in visual scripting
There's a #763499475641172029 for bolt related questions.
sorry
No worries, good luck.
thx
For SceneView you still probably want to use Event.current rather than the InputSystem since theres a bunch of other wizardry going on in there.
I need someone to explain local multiplayer to me. I have two Gamepads, and I don't want to use PlayerInputManager because I don't want to "spawn" players.
I have two players in the scene, with int PlayerId = 1 and int PlayerId = 2. I want Player1 to use the first controller (if there is one), Player2 to use the second controller (if there is one), and I also have a keyboard control scheme (one on WASD, other on arrow keys).
Please help.
I don't think that's what I'm looking for. The keyboard works fine. It's the gamepads I'm struggling with.
also PlayerInput / PlayerInputManager is the easiest path out of the box to wrangle more players. You can spawn all of them at the start too.
you can also enumerate gamepads ie:
Gamepad.all[0]
will give you the first connected pad
are you trying to use InputActions or just raw access to the devices?
This is my first time using the input system. So I guess I'm using InputActions.
I also made these 🙂
I have a PlayerInput component on my player object. How do I tell the player 1 PlayerInput to only listen for Gamepad.all[0], and the player 2 PlayerInput to listen for Gamepad.all[1]?
I guess that's where I'm stuck.
thats where PlayerInputManager comes in.
The gist of it is a PlayerInput object registers an InputUser
PlayerInputManager handles binding Device(s) --> InputUser for --> PlayerInput instance
you can do that process manually as well, but PlayerInputManager makes it much simpler
Do you have a tutorial for doing it manually?
nope, but I should probably make one lol
(not the first time these questions have come up)
in the meantime this should get ya started 🙂
Okay, thank you
additionally, I still recommend using PlayerInput / PlayerInputManager even if you intend on joining players manually. it helps with much of the shenanigans
you can manually tell PlayerInputManager to bind/join a PlayerInput instance with the above function
(of course be sure to set the Join Behaviour of the manager to "Join Manually" or it will try to do everything for you and fuck it all up)
how i can add my joystick as input?
Damn you're all over this discord.
Just so everyone is on the same page, is this a physical joystick you're talking about?
Because you're extremely vague about it.
hey all 👋 i've been trying to use this package https://github.com/nullkal/UniSense since Unity doesn't have official DualSense support for the Input System yet. however, the package doesn't work in IL2CPP builds. i'm pretty sure it has something to do with the [FieldOffset] attributes, which IL2CPP doesn't support, according to the documentation https://docs.unity3d.com/Manual/ScriptingRestrictions.html. the Input System itself does work in IL2CPP builds though, which im pretty sure is related to the "Fast" prefixed scripts. according to the comment at the top, this is pre-generated. is there any way that i can pre-generate the custom code so it works with IL2CPP?
im so lost with player input, i already have a movement script for player but how do i assign that movement to the player input?
That's backwards. Input drives movement not the other way around.
yeah but, i've created a joystick with on-screen stick script and player input asset, that i assume it would get the same joystick i created, now im confused on how im gonna make that joystick move the player
How are you reading the joystick input?
what do you mean reading
i've put my player input in my joystick and now i am trying to access it through player movement script but i don't have axis in my joystick
That doesn't really mean anything to me.
Is this a joystick you made completely yourself? What drives it?
or i could use the asset one, but the point is, i always need to create a joystick by myself, if i want to move my camera with cinemachine to put it as a input there, since cinemachine dont allow objects to get dragged there
i probably will maintain the movement as it was, or i could mess this up
Sorry, I have no idea what you're on about.
Have you tried following a tutorial that would let you control the camera with an on screen joystick?
Learn how to make a third person controller for mobile using the new input system and Cinemachine. Works for Unity 2019.3 and up and am currently using version 2020.1.
At 15:10 I meant to say that the reason we set it to 0 is to avoid the gravity from accumulating when on the ground. If you fell off an edge without jumping your character would ...
yea she creates a player input with the input asset, but then she goes over so much coding that i can't understand. i just want to access the axis of my created input joystick and be able to put it on cinemachine so i can rotate it around those axis, but she goes over quaternions, eulers and god knows what
In unity I'm trying have a 2d object rotate with a joystick, I already have set up a input action for it, how would I make that happen in script?
Maybe start here? https://learn.unity.com/project/using-the-input-system-in-unity
What the input for screen pressed?
ive made a mouse look script but when i use a controller it continusly turns left```cs
public class MouseLook : MonoBehaviour
{
public float Xrotation = 0f;
public float mouseSensitivity = 1f;
public Transform playerTransform;
public void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
Xrotation -= mouseY;
Xrotation = Mathf.Clamp(Xrotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(Xrotation, 0f, 0f);
playerTransform.Rotate(Vector3.up * mouseX);
}
}
ill send you the input manager
there are 2 each
You're not really going to get mouse input and joystick input to work with the same code like that
mouse axes report the delta of the mouse position
joystick reports how much the joystick is currently tilted
so how could i doo both?
I don't really understand what you're going for. I would expect the character to continuously turn as long as the joystick is held down
Debug.Log your controller
It could have drift
Whatever the input you're using to turn
Another trick is to just unplug the controller, if the turning stops it's probably your controller at fault
Why is your joystick axis also called "Mouse X"?
it dose that is whta im saying
that might be an issue too
So it does stop when you unplug the controller?
That's controller drift
how would that be fixed?
Increase the input's deadzone I guess
ok*
ok i set the dead zone to 1 and it still turns the same
ok i pluged a modded ps4 ctrler and it didnt work period
ill try a new normal ps4 ctrller
why does the new input system does not detect android inputs?
I've been searching for 2 days and haven't found a straight answer that actually works yet, how do i implement customizable controls (new system)??? Everything I've found doesn't work and/or is way too far beyond my current coding knowledge for me to try to make it work
Look into interactive rebinding in the new input system
yeah i did
there are some video tutorials floating around for it
can you link one that actually works then
If it's above your knowledge - not sure what to do. Maybe look into Rewired?
i already have the movement script and i cant restart it
whats that 👀
looked into it a little, price is a problem there unfortunately
i used unity's built in sample package for rebinding controls, nothing happens when i use it tho
it just shows up as a different key, maybe it remaps something but when i switch scenes to actually use it, it's gone
how do i fix my android input system please
bruh you need to actually describe the problem, provide any errors, show code, etc. asking the same vague question 20 times is not going to get you anywhere
idk whats wrong too
because it was working fine before i installed the new input manager
i already tried switch to the old one but isntr working
did you select your event system in the hierarchy and make sure to click the button to update it to the input system?
it will look like this
yea i did that
okay then you will need to provide more context. nobody here is going to magically know what is going wrong with your stuff if you cannot provide any errors, relevant code, or really anything
is it responding to mouse input in the game view? is it only happening when you test on an android device? please actually describe your issue
i didnt change any coding so
so when you updated to the new input system you didn't actually update any of your code to work with the input system?
not really, how could i update it?
thanks but where am i supposed to use this
That information tells you which methods to switch to using if you are migrating from the old input to the new input system
SketchUp 2017:
Unity 2021:
How do i fix this lighting color changing thing? I mean it doesn't look the same
@tame oracle What does this have to do with input?
The lighting and shading between Unity and sketch up are not going to be the same. You need to recreate the "look" in Unity as best as possible.
ohhh okah thank you!
I'm tearing my hair out, There seems to be a million different ways to use the new input system, could anyone please link me a good tutorial to learn HOW to use it? To learn how it works, but necessarily how to make 2d/3d movement, but how it works
If that makes sense
The one I found most helpful is the hour long talk on the Unity YouTube channel.
The package in the Package Manager has a button to import examples. They go in detail showing off three different ways to use it.
You're right there's a lot of different ways to use it, which is a bit confusing. But also powerful. It took me a while to decide on the implementation that works best for my style of coding.
Could you send me a link? I've looked at a few of them, but not sure which one you mean
I'll look into it now!
100% agree, I've looked up a bunch of different tutorials, but each of them use the system differently, which has thrown me off quite a bit. But glad I'm not the only one noticing it!
i have problem with my game, i want to rotate my cinemachine camera but this originates a problem that will cause my player to move and rotate the camera at the same time, how could i solve this issue? both movement and camera rotations are joystick so this is happening
I'm on mobile so can't do right now. It was an hour long Unite talk I believe.
Thanks, I'll see if i can find it, on their YT channel?
Workflow Tips and Feature Integrations? 45 mins, sounds right? 😄
Maybe. It had a Viking character.
Yea, that's it then, thank you!
Active Input Handling, can i just put this on Both to avoid errors? Or should i force myself to use the new one?
Getting errors related to Conemachine
Some packages use Input system, I think they have settings to turn it off. But if you want to keep using both set it to both.
@timber robin can i ask this question in unity-talk? this channel is a bit inactive
Dont setting to use both kind of have a big overhead?
Doesn't setting it to use both have a big overhead?*
Have no idea about that. You can look this up online.
There's a component in Cinemachine to handle this. Leave it on New only and use the Cinemachine Input mapper or whatevre it's called
So if i post code, will the code be collapsed for others?
I've setup a very basic Vector2 movement in a 3d world, with a sprint option, and would love it if someone could have a quick look and let me know if im going in the right direction
I'm basically taking the V2, changing it into V3 (context.x, 0, context.y)
Multiply by movespeed/time.deltatime, and perform the move in an FixedUpdate method
And a button input checking context.performed (sets isSprinting = true), and contect.canceled sets isSprinting = false
And in my update, i check wether character is sprinting or not
I THINK I'm on the right track, but would love to get it confirmed de debunked ❤️
That sounds right to me. Assuming you're using a rigidbody for the FixedUpdate.
Been trying to make a simple jump button work with the new input system, but I can't get it to work, my button has the press interaction, then I read the value as context.performed because started doesn't work, but it keeps reading as true, so my player keeps jumping
why use the press interaction?
I thought that's how it's supposed to work
I just want it so that just pressing it at that moment enables a bool, then disables it afterwards
it says on the docs that you can use the Press interaction to detect it
UnityEngine.input.GetButtonDown
See UnityEngine.Input.GetAxis for how to set up a binding to a button or axis. You can use the Press interaction to detect when a button is pressed.
I switched it to ButtonControl, still doesn't work
I don't even know why it's not working as intended, it's set to Invoke Unity Events here, and it's called as is above
wasPressedThisFrame doesn't get set to false even if it's not that frame
You don't need to use any interaction. The default interaction works fine
Check cs if (context.started) { isJumping = true; }
No need to check the InputControl
Press interaction is only if you want to customize how it detects the press
I only want to detect it being pressed once, and then disable it straight away
yes, later in your code you will say:
if (isJumping) {
isJumping = false;
// do the jump
}```
I feel like there's a better way to do this, but I'll try it I guess, I swear I've done this before, but I don't have the project that has it
I used InputControl because wasPressedThisFrame sounds exactly like what I'm looking for @austere grotto
I understand that but started does the same thing and it's control agnostic
And it obeys the configuration rules of your input action
not sure how to deal with this all honestly, since my player has states
States responding to input events is like the textbook paradigm for state machines.
Each state, it should have a defined response to each input event
so, disable my jumping bool as my idle goes to jump?
for example If you're in the standing state, and you receive a jump input - you should transition to the jumping state
just an example
{
if(Input.GetButtonDown("Oculus_CrossPlatform_PrimaryIndexTrigger"))
{
Debug.Log("P Index trigger pressed");
FirePortal(0, leftController.gameObject.transform.position, leftController.gameObject.transform.forward, 250.0f);
}
else if (Input.GetButtonDown("Oculus_CrossPlatform_SecondaryIndexTrigger"))
{
Debug.Log("S Index trigger pressed");
FirePortal(1, rightController.gameObject.transform.position, rightController.gameObject.transform.forward, 250.0f);
}
}``` i never get any output. any idea what im doing wrong?
Those button names are not correct I guess?
Did you set those buttons up in your input manager?
yeah
they get auto created by something else i dont know what
some oculus stuff probably lol
Put a debug.log outside of the if statements
make sure your Update() is actually running
i cant even spell spam smh
triple check that your button names are correct
is it ok that some bindings have no button assigned and only an axis
actually wait its not really a button its aqn axis so would i have to have a loop that checks the value of the trigger
idk about a loop but you can check like ```cs
if (Input.GetAxisRaw("Oculus_CrossPlatform_SecondaryIndexTrigger") > 0.5f) {
}``` or whatever threshold you want to check
i just changed it to that and will check if ti works after the battery charges, thx
oof
man I want to get a VR for fun and development but it really seems not ready for primetime yet
Its pretty fun in certain scenarios
i got the quest 2 and for how much it was id say it was worth it
Love me some beat saber and Superhot
pavlov >>>>>>>>>
I really like the games where the space around you is the space you move in, as oppose to a joystick/teleport movement
But thats just me
Like Job Sim and Vacation Sim do that well
Has anyone had any issues reading input from the InputSystem in DOTS? Particularly using buttons? I'm having the strangest problem with it, where I'll miss frames where .triggered is true. I switched to using the old Input and my code runs fine so I'm pretty sure its InputSystem.
It occasionally works, which is part of the strangeness.
What input behavior are you trying to accomplish and what does your code look like?
Attempting to read a button press just to jump
There is the input system (just using the "Fire" button to jump for now)
[UpdateInGroup(typeof(CopyManagedDataToComponentSystemGroup), OrderFirst = true)]
public class InputSystem : SystemBase
{
// Get an instance of the InputSystem
private readonly CCInput _input = new CCInput();
protected override void OnCreate()
{
base.OnCreate();
// Create Singleton Entities for each Action Map
EntityManager.CreateEntity(typeof(PlayerInput));
}
protected override void OnUpdate()
{
// Populate input components with input data
if (HasSingleton<PlayerInput>())
{
if (!_input.Player.enabled)
{
_input.Player.Enable();
}
var playerInput = new PlayerInput
{
Move = _input.Player.Move.ReadValue<Vector2>(),
Look = _input.Player.Look.ReadValue<Vector2>(),
Fire = _input.Player.Fire.triggered
};
SetSingleton(playerInput);
}
else
{
if (_input.Player.enabled)
{
_input.Player.Disable();
}
....
Here is the code where I read from the InputSystem
Let me know if you'd like to see the rest of the code in that file
public class PlayerMovementSystem : SystemBase
{
protected override void OnUpdate()
{
PlayerInput playerInput = GetSingleton<PlayerInput>();
Entities.WithAll<PlayerTag>().ForEach((ref CharacterController characterController) =>
{
float movementX = playerInput.Move.x;
float movementZ = playerInput.Move.y;
if (!MathUtils.IsZero(movementX) || !MathUtils.IsZero(movementZ))
{
characterController.CurrentDirection = new Vector3(movementX, 0.0f, movementZ).normalized;
characterController.CurrentMagnitude = true ? 1.5f : 1.0f;
}
else
{
characterController.CurrentMagnitude = 0.0f;
}
characterController.Jump = playerInput.Fire;
}).ScheduleParallel();
}
}
And here is where I read from the playerInput singleton and apply it to the charactercontroller of the player
When I swap characterController.Jump = playerInput.Fire with characterController.Jump = Input.GetButton("Fire") or something similar (I got rid of the code so that may not look exactly right) jumping worked fine, but otherwise the jumping only works occasionally/randomly;
Movement works fine with InputSystem so I'm assuming its something to do with the Action Type Button
I would recommend not using the Press interaction. it's only there for customizing the press point basically
Thanks, I actually just added that to see if it would fix the problem
I'd been having the issue before without Press
I'll get rid of it now tho
Also try:
Fire = _input.Player.Fire.ReadValue<float>() > 0```
whoooaaaaa
i think that worked
yes i think its good now
tyvm
was using .triggered not the right way to do this?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputAction.html?q=InputAction#UnityEngine_InputSystem_InputAction_triggered
triggered is more like Input.GetButtonDown
if you check the docs
Whether the action was triggered (i.e. had performed called) this frame.
Yeah is that not what I wanted? I thought that made sense
You have Input.GetButton("Fire")
that's true every frame as long as it's held down
idk is that not what you want?
I just wanted to read the frame the button was pressed
And have that make the char jump
You could also try:
Fire = _input.Player.Fire.phase == InputActionPhase.started
I'm not super familiar with DOTS but is OnUpdate guaranteed to run every frame?
that also seems to work fine
hmm i believe so
i'm also new, this is all just me experimenting tbh
i wasn't expecting to get stuck so early tho hahaha
ok - the started phase thing should be more like GetButtonDown and checking if ReadValue > 0 should be more like GetButton
np
any idea why .triggered wasn't working?
Not really... I actually would rexpect it to work. But sometimes the rules about when an action is performed are kinda strange
but started is pretty consistently when you first start actuating the control
so...
¯_(ツ)_/¯
what binding do you have set up?
Space key?
idk - but it's working with the started phase thing?
yes
cool
np
Has anyone been able to get local splitscreen with per-player UI working with the new input system?
Yes, the entity query that matches will guarantee to run OnUpdate each frame. Actually it runs more frequently than the legacy Update event on MonoBehaviour
I use InputSystem with DOTS, it works perfect. .triggered will run ONLY one time (one frame) the moment the button passes the press threshold, and that's it. If you want to know if the button is being 'held' down in any given frame, you'll want .ReadValue instead.
For DOTS, depending on what I need, I have it setup like this:
var playerPrimary = input.Player.Primary.triggered;
var playerWantsPrimary = input.Player.Primary.ReadValue<float>() >= InputSystem.InputSettings.defaultButtonPressPoint;
is enabling/disabling an input system action map actually this expensive?
I'm messing around with a piece of code that I found that's meant to vary the height of your jump based on how long you press the button for. My only problem is that the code is written with the Unity's old input system and I'm trying to transfer it over to the new system.
Here's the original code:
if (rb.velocity.y < 0)
{
rb.AddForce(gravity * fallMultiplier, ForceMode.Acceleration);
}
else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
{
rb.AddForce(gravity * lowJumpMultiplier, ForceMode.Acceleration);
}
else
{
rb.AddForce(gravity, ForceMode.Acceleration);
}
}```
And here's what I have:
I have two scripts: PlayerController and JumpModifier.
PlayerController has:
```cs
[SerializeField] public bool jumpButtonRelease;
public void Jump(InputAction.CallbackContext context)
{
if (isGrounded)
{
jumpRequest = true;
}
if (context.canceled)
{
jumpButtonRelease = true;
}
}```
JumpModifier has:
```cs
[SerializeField] private float fallMultiplier = 2.5f;
[SerializeField] private float lowJumpMultiplier = 2f;
private float gravityScale = 1f;
private float globalGravity = -9.81f;
void FixedUpdate()
{
Vector3 gravity = globalGravity * gravityScale * Vector3.up;
if (rb.velocity.y < 0)
{
rb.AddForce(gravity * fallMultiplier, ForceMode.Acceleration);
}
else if (rb.velocity.y > 0 && playerController.jumpButtonRelease)
{
rb.AddForce(gravity * lowJumpMultiplier, ForceMode.Acceleration);
playerController.jumpButtonRelease = false;
}
else
{
rb.AddForce(gravity, ForceMode.Acceleration);
}
}```
I thought that this would work but unfortunately it doesn't. From what I've gathered so far, when I used Debug.Log on jumpButtonRelease in FixedUpdate, it seemed like jumpButtonRelease only became true if you hold the jump button for long enough. So in the end, the player never does a short jump because jumpButtonRelease doesn't become true fast enough. Help would be appreciated. Either by fixing this or pointing me to a way where I can do short jumps with the new input system. I tried finding methods to this with the new input system, but no dice.
Also based on the Migrate from Old Input System guide, the isPressed property seems like it could work but I can't quite figure out how to use it with the code that I have.
What am i doing wrong? This is some insane performance hit for the new input system
Not even sure which part is actually doing this, just that it involves the mouse
No but creating one from the generated code file might be. It does a bunch of JSON parsing etc
Its technically already created at startup?
im just enabling/disabling the player maps while in the menu
Hey guys I have installed rewired and I have used it and it works, my ds4 controller works perfectly.
It doesn't work in the build on mobile thought.
Pls help me
I have tried unity remote too, on pc it works, on mobile it doesn't
Idk if this is the right channel to ask but I am not understanding why on mobile it seems like not registering input
Ping me whenever you want to help me
hey, trying to get my menu working with the new input system, but I'm feeling a bit stuck. I added an InputSystemUIInputModule to my event system, and assigned it the player controls asset that has the UI controls mapped, but nothings working other than my mouse. not seeming to get any navigation events from keyboard or gamepad
Does it work with the default InputActionAsset for UI?
(the one that's preconfigured on the module)?
nope 🙁
ok well I just removed the whole even system and made a new one, and now it works 😅 must have screwed something up along the way. thanks for the help
Using new unity input system.
I have a Player Input component that handles all player input for non-UI actions. And the eventSystem's "Input System UI Input Module"
The "Fire" button and the "Submit" button are the same keybind. The Fire button opens the menu, but then instantly clicks the selected button. This happens even if the UI Input Module is disbabled when the fire button is pressed. Has anyone seen this and know why this is happening?
Yeah I've seen this before.
my workaround is to alternately enable/disable the action maps as needed.
Only enable the UI action map when you open the menu
I think I may have even done something where I waited one frame after opening the menu before enabling the UI action map
Is the UI action map enabled while the UI input module is disabled?
They are independent
Ah, then that may be a simple fix. I thought disabling the UI input module would disable input... Let me try that
playerControlsMap.Land.Move.ReadValue<float>();```Gives me the normalized value, so roughly the same functionality as `Input.GetAxisRaw("Horizontal")`. How do I get the same functionality as the non-normalized version, `Input.GetAxis("Horizontal")`?
GetAxisRaw vs GetAxis is not about normalized vs not normalized
GetAxis performs smoothing
Yeah I noticed that
I'm doing my own smoothing now :p
Do you know any ways to smooth though?
Just use MoveTowards basically
have a separate float axisValue variable that you MoveTowards the actual input value
That would mean I also smooth vertical velocity though
It's a 2d platformer
Actual Input value -> feeds into your smoothed input value -> feeds into whatever you do with the input value
Oh, cause I'm smoothing velocity now
that's different
Well then I guess I should ask, do you know any ways to simulate acceleration?
do you know how acceleration works?
I mean I know some people literally just increment the velocity until it reaches a certain max limit
that's how acceleration works basically so yeah
Isn't that too linear though?
Alright
THere's SmoothDamp
or get something like DOTween which offers 85 different easing functions or whatever
and do as you please
playerControlsMap.Land.Jump.triggered```How do I get this, but for if the player is holding the button?
triggered seems to only return true the frame the player pressed the button.
listen to the started and canceled events
set a bool to true in started
false in canceled
Alright
or do : playerControlsMap.Land.Jump.ReadValue<float>() != 0
Oh I like that better, thanks :)
Hi i wasnt sure if this was the place to ask this, but is ther a way to change the input to scroll through a scroll rect? i know of pc is default to scroll wheel or click and drag but i want to set it to scroll with a custom input. is this posible?
it comes from your Input Module
whatever axis or InputAction is set there
okay.. do you mean in input manager?
No
I mean the InputModule component
usually it's on your Event System GameObject
Hello, i'd like to know if there's an alternative implementation of UnityEngine.Input.simulateMouseWithTouches with the New Input System, as there's no corresponding API yet, how can I have this behaviour using the new input system ?
Sources : https://docs.unity3d.com/Packages/com.unity.inputsystem@0.9/manual/Migration.html & https://answers.unity.com/questions/598032/how-to-disable-touch-to-mouse-click-translation.html
Does new input system supports dualshock 4?
I know it doesnt support usb wireless adaptor but does it supports bluetooth?
It supports dualshock4, I don’t know about bluetooth though. I think it should.
i think it does as long as you use DS4 windows, i guess
“We do not support the "DualShock 4 USB Wireless Adaptor" to connect a PlayStation controller to a desktop machine. Use USB or Bluetooth to connect it.”
Okay they do support it.
Not sure about dualsense though, I wanted to know about that. My dualsense just gives wrong input in game except leftstick 😐
how about on mobile?
Hey I need some help regarding input system on games for my project. Pls dm me I'll appreciate it very much
This discord is for asking questions, not for finding personal help. You can ask your question and if anyone can answer, they will.
Ok thx for telling actually im new here
What is this channel? Its Input.Getkey gang?
It's old and new Input System 🙂
lol, i like how you put that.
does rewired can be used on unity remote too?
or I have to do a build?
basically I am using my dualshock 4 connected to my phone (bluetooth) connected via usb to my pc
doesn't seem to work
altought it works perfectly when ds4 is connected to pc
I'm creating a local multiplayer game using the new Input System.
I'd like a shared main menu where anyone can change the selected button. Followed by a character select screen whereby each player chooses their own character settings.
I can get multiple inputs mapped to 4 different sets of buttons on the screen. But I cannot figure out how to have a shared UI... anyone else come across this?
ok I did the build
but rewired doesnt work
on mobile
I am using the ds4 but on mobile it doesnt work
but It works fine on editor
make 4 UIs overlap
So rather than one start and exit button? I'd have 4 sitting on top of each other? Surely it would just show whoever sits on top
yeah
maybe you could disable rendering for 3 out of 4
so maybe it works but you dont see them (to improve performance)
idk there is surely a better way
yea, because that way you're gonna have each player selecting different buttons on their own unrendered canvas
it's a pain in the ass, been trying to figure this out 3 or so days now
does anyone know how to have an anolog stick control an object on a canvas? its currently controlling the object but it resets its position when i let go of the stick. i want the object to always be traveling additivly across the canvas (retaining its position)
@slow crest maybe you can make a sort of "record" or maybe you save the position of the joystick in the last 2 frames, if it the stick gets close to the center really fast you block the stick
@tidal jackal i hav already tried that. there should be a simpler way
I am not sure of a simpler way but did you really tried that?
yeah, it doesnt work becasue what if i want to move the stick back to the center slowly? it wont return the corect vector2 value i need @tidal jackal
it should
btw https://guavaman.com/projects/rewired/docs/Troubleshooting.html (first script) for the code I used to debug
how would you do it? or do you know of a link
idk
I have done something similiar for my game tho
but instead with momentum
its a weird story of how I implemented a mechanic...
@tidal jackal im just trying to translate an image across the screen uning the joystick and/or the mouse position at the same time
already did that
instead of doing something like mouse_pos = get.axis
you can do mouse_pos += get.axis
the problem is that the fake mouse needs to control the real mouse position as well as the image. and the mouse position needs to controll the fake mouse and the image at the same time. they clash
you dont have to worry about the stick going back
i dont think thats a problem
how though?
how do i have two things control eachothers values?
thats like asking you to pick yourself up off the ground. its justy physically impossible
//C#
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
int xPos = 30, yPos = 1000;
SetCursorPos(xPos,yPos);//Call this when you want to set the mouse position
idk what this is
i copy pasted
ok better question. @tidal jackal do you know how to change the mouse position without moving the mouse
but should work
//C#
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
int xPos = 30, yPos = 1000;
SetCursorPos(xPos,yPos);//Call this when you want to set the mouse position
oh i see
i don't understand the three middle lines of code and why they are necissary
also ik nobody cares because this is a unity server but in python its
import pyautogui
pyautogui.move(100,100)
me neither but it should work
I think first you immport namespace then a dll and then a bool from dll that makes everything work
@tidal jackal im not a fan of copy pasting code into my project. there has to be a better solution
thanks for the help, i'll continue fighting my way through this
yeah there is always a better way but its not worth wasting 20 hours finding the best solution that will save a quarter of millisecond off a frame
@tidal jackal im not looking for fast response time. im looking for a clean way to write the code
you should see my scripts, you'll shit your pants with how clean it is
definetely but if to make the code cleaner you put a getcomponent<>() in the update void just to make it look "cleaner" its useless
what? thats a horrible idea
complete opposite of what clean code means
Clean code does not mean "less" code
to anyone who wants to help me here is my question, also I didn't specify that I have this error:
Autoconnected Player Rewired: [ERROR] ControllerDataFiles is missing critical data! The serialized data may have been corrupted. Please see the Known Issues in the documentation for possible causes and solutions.
------- Rewired System Info -------
Unity version: 2020.1.3f1
Rewired version: 1.1.36.0.U2019
Platform: Android
Using Unity input: True
Native mouse handling: False
Enhanced device support: False
Android: Support Unknown Gamepads: True
you're right
debugging code if it's interesting
pls somebody help me
@tidal jackal ok so i figured out half of it just now, all i need to do is convert the mousposition value to a additive value i think?
Yes
So that for example axis is negative mouse pos was 800 += axis (-1) * sensivity
Nice
is there a list that shows what to type in code if i want to get input from (spacebar) or (the letter g) or (right mouse click)
private void Update() {
var input = Input.inputString;
if (!string.IsNullOrEmpty(input))
Debug.Log("Pressed char " + input);
switch (input){
case "q":
Debug.Log("Q Logic");
break;
default:
break;
}
}
using this to process input, is there an article on the best practises? this doesnt account for cases like mouse buttons or spacebars
ty
anyone know why the player can only move right and backwards not forwards and left. ```c
using UnityEngine;
public class InputManager : MonoBehaviour
{
#region Variables
[Header("Movement Axis")]
[SerializeField]
private string m_forwardAxis = "Vertical";
[SerializeField]
private string m_sidewayAxis = "Horizontal";
[Header("Weapon Keys")]
private KeyCode m_aimKey = KeyCode.Mouse1;
[Header("Camera Axis")]
private string m_verticalLookAxis = "Mouse Y";
private string m_horizontalLookAxis = "Mouse X";
private float m_xAxisSensitivity = 0.5f;
private float m_yAxisSensitivity = 0.5f;
protected float m_forward;
protected float m_sideway;
protected bool m_aiming;
protected float m_xAxis;
protected float m_yAxis;
#endregion
#region Properties
public float Forward
{
get { return m_forward; }
}
public float Sideway
{
get { return m_sideway; }
}
public bool Aiming
{
get { return m_aiming; }
}
public float XLookAxis
{
get { return m_xAxis; }
}
public float YLookAxis
{
get { return m_yAxis; }
}
#endregion
#region BuiltIn Methods
private void Update()
{
HandleInput();
}
#endregion
#region Custom Methods
protected void HandleInput()
{
m_forward = Input.GetAxis(m_forwardAxis);
m_sideway = Input.GetAxis(m_sidewayAxis);
m_aiming = Input.GetKey(m_aimKey);
m_xAxis = Input.GetAxis(m_horizontalLookAxis) * m_xAxisSensitivity;
m_yAxis = Input.GetAxis(m_verticalLookAxis) * m_yAxisSensitivity;
}
#endregion
}
no Idea, this code doesn't move anything
ok well the project is using final ik maybe that is doing it?
no idea. It's definitely related to however you're moving the character, and this script is only part of that
how are you taking these input values and moving the character?
i have no idea i found this project on a website for unity tutorials and im just trying to learn from it
Well the first place I'd look is to do a "Find All References" on the public properties in this script like Forward
that should take you to the script that actually moves the player
assuming that script actually uses the input data from this one
Do you know what "IK" is?
not really
It's "Inverse Kinematics". It's a technique to line up a character's appendages with things they are holding or reaching for or standing on or otherwise interacting with
It generally is not directly related to movement
oh ok so i need to not look in the stuff related to "IK".
You should be looking for a script called something like "Player Controller" "Player Movement" "Character Movement"
something along those lines
nothing with those names
Idk - without seeing the projetct I'm shooting in the dark here and it seems so are you
Maybe start by looking at the scripts that are attached to the player?
was just about to send a pic of that lol
and there's nothing ive not looked in before so
i mean not really im stupid
it's what you're looking for
oh ok well if i send the script can you tell me why i can only use S and D to move the player but that arrow keys work fine
maybe
although when you describe it this way it seems more likely to be a problem with your Input Manager settings
ok but i don't see anything in the Input Manager that would help me although i am stupid so maybe
Look at the "Horizontal" and "Vertical" axes and see what keys are bound to them
what one the player game object?
My question
.
hello everyone, is it possible to export a package of a scene including the input system?🤔
Is there a way to totally disable the input system, like during a transition?
Either disable the entire InputActionAsset you're using or disable whatever ActionMaps you need
thank
How can I get the position on Press action?
the position of what
the press
For example the press of a primary touch
Ok so touch position
yeah, or mouse
You'd make an InputAction that is bound to pointer position
and read the current value of that action with pointerPositionAction.ReadValue<Vector2>()
i mean i do right now but it's kind of state-machine-ish
cause i have to wait for the position event to come first before i know where he pressed
or does position come first, i wouldn't think so
you can read the current value of the action at any time
the entire input asset is refreshed at the same time
So when the Input Action Press is called, would the Position action hold the right value?
yes
cool
anyone know why this script is not working i have all the ground objects tags set just not working ```c
//jump script for a 3d object
//attach script to player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//make sure you save the script as "playerJump"
public class playerJump : MonoBehaviour {
//variables that are set
Rigidbody player; //allows what rigidbody the player will be
private float jumpForce = 1000f; //how much force you want when jumping
private bool onGround; //allows the functions to determine whether player is on the ground or not
//the first thing to happen at runtime
void Start() {
//grabs the Rigidbody from the player
player = GetComponent<Rigidbody>();
//says that the player is on the ground at runtime
onGround = true;
}
//checks every frome if the parameters are met to start the function
void Update() {
//checks if the player is on the ground when the "Jump" button is pressed
if (Input.GetButton("Jump") && onGround == true) {
//adds force to player on the y axis by using the flaot set for the variable jumpForce. Causes the player to jump
player.velocity = new Vector3(0f, jumpForce, 0f);
//says the player is no longer on the ground
onGround = false;
}
}
//checks if player has hit a collider
void OnCollisionEnter(Collision other) {
//checks if collider is tagged "ground"
if (other.gameObject.CompareTag("ground")) {
//if the collider is tagged "ground", sets onGround boolean to true
onGround = true;
}
}
}
define "not working"
What are you expecting to happen, and what is happening instead?
nothing is happening at all the player has the script and when i press space nothing happens and this time it is the right keys in the input manager
I'd guess then that your OnCollisionEnter is not running, or if it runs, the objct you collided with is not tagged properly
first step - Add some Debug.Logs
void OnCollisionEnter(Collision other) {
Debug.Log($"OnCollisionEnter called. We collided with {other.name} which has tag {other.tag}");
//checks if collider is tagged "ground"
if (other.gameObject.CompareTag("ground")) {
//if the collider is tagged "ground", sets onGround boolean to true
onGround = true;
}
}```
that's the first one I'd add - look for that in the console and see what's going on
I'd also add one here to make sure the jump code is running:
if (Input.GetButton("Jump") && onGround == true) {
Debug.Log($"Ok we're jumping now!");
//adds force to player on the y axis by using the flaot set for the variable jumpForce. Causes the player to jump
player.velocity = new Vector3(0f, jumpForce, 0f);```
ok ill give this a try
?
ok fixed that error but now its saying im jumping but the player doesn't move
- Do you have another script that is also controlling the rigidbody?
- Do you have any constraints on the rigidbody's position?
yes this script is overwriting the player's veloict every physics frame, so it will just overwrite whatever your jumping script does
would you be able to add the jump script into that file for me as i don't know how i did try but got really confused
How do i detect if its a controller being used or a mouse?
its not tracking my mouse delta for some reason, even when moving the trackpad, any reason why this would be?
what is "it" that is not tracking?
im using player input script for unity events and im using a look function with that takes the mouse delta as an input, but even when debugging at the very beginning of the void it just doesnt run
- How is the Input Action configured? (Value/Vector2 for example)?
- What is the name of the action?
- What is the signature of your function?
- What action map is the action in?
- What's the default action map of the PlayerInput
Does anyone have a tutorial, article, or reference that I can follow to understand how to create a controller/input device key binding using the new unity input system? (say I want to allow the player to change JUMP from south button to R)
awesome thanks - runtime rebinding is what I was looking for
hello im using the new input system, im trying to do a hold button sprint, whats the action for that? e.g sprintControl.action.(?)
as far as i know .triggered is when the button is pressed, is there one where when the button is being held?
sprintControl.action.ReadValue<float>() != 0
thanks! : )
i started using the new input system and everything was working great until i realized that now for some reason the character controller only moves the player by the world position rather than local position, any help with this would be appreciated
you can set playerVariable.transform.localPosition instead of playerVariable.transform.position
@hearty lance
public void Update()
{
controller.SimpleMove(PlayerMove * playerSpeed);
}public void Move(InputAction.CallbackContext context)
{
Vector2 move = context.ReadValue<Vector2>();PlayerMove = new Vector3(move.x, 0, move.y); }
oh i see
thats the movement
well you can use its world position plus an offset to effectively change its local position
any examples on how to do that..?
like Vector2.move = transform.position + context.ReadValue<Vector2>();
so offsetting it from its world position by the input amount which i assume is what context.readvalue is
idk if that would work any differently it probably wouldn't now that i think about it
i hate that it went from local to global just because i switched input systems
figured it out, thanks for the help though!
void Update()
{
controller.Move(transform.TransformDirection(PlayerMove) +
Physics.gravity * playerSpeed);
}void Move()
{
Vector2 move = context.ReadValue<Vector2>();PlayerMove = new Vector3(move.x, 0, move.y);}
Glad you figured out your issue, but old input system vs new input system shouldn't have made any difference. Neither input system is aware of the direction your player is facing. CharacterController always deals with world positions
Would it be possible to assign scroll wheel +/- to the same input as dpad up/down? I'm having no luck so far
i downloaded the new input system but then regretted it and removed it. how do i switch back to the input manager?
nvm found solution (project settings, player, active input system)
Just tested a WebGL build using the new Input System, and IMGUI buttons don't seem to be recognized. Changing to the old input system, the buttons works as normal. Any tips as to why?
Did you update your Input Module on your Event System?
New Input system uses its own input module
Yep. As seen in the clip, the white button works just fine, issue is with the IMGUI buttons
The exact same setup works just fine in a windows build too
Would seem to be a bug then 🤔
Heres a thread about the opposite (not working in a windows build) which presumably was fixed: https://forum.unity.com/threads/imgui-input-in-builds.737642/
was afraid someone was going to say that 😅
Thanks for the info
Does anyone know how to get a Playstation 5 controller to be recognised properly by Unity?
I'd love to know how you're meant to multiply just joystick input by deltaTime when using it in combination with mouse input for a look action. Where of course the mouse portion of the input does not need to be scaled.
The docs have an example that does not do it
and just says "You can write code that is agnostic to where the input is coming from", yahuh, I could write something broken
I imagine you could write a processor that scales by deltaTime and only apply it to the joystick?
Hello im using Unity 2018.3.8f1 and my player character suddenly stopped being able to look up and down. I imported images from a different project to use as sprites for a UI but that was all. I restarted Unity but that didnt fix it. Would anyone have any suggestions for how to fix this? (For now I cant switch out of 2018.3.8 to the newer engines)
Hello everyone 🖐️ , i wanted to ask something
at the moment I am trying to learn the new input system. I would like to know if you use the component "Player Input" or if you use the C# auto generated class, and why
I'm a bit lost at the moment and clearly there are 30 different ways to use it, I prefer to ask for help
hi all
i can not get my public void to show up as a input action, how come?
does not show in the dropdown
How would I be able to get the value of this callback context?
if(value.phase == InputActionPhase.Started){
Debug.Log(value); } }```
I'm trying to get the -1 from this debug.log
using UnityEngine;
using UnityEngine.InputSystem;
public class UIInputs : MonoBehaviour
{
public void StartGame(InputAction.CallbackContext context)
{
Debug.Log("You pressed start! Good girl!");
}
}
is my code not right
?
What's appearing in the functions list?
Then you should have continued down my website
and gotten to this page https://help.vertx.xyz/?page=Interface/Unity Events/Incorrect Assignment
hmm
is it saying what value it expects to be read?
nope im just getting a syntax error
so i want to get the factor value here
well that did something
but when i press Start nothing happens
What would cause that part?
ill watch this video:
Unity's new input system is event-based plus it handles keyboard mouse and gamepads easily and quickly. The video looks at action maps, actions, bindings, action types, interactions, and processors. Which can be used to dial in the controls for a Unity project. The system can broadcast messages, use Unity events, or best of all use C# events whi...
later, sleep well
Just using the player input with Unity events seems like a reasonable approach to get the most out of the new input system for the least amount of effort. You can always dig deeper into how PlayerInput, PlayerInputManager etc. are put together to build your own high level layer if need be.
How can i make the mouse delta from the new input system deterministic i tried multiplying by delta time on update but it doest work it is sometimes slow and sometimes fast, same if i dont multiply by delta time
Got a question I am finding it very difficult to get an answer to. I know I could just use the default gamepad for my new input system bindings but if I'm planning on making this cross platform, I should use specific button mappings... so my issue is the nintendo switch. The input system has to option for pro controller mapping but will that mapping also work for joycons?
anyone else experience lag time during play mode startup before the input system accepts input? I see it consistently, about 1-5 seconds
Editor? Might just be the editor compile time
yeah, i can't recall if i also see it in builds. but i was not experiencing it when i was using the old input module
oh then dont know. by editor compilation lag it would have been same for both.
not sure what channel to put this in, so Ill put it here. I want to turn up my Camera's far clipping plane to be able to see a larger area of my map, but when I rotate my camera using a script while the clipping plane is set to a higher number, it becomes laggy (it skips a few pixels when turning every second or so)