#🖱️┃input-system
1 messages · Page 52 of 1
the way mouse input works is whenever you move the mouse, for that one frame you get the delta (change) from last frame
so whenever you're not moving the mouse you will get 0,0
Typically for a top down game with mouse aiming you'd have a cursor that you move around and have the player aim at the cursor
It just fundamentally works differently from joystick aiming
Is there a way for me to fix it while keeping my current aiming implementation with the controller? If not, I can just make a new action and switch between them whenever I switch between keyboard/mouse and controller.
I'd probably make a separate action that reads mouse position not mouse delta
and yeah the code is gonna be pretty different, probably not worth trying to do it with a single InputAction
Thanks so much for the help! I implemented 2 different actions and it's working perfectly now.
REcommedned videos for new input system? 100% lost @-@
@tawny dome there's a tutorial in the channels pinned messages
Cannot find action 'Pause/Pause[/Keyboard/escape]' with ID 'b9f0c125-46e5-4f6f-9026-9808c4fd429b' in 'Controls (UnityEngine.InputSystem.InputActionAsset)
UnityEngine.InputSystem.PlayerInput:OnEnable () (at Library/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/Plugins/PlayerInput/PlayerInput.cs:1564)
from what i understand i get this error bc i removed an input but when I try to re add it with the same name and all i still get it
help ?
Make sure to save your inputaction asset
If not that, share screnshots of the action and the code
show the code that's trying to use/find the action
Oh , and show the inspector for your PlayerInput component
well that's what i can't find
when i remove an input doesn't it give me errors other than the one i sent ?
bc i fixed those after i removed the pause action
How i can put my file explorer folders in Unity?I have some folders with scripts and animations but i can't,i need a another unity version or i make something wrong?
I use this unity version:2019.4.28f1
You need to move any files you want to use in your game into the Assets folder in the project folder.
wdym native input plugin?
Any custom input plugin or library with (almost) 0 input lag
use the new input system?
No, the new Input System still has a lot of input lag for a Rhythm-based game
I need a library or plugin which is extremely accurate
i mean if you use the event based approach there really isn't any input lag
I still prefer a custom library tbh
why though? you can't really get more optimized than this
if you really want a custom library, i am sure there are plenty on the asset store. i'm still interested on how you get any input lag
how many ms do u get?
it's a beat based game, more or less 10ms make the difference
plus, unity input manager verifies the input every frame, which isn't enough
That doesnt make sense. Your main game logic is not even running until the next frame is calculated. So I'd argue you're much more frame dependent than on input latency. And I'm getting far less than 10ms with the input system.
Yes and I don't want it to be frame dependent since it's not accurate for rhythm games which have very specific needs
The new InputSystem is event-based and you can access the timestamp at which the control was actuated (not when the callback was called) as a double in seconds since startup, so the API is definitely capable of providing the precise low-level information a rhythm game needs; I don't know whether anyone has profiled exactly how accurate those timestamps are, though.
If true, I have to check that then. Hope it gives me the freedom I need to change anything I need for my game, thank you!
Hi! I'm trying to use the New Input System, and I want to make the "A" and "D" keys eventually map to Player Rotation on the Y Axis.
So "W" and "S" will Map to forward and backward motion, while "A" and "D" will handle rotation (I know it's an archaic movement system)
How do I best design the input system to accommodate this?
I started out with what the usual tutorials tell me to use: The Move Function being on a 2D vector and taking in four keybinds for Up, Down, Left, and Right.
But instead I want to design it so instead of mapping Move to Four Values, I want it to map to 2 values, and I want Rotation to also be on Two Values. How do I set that up in the Input Manager?
Instead of this, I want Move to have 2 binds that I can access, and Rotate to have another 2
I'm assuming Vector2 is the wrong Control Type
To set that up you selected "Add 2D Vector Composite" for Move, right? For the 2-directional equivalent you would just select "Add 1D Axis Composite" instead.
You should be able to leave the control type as "Any" and it will figure it out, but "Axis" would be the correct one.
That's how it should appear, yep.
Thank you! Really appreciate it
Oh one other question about that, when I read the value, instead of context.ReadValue<Vector2>()
Should I do something like:
context.ReadValue<int>() or something?
or float rather
float, yep.
that seems to throw an error telling me I can't convert a vector2 to a float
Oh whooops absolutely my bad sorry
lol I was looking at an error for my function call still calling for a vector2 xD
Hello, I am attempting to get the new input system to work with an off brand (MOGA XP5-A) gamepad that is recognized as a joystick HID. In the Input Analysis Debugger I am receiving updates from the device just fine, however the Input System itself doesn't seem to pass on any of the actions to my code.
The controller does nothing in game/editor despite being set up similarly to my X-Box 360 controller (and mouse and keyboard) that works flawlessly. I would prefer not to have to reconfigure the HID as a Gamepad. Strangely on an android build of the app using the same controller in bluetooth mode connected to my phone, it registers inputs just fine, it's only in the editor and x64/x32 pc builds that the input is not recognized. Anyone have experience with such a problem or working with Joystick recognized HIDs?
As you can see in the screenshot, the stick control of the controller is reading properly in the Input Analysis Debugger with Y at -1 and Down at 1.
Thank you.
Hey, I'm trying to get smooth rotation for a top-down shooter using the new input system. I've found a way to make the rotation smooth in the Unity editor, but when I go and build the game, the rotation becomes jittery. Also, I have it set up to use both mouse input and the right joystick on a gamepad, but for some reason, rotation with the gamepad isn't working. Does anyone know why it is jittering in the build or what is causing the gamepad to not work for rotation? Here is the link to my whole script: https://www.toptal.com/developers/hastebin/cunetigita.csharp
@pliant copper Video of the jitter could be helpful
Where are you calling Aim?
FixedUpdate
Is interpolation enabled on the rigidbody?
Yes
Here's my movement function. I also attached the entire script in the original message if you need to see anything else.
Doing that requires me to unfreeze the rigidbody rotation, which means the player will rotate if it rubs up against any corners or walls.
Also, the rotation is still jittery in the build. I have no idea what's going on anymore.
how do you handle "GetButtonDown" when transitioning from old input system to new? is there a way to not use a variable (like the old one)?
Mouse.current.leftButton.wasPressedThisFrame
it also exists for the keyboard
the mouse and the keyboard are two separate classes now
@rugged raven
Attempted to access a missing member???
void OnSprint(InputAction.CallbackContext context)
{
if (context.performed)
{
isSprinting = true;
}
if (context.canceled)
{
isSprinting = false;
}
}```
Any idea why the event handler on this would not get removed / action stays around when exiting play mode in the editor?
If I exit play mode, and then enter again, the event handler (execute here) is firing twice, and then three times if I exit again and play again, etc etc.
public class AbilityMotor : MonoBehaviour {
public List<Ability> abilities = new List<Ability>();
Animator animator;
void Awake() {
animator = GetComponent<Animator>();
}
void Start() {
abilities.ForEach(ability => {
var action = ability.actionReference.ToInputAction();
action.Enable();
action.started += _ => ability.Execute(animator);
});
}
}
nvm got around it like this, still weird though
void Start() {
abilities.ForEach(ability => {
ability.actionReference.action.Enable();
ability.actionReference.action.started += HandleAction;
});
}
void OnDisable() {
abilities.ForEach(ability => {
ability.actionReference.action.started -= HandleAction;
});
}
void HandleAction(CallbackContext ctx) {
abilities.ForEach(x => {
if (x.actionReference.action == ctx.action) {
x.Execute(animator);
}
});
}
I am having a problem where when I try to switch from the new input controller to the old one, my unity closes and re opens and it is still the new one.
All my unity events are invoked perfectly fine in linux and in the linux editor, but they don't appear to work on windows or the windows editor
anyone else had this issue?
Maybe check this reply
https://forum.unity.com/threads/inputaction-callbackcontext-gives-missing-member-error.973806/
Anyone able to get virtualmouse working in 2021.2? Trying out the gamepad mouse cursor sample but the cursor disappears and stays locked in the same spot. Verified that it works fine in the 2020 LTS.
So I guess 2020 LTS is using input system 1.02 and 2021.2 will use 1.1
Kinda strange that buttons clicks will work, just not joystick movement.
Never seen that. Show some screenshots of your setup?
I'm trying to create a game that has a local multiplayer mode that uses controllers.
I want to make it so haptics can play for each individual player. The problem is, I'm not sure how to get a reference to the gamepad of a specific player. I'm not sure if Gamepad.current is relative to the player that the line of code is in or if it's relative to all players.
If it is relative to all players, is there any way for me to get a reference to the gamepad via the PlayerInput class without knowing the index of the device? If not, I also have an OnDeviceChange callback that can get a reference to the current device, but I'm not sure how to check if that current device is a gamepad or not, because I also have keyboard/mouse support.
Can anyone help me find a way to get a reference to a specific player's gamepad?
Player input has a devices property
Yeah, but it requires me to know the index of the device. It doesn't just give the current device.
Wdym? You get it from the player input component for that player
It is an array. It requires me to know the index of the gamepad to get a reference to it.
Just iterate over all of them
Any that are gamepads, do a rumble for
Ignore any that are not
Yeah but I'm not sure how to check if an input device is a gamepad or not
if (theDevice is Gamepad gp) {
gp.Rumble(); // this is pseudocode
}
Something like that probably
Oh, I didn't think to use 'is'. Thanks so much, it's working perfectly now!
On single click, my unity is reading as 2 clicks. How do i solve this?
how are you detecting the click?
InputAction.thingy.click.performed += _ => method();
Do you have a press interaction filter on the action with the trigger behavior set to press only like this?
how can i achieve key repetition if i hold a key, but using the windows parameters (where you can set the key repetition speed) ?
Anyone got bugs on macos where inputs are not being recognized?
Im really not sure if it’s possible with the input system itself but maybe this can help ?
https://docs.unity3d.com/ScriptReference/MonoBehaviour.CancelInvoke.html
Look at the invoke repeating example
Yeah that's repetition but the speed is chosen by the game
Not à big deal for me tho I guess I'll go for that
so I am having an issue with the new input system where my xbox 360 wired controller not spawning the player prefab. I can see in the console log that the xbox 360 was detected. Any tips or advice to get this xbox 360 controller working?
You can select the repetition time inside the InvokeRepeating()
Hi, I'm kinda new to the new input system. And I was wondering if someone could help me figure out how to pull of a basic UI/Button-to-function() operation with it.
In the package manager, on its page, there is a button to import examples as well. They show different ways of handling input.
I'll take a look. thanks.
Thanks. I'm great at dumb questions.
Anyway while the examples shed light on the input system itself, how do i make it work for a simple thing like a UI button, to activate a function (I'm talking about menus)
Do I have to create separate actions for every menu item?
Right now most of the examples feel like I'm trying to kill a fly with a giant hammer.
Okay
For the UI you would usually use something like Unity's EventSystem. It has an inputmanager which is the only thing that talks to the inputsystem, and the eventsystem takes that input, uses raycasts to figure out what button you're clicking on, and the button sends callbacks for its effects.
Are you asking if you can have multiple subscribers to the events on the InputActions?
Yes
not a problem
that makes sense.. Let me get this correct, In the new system the raycast has to be handled manually since it depends on how the input was configured in the first place?
Ok so I made the input system asset. Then I create a script to 'recieve' the input and generate raycast on the canvas elements?
Unless raycast is happening all the time, and i wait for the 'click' event first, and then check where the raycast was happening at the time, and activate the corresponding element?
The EventSystem works just fine in the new input system. All you have to do is switch your StandaloneInputModule out for an InputSystemUIInputModule
you don't have to do any manual raycasting or any input handling of your own at all for that
I think the Input Module is what @hidden laurel was referring to when they said "inputmanager"
but for some reason the buttons i placed on the canvas dont recieve clicks
if i set a button as the first element, it does highlight. if i press enter, it works (activates it). I can also navigate with the cursor keys. But the moment I try to click, everything loses highlight, no matter which button it is. And then nothing activates again.
I'm using the new InputSystem and I'm having some trouble with _playerInput.currentControlScheme
namely it returns Null when the "Default Scheme" of my PlayerInput component is set to <Any>
When I change it to Keyboard&Mouse, _playerInput.currentControlScheme now correctly returns Keyboard&Mouse
But.. my controls don't work any more! 🙀
anyone know what's going on?
It seems that it's related to fact that I have two PlayerInput components
one for the Player object and one for the GameFlowManager object
Seems that you can only have one PlayerInput? How do I pause my game then?
Is it a good idea to have two Player Inputs?
Is there anyone here?
i personally don't recommend the playerinput component. just let the c# class be generated and hook into an instance whenever you need
Yeah to expand on that I'd only recommend PlayerInput if you're using it with PlayerInputManager and you're making a local multiplayer game
of course they are not by default
i was laughing at the "are" but now i see i was just reading it poorly
clap clap
This is a bool, is there way to have it be set to true when pressed, but then back to false upon lifting finger off key?
if (context.performed)
{
pressedInteractInput = context.control.IsPressed();
}
If there's an IsPressed() method I would assume there's something similar for detecting when key is down/up.
if (context.started) pressedInteractInput = true;
else if (context.canceled) pressedInteractInput = false;```
should work
it may depend on how you've configured the action
It's using unity events
I'm just trying to make it so I can have generic "interact" key while on the player controls, which then could be paired with several different bools in order to make different things happen.
i.e. If in the shop trigger and press interact, then switch to ShopControls input, etc.
if i do performed then canceled, then it's false -> true -> false lol
I guess that's fine?
Might be buggy though
yea 😦
If anyone has some insight on this, i'm all open. I am trying to make a generic/global "Interact" key, that I can then pair with any bool to do different things. Examples:
if interact && inFrontOfDoor
if interact && atBoat
etc.
I am using Unity Events, and I currently have interact set up as a button (mapped to E specifically). Need a way for that when button is pressed it's true, so I can do whatever interaction, and upon release it's set back to false.
yeah but how's the Input Action set up
Like the interactions?
everything
how is the INput Action set up. The value/control type. The bindings. The interactions
yeah get rid of the interaction
with no interaction you can use started/canceled and it should work fine
because it was the only thing i could get working
but i tried everything.
I ended up getting a shitty method working like this, with the interaction:
private void OnTriggerStay(Collider other)
{
if (other.CompareTag("Player"))
{
openStoreText.SetActive(true);
if (!isStoreMenuOpen && InputManager.Instance.pressedInteractInput)
{
isStoreMenuOpen = true;
print("Open Store");
//Switch to StoreControls
}
}
}
another option is just:
bool interact => interactAction.ReadValue<float> != 0;```
Ok, going to try again, with no interactions.
Which is how i do all my other inputs as well, just swear it wasn't working.
I've confused myself so much now that I don't even know how to get a reference to the interact action using interactAction.ReadValue<float> != 0;
Im not using a generated c# class
Shouldn't it just be context?
bool interact => context.ReadValue<float> != 0;
(doesnt work tho)
Uh well if you're using PlayerInput it'd be something like:
InputAction interactAction = myPlayerInput.actions.FindAction("ActionMapName/Interact");```
Ah FindAction
and then in this case you wouldn't be using any callback methods at all
you can just have
bool interactCurrentlyPressed => interactAction.ReadValue<float> != 0; as a property in your class
and call that whenever you need to know if it's currently pressed or not
Of course interactAction would need to be a member variable, that you set in Awake() or Start()
right
Hey, i have this weird issue where my controller controls are working but not my keyboard ones
d pad left works, but not r
no idea how much more info to provide
Ok I must not fully understanding, just getting errors.
what errors
show the code and the errors
Getting them one sec.
[HideInInspector] public InputAction interactAction;
private bool interactCurrentlyPressed;
public bool InteractCurrentlyPressed
{
get => interactCurrentlyPressed;
set => interactCurrentlyPressed = interactAction.ReadValue<float> != 0;
}
private void Start()
{
interactAction = playerInput.actions.FindAction("PlayerControls/Interact");
}
Think I'll just remain with the way I have it functioning at the moment, and see how this pans out with future interactable things.
Feel like I've been heads down and just confusing myself for the past 3hrs with no breaks.
Could anyone help, I've had a look online but can't seem to find anyone confirming, does the new Input System work with the IBeginDragHandler, IDragHandler, IEndDragHandler for UI?
Yes it works with the event system and all features therein
Thank you so much!
Yeah not like this.
Just
public bool InteractCurrentlyPressed => interactAction.ReadValue<float>() != 0;
you don't need any setter at all, or a backing field
yeah but i still get the same error.
you forgot the ()
and so did i
damn
thanks 😦
Ok so you're right (of course :P) Praetor, this works. @austere grotto
private void OnTriggerStay(Collider other)
{
if (other.CompareTag("Player"))
{
openStoreText.SetActive(true);
if (!isStoreMenuOpen && InputManager.Instance.InteractCurrentlyPressed)
{
isStoreMenuOpen = true;
print("Open Store");
//Switch to store
}
}
}
But now i want to see if I can use OnTriggerEnter, rather than Stay
I had this as a workaround for my solution.
Well, no, guess it wouldn't work on Enter, since it would need to constantly check.
i'd do the check in Update
ok, so when I was doing that i was getting like 10 debug prints
set another variable true/false in OnTriggerEnter/Exit
But maybe now it will be different
and then it's like this in Update:
if (isInRange && InteractCurrentlyPressed) {
DoTheThing();
}```
Can anyone help me with the new input system? I am trying to get a character to move in the negative and positive direction as well as jump
The only thing that seems to be wrong is the fact that my script component for the character is not letting me edit the movement/jump speed, which is not allowing me to test if it is actually working correctly.
Hey there I have a question about using the Input system. So if I create a C# class from the input asset file, and I manually create an instance of that class inside a MonoBehaviour (hook up the listeners and all of that) is it safe to instantiate different Input objects(?) on different MonoBehaviours or, should I create a single input object and have a reference to that on all my MonoBehaviours?
//Should I do this on each Component (is it safe?)
class Component: MonoBehaviour {
InputClass inputObject = new InputClass();
/*Set the listeners in OnEnable and OnDisabled*/
}
//Or is this better
class InputEvents {
public static InputClass InputObject = new InputClass();
//Private constructor, etc...
}
class Component: MonoBehaviour {
InputClass inputObject = InputEvents.InputObject;
/*Set the listeners in OnEnable and OnDisabled*/
}
It is safe to create multiple instances yes. That doesn't mean it's a good idea necessarily
It may actually be necessary to do that in some cases, for example if you want to support local multiplayer, it's probably best for each player to have their own instance.
The advantages of sharing an instance are:
- Disabling or enabling a particular action or action map will be able to affect all scripts that are sharing that single instance
- performance/memory usage will be better
I see
Disadvantages of sharing an instance are:
- you need to centrally manage that instance and get a reference of it to all the scripts that are interested
- Disabling or enabling a particular action or action map will be able to affect all scripts that are sharing that single instance (this might be a disadvantage for you too)
There seems to be no mention unity's docs about such a case (which shouldn't be that uncommon I think) so I decided it was best to ask
Well in a case where you are reinventing the Player Input component you can probably use the component as a reference 😛
I would use that, but the thing is events on a single game object will be fired whether I want them or not, so for example I want to have different Components handle different inputs in the same GameObject. So if I disable the component that handles jumps, it won't jump, but if I use the PlayerInput/PlayerInputManager the event will be fired regardless and the action will be executed.
I personally decide the state of the input in the input event, but execute it in the usual Unity loops
You can disable the jump input action or the action map containing it instead of the component that jumps
but - are you doing local multiplayer?
if not, there's not really a great reason to use PlayerInput anyway
Well I'm trying to use as little ifs as possible, so by doing it this way there is no if (not mine at least), probably not saving any performance by doing it, but if DOTS is ever finished it would be easier to port I guess
It's not premature optimization though, it mostly that I've found it easier to wrap my head around logic than a bunch of ifs in an update loop
Branching logic is not a sin in DOTS in the same way it is in shaders 😄
nope
I would personally be more worried about the input implementation controlling the logic of your components
I think the chance of switching input systems is a lot more real than the port to DOTS.
It's easy a single game component handles jumping, when you jump the physics call back will detect you're not grounded so it will enable or disable the jump component
Disabled component: no jump; enabled: jump
Yes, and input implementation messing with that doesn't seem ideal to me
could you elaborate
Hi, so i have some code where i need to feed input, but how? Cause it is class not a Monobehavior that can be on player.
public class CharacterControllerPrediction : ClientPrediction<CharacterControllerInput, CharacterControllerState>
{
private Vector2 _move;
private Vector2 _look;
private bool _sprint;
private bool _jump;
private bool _analogMovement;
protected override CharacterControllerInput GetInput(float deltaTime, uint currentTick)
{
return new CharacterControllerInput(_move, _look, _sprint, _jump, currentTick, deltaTime);
}
public void OnMove(InputValue value)
{
MoveInput(value.Get<Vector2>());
}
public void MoveInput(Vector2 newMoveDirection)
{
_move = newMoveDirection;
}
}
If you do figure out what the issue is and it's not on the list, or something particular helped troubleshoot the issue, please let me know so I can amend it 👍
For the 4th time (in this project, i've had more in others where none of the fixes work here), I have had this issue. my unity events are only being invoked on one of my player inputs, the other one only works with a controller even though i have it set up this way:
for reference, this is the one that works
i noticed that they have seperate 0 and 1?
can i not have 2 inputs that get input from 1 player
i pressed some random buttons on other gameobjects and fixed this- unity please fix this mess of an input system, or at least make it consistent
I don't use PlayerInput myself, but I know that each PlayerInput object is intended to represent one player, so if you have two PlayerInput objects that's essentially telling the game that the inputs on them are for two different players. It wouldn't surprise me if (for example) you need to tell the system that a second player has joined in order for the second PlayerInput instance to start taking input? I don't know specifically, though.
It also wouldn't surprise me if it avoids pairing automatically pairing multiple PlayerInput objects with the same control scheme, even if they both have it as a default (since most games would not want multiple players per controller); I think if you want more than one player on the same KB+M you need to explicitly tell it to do that, it won't attempt to do it automatically.
yeah, you are right, i need to spawn other PlayerPrefab as Others players
Guys, could you please help me out... i tried using the input system, and everything works except for the Space button, which, in my case, is being used for jumping
Sorry, this is my first game aaaaand i dont really know how to fix things, even if it might be easy for you guys🙃
Use ReadValueAsButton() instead of ReadValue<bool>()
someone please tell me what this means
MissingReferenceException while executing 'performed' callbacks of 'Player Map/Fire1[/Mouse/leftButton]'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
You have a callbcack function hooked up to your Fire1 action
And it's throwing a MissingReferenceException
meaning you probably are trying to do something with an object that was Destroyed
THAT'S THE PROBLEM IN ESSENCE .... I have destroyed my object.. in ondisable i have unsubscribed from ALL input functions... then CREATED A NEW prefab (respawn).. the problem is the new one now... it doesn't refrence ANY OF THE THINGS IN IT .. like when I refrence an animation or a control ... it doesn't use the one related to the prefab I dont understand how this is happening
show your code
what part would you like to see
private void ShootPrimaryUp(InputAction.CallbackContext ctx)
{
if (playingUIPlayerMenu.isOpen)
{
if (animator.GetBool(launchingGrenadeHash))
{
animator.SetTrigger(throwKeyReleasedHash);
//throwingGrenade = false;
//grenadeTimer = 0; // done in animation coding
//StartCoroutine(bss());
}
}
}
this is the function related to input manager
the whole scipr
especially all the subscribing and unsubscribing bits
it is over 1600 lines
and how things like animator and playingUIPlayerMenu are assigned
that's ok
Put it on a paste site
I know how to skim through code quickly don't worry about it
that was the problem I unsubscribed only to when performed instead of started...
there ya go
Trying to set up gamepad support - it thinks the PS4 left stick is a right stick
It also thinks the right stick is a d-pad
If I try to use a normal USB controller, Unity doesn't seem to pick it up at all, even if I use the generic "left stick" mapping
Anyone knows why the mouse input doesnt work when updating to 21.2?
yeah i am at a loss why the mouse input isnt working... its all vector zero
is there any way to fix lagging in a Unity game for 8000hz polling rate?
or maybe do something about it
or the question is can Unity even handle that much data?
Where did you get that code from? 🤔
public override void OnEnter() {
_timeInState = 0f;
Context.Animator.SetBool(Context.IsRunningParameter, true);
Context.MovementInputAxis.canceled += ExitCallback;
Context.RunInput.canceled += ExitCallback;
Context.RunRampStart = Context.Speed;
}
public override void OnExit()
{
Context.Animator.SetBool(Context.IsRunningParameter, false);
Context.MovementInputAxis.canceled -= ExitCallback;
Context.RunInput.canceled -= ExitCallback;
}
It seems like MovementInput is blocked by RunInput which makes little sense imo
MovementInputAxis.canceled is never called, but RunInput.canceled does get called
The input debugger registers the keypresses though.
MovementInputAxis is a Vector2 Value and RunInput a Button
Also, MovementInputAxis events work perfectly fine as long as RunInput is not being held it seems ? really confused about this
How would I do this with the new input system
I already have the action reference hooked up
Both of the conditions are the same though.
The else if is never gonna work
Sry it was different but Emmy attempt to get it working with the new input system didn’t work so I copy and pasted it back and forgot to change it
Main issue is I’m using the new input system and my code is using the old
Well, how was it supposed to be then?
I made the code for an old project with the old input system
I’m adapting it to work with the new
Well, what was the original code?
This is my original code
As I said, it wouldn't work in either of the input systems
This is the original and works with the old system I’m trying to adapt it to the new so how would I also I have the referenced action added now so how would I read it
I know this works ^ but I’m trying to change it to the new system since my project is set to that and the 2 systems aren’t compatible
Hello! I'm trying to use the Character Controller for a basic movement system and I'm getting weird jittering and drifting motions and the object is hovering off the ground. I've looked around on the forums but none of those solutions (zeroing y axis, changing from FixedUpdate() to Update(), changing skin width, etc.) have worked. How can I fix this (preferably in a simple way, I'm pretty new to Unity)?
Well, you'll need to learn how the new input system works. Check the link that PeppeJ shared. If you think that someone is gonna write that code for you, that's not how things work around here.😅
Not asking for someone to write my code all I need to know is what would I put in the if statement to signify that the button has been pushed also the site that PeppeJ shared is hard to comprehend and I’m pretty new to this
I’m trying to get a simple system to work but I have no clue what to put in the if statement
On the link that he shared, there's the Migrating from the old input system section that sows exactly what replaces MouseButtonDown/UP.
Also, if you have so much trouble, why not keep on using the old input system?
Open XR doesn’t support the old system sadly
Or in a capacity where you don’t have to spend 10 hours rewriting a ton of stuff
Then you've gotta learn it. If manual doesn't do it, look up some youtube tutorials. I'm sure that there are plenty that explain how to migrate from the old input system.
Most of the tutorials are 30min + so I don’t really have time for that rn
Also where’s the link I can’t find it
The link that PeppeJ shared. There are sections of the manual on the left side.
Oh I don’t see a left side on iOS
Could you copy that link and send it hear
Nvm got it
Doc doesn’t mention anything about adapting of statements though
what statements?
I’m still trying to adapt this
The exact thing I linked does exactly what you asked for. It tells you whether or not a certain button was pressed
"Use this code:
Keyboard.current.space.wasPressedThisFrame"
if(Keyboard.current.space.wasPressedThisFrame) { }
K thx
He's checking for the mouse button though, not keyboard.
But it's a similar concept.
Also I’m checking an XR controller
If you don't have any special interactions set up on your input action, you will generally want to do this by subscribing to the action's started and canceled events (corresponding to button down and button up respectively).
How would I do that
If you're not sure how to subscribe to C# events that's more of a #💻┃code-beginner question. Though the input system docs posted above will have a lot of examples, since it uses them a lot.
I’m mainly making a game for art not for adding gameplay so I don’t know much code apart from simple things
Could you give me an example how to get this working
I’m not trying to become the next big Programer I just want to get to the part where I get to make environments
That's fine, there's no shame in being a beginner. But to make a game in Unity you will need to either learn to code or collaborate with someone who already knows; you won't be able to get anywhere by begging for scraps of code on discord (if you'll forgive the idiom).
If you don't want to learn C#, Unity's Visual Scripting is designed to be easier to get going with for people who are new to programming.
All I need to do is get this one thing working then I’ll be out of your hair I’m not really even making a game just a environment for vr I’ve already spend an hour trying to get this to work and nothing I can find is related close enough or to complicated
There’s so many forms online that say how they do it and it never works
I thought this would be a simple thing just to register a click from and input but it’s not apparently and i don’t have the time in my life to learn c#
I’ve already abandoned so many projects because I got stuck on apparently simple things and I don’t want this to be another one of those
Then don't abandon it; put in the time to figure it out, or join a team with other people with different skills who will support and work with you. If your response to a problem you hit is "hoping some random stranger will solve it for you" then that's essentially the same as giving up.
Then try one solution/tutorial. If you face issues that you don't know how to solve, ask a specific question in the relevant channel and present what you have tried. People will see that you are ready to put some effort in it, and will be more likely to help you.
I did watch a tutorial this is that specific question
Unfortunately this isn't really much for us to go on? As you've said, you've tried most of the common remedies already. My advice for how to track it down would be to simplify things as much as possible; start with a trivial charactercontroller that's just moving in a line through a void at fixed speed, then slowly add features from your movement system until the problem starts happening. Knowing what's triggering it should be a big help in figuring out why, and how to stop it.
A tutorial on what? Converting from old input system to new one?
For the grappling
That doesn't sound relevant to the new input system at all.
Unless they use it in the tutorial..?
No old system was used
I just need to know how to trigger the event to grapple with the new system
In something I can understand
Well then I guess I give up on this shitty project
How the fuck I suppose to learn how to do a simple task if to response is learn how to do it tutorials are no help since I don’t understand how most of the stuff works and how to imply it and everyone uses different methods
If you don't understand a tutorial it means that you're missing some underlying more basic knowledge. Figure out what it is that you're missing and go learn that. Follow the chain of missing knowledge until you get to the most basic thing that you can understand and the go back the chain until you eventually can understand everything you need.
Hello, I have a character controller based off the FirstPersonController starter asset, it's been working fine but recently mouse look has gone haywire. Looking around using Pointer[delta] in the input system results in strange delta values that reset to zero and cause mouse skipping. My code still very much resembles the initial starter asset (Camera rotation in late update (really no changes from initial starter asset)) and I think the issue somehow lies in the actual input system. I have a recording of the input analysis debugger showing the strange delta vector2. Anyone know what might be happening?
This isn't a framerate issue as well, this is running at a stable and solid 60FPS. Occurs both in editor and builds.
I just created a default project and imported the same FirstPersonController starter asset and tested, it didn't have this mouse input problem the first few times I tested. I just tried again, just to look at the mouse delta again in the working project and it as well started to have this same issue leading me to believe this may really be a problem with the input system but I do find that hard to believe. This is on 2021.2.1f1
In the meantime I have switched to enabling both the old and new Input System. Utilizing Input.GetAxis("Mouse X/Y") instead completely fixes the mouse stuttering issue, leading me even more to believe this is a problem with the new Input System.
Thanks a lot man...
On a Mac (for example) the tab and capslock keys aren't detected. This bug has been known about (by Unity) for about a decade, so far as I can tell.
it's not needed anymore anyways
Hi everyone ! I hope you are all good 🙂 I am doing a little mobile game and I did a grid movement code so that my character is moving poitn to point. I have a little problem, I would like to move with clickables buttons, so I need to redo my code to swich form keyboard input to buttons. If someone have the answer this will be fantastic ! Wish you all a great day 👍
make a ui button and subscribe to the corresponding events
So I need to make a different class for each the direction right ? 🤔
In order to setup them in unity
wdym?
seems like you want a ui dpad or something. depending on your ui element, that one might already have arguments what direction was pressed or events for each direction or smth else. how you have to handle it in the end really depends on your ui element
I just have 4 differents buttons for left, right, forward and backward
well then just subscribe to those events
Ok I will try thanks !
Probably same bug. Don't know. Unity is full of caveats like this.
exactly how would you do it now? Please show code. Not just "use new input system".
use the new input system
like you should be
"should" it's not finished and despite their claims, is not production ready, and you can't do simple things like get tab input with it, with any more certainty than with the current system.
it is finished and very much production ready
Do you work for, or are you otherwise paid by Unity?
Ok, you can tell the truth whenever you like. Like the shortcomings of the new input system for touch (mobile), how it messes with Cinemachine, how it's not consistent across Windows devices... what else?
we have not had any problems with it and it sped up our workflows immensely. wtf do you want
that you not make sweeping claims about its state. You have your evidence and seemingly none other. There's a myriad of issues with the new input system. Denying that helps nobody.
The only "solution" I came up with for tab and caps lock problems was to use double tap on shift like on a phone, and triple tap of spacebar for tab, and teach users about that. I know... it's ridiculous. But that's what I had to do. I hope this is somewhat helpful.
Ok
there might be, but the ones you specifically mentioned are not even relevant to you. e.g. 'shortcomings for touch'
I'm not sure how you come to this conclusion, now why.
there's no tab in touch controls
again, what has that got to do with anything? There's many problems with the new input system. On Mac, Windows and Touch devices, both iOS and Android.
that's simply not true. if there are, they are niche problems. if there were, it would not be production ready and we would've encountered them
If you haven't come across any show stoppers with the new input system, I'm happy for you. Denying that there are many others experiencing real problems that really impact them, and many of these have been admitted to by the devs of Unity, is just bizarre levels of confirmation bias.
Production ready 😂
i'm not denying it. i'm just saying that in the case of a simple 'getting tab press action' there won't be any. i am sure of it
so it might be worth a try
this is probably a correct assumption. I've seen all sorts of weirdness with it. There's something dis-harmonic about its polling, too, that causes flutter.
Hey hi! Does anyone know why Unity detects a Gamepad as a Joystick? If so, how could i remap that, since the inputs that it registers do not match what is actually pressed on the gamepad.
🙂
The only things recognized as a Gamepad are pretty much XBox and PS controllers as far as I'm aware.
Any recommendations on which brand to get? Or only native PS4/Xbox controllers?
I believe only the on brand controllers are natively recognized as Gamepads. I have an off brand xbox licensed controller (Moga XP5-A) and it gave me problems as a Joystick/HID
Getting the input system to recognize it as a Gamepad is possible but a lot of work I believe.
I just found an incredibly easy work around!
You can emulate an xbox controller and Unity recognizes it as such (cause windows does) 🙂
https://www.youtube.com/watch?v=KTMq3vARsko
I had a cheap old 10$ game controller laying around for a while and, recently I decided to use it. However, when I plugged it in, it doesn't work in any game. But it was recognized by Windows. Then I wondered how can I make it work? In the end I figured out that it can actually be converted into and Xbox 360 controller by using XOutput and ViGEm...
Thank you for the info!
Oh, this is a neat work around.
Anyone know what might cause input to be vastly different in a build compared to the editor?
On default settings
Feels like there is mouse acceleration or something because the character whiplashes around the axis
Something framerate sensitive in your code probably
Regarding the new input system, I've been trying to make two keys, one for positive (1) and another negative (-1), I've set the "Action type" to "Value" and the "Control type" to "Integer" with two keys for negative and positive.
How can I read it correctly in code?
It is meant to be like a "left and right" cursor where on my code I'll use as "-1" and "1". Any suggestions or advice would be highly appreciated.
What composite are you using?
I considered making two buttons as a "easier way" but I think an int would be better :P Do you think I should follow by using two buttons?
oh okay I discovered my issue
it is working now!!! I was reading the value through a float function on the code, so it was returning an int on a float function, which wasn't quite okay haha
I set the function to be an int so it works normally now :)
I believe MS and Sony both have strong incentives to provide great value and to not screw things up, so I'm not sure if thirdparty controllers are a good investment unless you are going for something more premium.
Whats the way to do mouse look in 2021.2? The one I used previously doesnt seem to be working anymore
How can I download Input System 1.1 or 1.2 ? I only seem to have access to 1.0.2 and previous versions. Unity 2021.1
If Unity doesn't offer those versions to you in the Package Manager that means they haven't confirmed that they're compatible with the version of Unity you're on. If you want to install them anyway, the easiest way is to edit the version number listed for the package in Packages/manifest.json.
Alright, thanks
am i the only one with a bloody mouse problem with 2021.2? xD
How to read from the third binding values?
hi everyone, I'm not sure if I've done something wrong, but if I'm using the right trigger for acceleration, should the action type be Value? I've got it set up as follows, but this only registers a single input (i.e. holding down the trigger does not cause any movement beyond the first method call
or should I move some kind of check for this input into my Update() method so it's called continuously?
Hello all, has anyone else experienced a strange issue with the new Input System and android where suddenly on screen controls just stop working? I have a game with on screen d-pad for movement and various buttons for accessing in game menu, confirm selection, cancel, etc. While my player is reading through text, randomly the "advance" or "confirm" button will just stop responding all together. Only way I've found to fix it is to either leave the game (just go to home screen) or swipe down from top to open the notifications menu. After doing this and coming back to the game, it works just fine, all buttons are responsive, etc. I've done some debugging and it just seems like the events are not getting fired for some reason or another. I tried updating Unity (started with 2020.1.17f1 and upgraded to 2021.1.27f1), upgrading the Input system, rebuilding my input actions map. Nothing seems to fix it.
(apologies for the long post) but I'm at my wits end trying to figure out what's going wrong and why leaving/coming back fixes it
It should be Value/Axis and yes the most straightforward way would be to read it in Update instead of going event based.
OK great, thanks! Just so I know I'm looking at the right syntax, should it be something like:
void Start()
{
var accelerateAction = InputAction("Accelerate");
}
void Update()
{
if (accelerateAction.performed)
{
OnAccelerate();
}
}```
No
It should be something like
float accel = accelerateAction.ReadValue<float>();
You'll get a number between 0 and 1
Your start code will also not work
Ah ok, I need to do some more reading I think...at the moment I have acceleration and reversing in two separate value actions, rather than a single axis
because it needs to be an InputAction rather than a var?
Based on your code and this question I recommend taking some basic C# tutorials first to get an understanding of how variables work in C#. The new input system is going to be quite hard to work with without a solid grasp of those basics.
It's fine to have them on separate axes.
Yeah definitely! I mean I've just finished Create with Code 2 on Unity Learn, but for some reason this new input system is tying me in knots lol
The new input system is great but it does require intermediate knowledge of C# so it's not ideal for beginners
There has definitely been some feature creep on this, my first unity project 😅 I will persevere though, thanks for the help!
well found the problem myself, the bloody mouse input doesnt have values if you are trying to get it in FixedUpdate, it works in Update
so what code shall i put it update?
my code for it is : cs defaultInput.Character.Sprint.performed += e => Sprint();
and its in awake
soo?
any ideas?
Add some logging to this so you can get an idea of whats actually happening
e.g. add a log inside Sprint
did that
and?
but only when i press ctrl it log
well are you double tapping e?
if you remove the ctrl binding does it work/
it should work for both tbh
not sure why it's not
Try it in a build
maybe it's just an editor issue
i just add new action named sprint 2
I have the following issue :
The cancelled event is called for a Vector2 Value input action when it goes to 0,0
However pressing e.g A and D at the same time still results in a 0,0 vector without actually cancelling anything
how would i make it like not do that ;_;
I want the cancelled event to only be invoked when no keys that modify the axis are being pressed
Isn't that actually the behavior that you just described?
Are you saying canceled is being called when both buttons are pressed?
Ok I guess it just gets called whenever the resulting vector is 0
Is this bad for your game logic somehow?
Looks like you're have to work around it
Or switch to a separate action per direction, instead of a composite
Hi, could someone please help me debug this error? I've confirmed that the method described in the error - PlayerControl.OnRoll - is definitely set up and saved in the Action map, and other actions are working so I'm a bit stumped. I tried changing the method to public but that didn't seem to do it either.
MissingMethodException: PlayerControl.OnRoll Due to: Attempted to access a missing member.
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <f98083cbc97e4fa0a4ef2f523feff5e1>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
Are you using the PlayerInput component?
Yes, it's attached to my player object
can you show screenshots of how that's set up?
Especially anything related to the Roll action
ok now show any scripts that are attached to this same GameObject?
can do!
and here's the code for that OnRoll method:
public void OnRoll(InputAction.CallbackContext context)
{
float axisValue = context.ReadValue<float>();
if (axisValue > 0f)
{
Debug.Log("Right roll!");
playerRigidbody.AddRelativeTorque(Vector3.forward, ForceMode.Acceleration);
}
else if (axisValue < 0f)
{
Debug.Log("Left roll!");
playerRigidbody.AddRelativeTorque(Vector3.back, ForceMode.Acceleration);
}
}
I know that if statement is probably superfluous, but I don't think that's what's throwing the error
When you use "Send Messages" mode, your method is supposed to take an InputValue parameter
not a CallbackContext
ahhhh gotcha
is there a different method to read an InputValue other than InputValue.ReadValue<float>()?
all I see in the Intellisense is Get<>
Should be .Get<float>() iirc
that's the one! Should have tested before asking really 🙂 thanks for the help!
that's the last control sorted! now I just have to figure out that continuous input thing and I think I've actually got a control system implemented that isn't a bloated mess 😅
exactly the workaround I wasnt wanting to do 😝
learning and transitioning to the new player input system, how does one do the following?
public void OnSecondary(InputAction.CallbackContext context)
{
// Where the held duration is > 0.2f but < 1.0f and triggers on release.
// -- e.g move the player to the place we just clicked using nav mesh agent
// Where the held duration is > 1.0f triggers each frame until release.
// -- e.g move the camera around using the mouse delta (free look)
}
you can handle the timing aspects of this with interactions: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Interactions.html
SlowTap + Tap together should get you the behavior from your first case. context.performed tells you when all the conditions were met, so that's all you'd need to check for in this method.
If you want behavior to trigger every frame, you're probably best off either polling the InputAction in Update or setting a bool in this method based on the phase (started/cancelled) and doing your work in Update based on that.
Good morning community.
For some time now, the "Listen" button when assigning new inputs in the input manager dosent register when I press anything, so I have to type it in manually. Did I touch a setting I didnt want to?
I ended up using the Hold interaction and it seems to work, I'm not sure if it's the right way or the best way?
I also lowered the tap range to 0.2f ~ 0.4f and hold kicks off after that.
public void OnSecondary(InputAction.CallbackContext context)
{
if (context.performed)
{
SecondaryIsPressed = true;
}
if (context.canceled)
{
if (!SecondaryTapped && context.duration >= 0.2f && context.duration < 0.4f)
{
SecondaryTapped = true;
}
if (SecondaryIsPressed)
{
SecondaryIsPressed = false;
}
}
}
private void LateUpdate()
{
if (SecondaryTapped)
{
SecondaryTapped = false;
}
}
im trying to use the InputSystem package but somehow my touch doesn't enter the STATIONARY phase?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.TouchPhase.html
if I debug.log it it seems to constantly be on BEGAN
it does switch over to moved and ended too when i move or end the touch
but never goes to stationary
New project, latest Unity 2020.3 LTS ... Multiple mice don't seem to be working. Does anyone know if this a known bug? (the API calls are all there, but they incrrectly return only one Mouse even with 2 plugged in).
(either mouse works fine, but 2 mice = Input System appears to fail)
Possibly a bug. Report it if you can
Hey ! 😎
I would like that when I press TAB (Inventory) the camera (Virtual Camera Cinemachine) could not move but I can't find how to do it ... 😭
Hey there! I am working on a project that has both mouse and touchscreen controls and am trying to find out input which has been used last. I have tried using the InputUser.onChange callback and haven't had any luck with that. Any tips/advice would be helpful, thank you!
If no-one's got it working I'm gonig to assume it's just another "New Input isn't finished being written yet". Seems to be a lot of that.
I found a cryptic comment in the docs for Mouse. It could mean they don't support it, or they don't intend to support it, or could mean something else.
I'm using Unity's new input system and every time I press a button I get MissingReferenceExceptions for started, performed, and canceled. The code still seems to run fine, but it's spamming errors.
the error:
MissingReferenceException while executing 'performed' callbacks of 'Player - Ground/Movement[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d]'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
an example portion of code called on Awake()
movementAction = playerInput.actions["Movement"];
movementAction.Enable();
movementAction.started += UpdateMovementInput;
movementAction.performed += UpdateMovementInput;
movementAction.canceled += UpdateMovementInput;
private void UpdateMovementInput(InputAction.CallbackContext context) {
movementInput = context.ReadValue<Vector2>();
}
^^ if anyone has this problem like I did... it was because I didn't unsub my actions on Disable.
Hey!
I'm currently using the IDragHandler interface for a mobile game I'm making however it cannot handle multitouch input, does anyone know a fix/replacement?
@willow violet im not sure that's a unity issue, windows doesn't provide any API I know of to determine which mouse input is from which, their drivers both add events to the same messageloop. I think you would need some custom mouse driver to handle multiple mice independantly
how can i make input manager detect double tap like
tap hold
like in mc if u wanna sprint
how can i do that
normal multi tap dont work
Windows absolutely has APIs to know which is which, it's been part of Windows for ... 15 years? ... longer?
I've now given up on Unity's New Input system, and instead did a short C++ wrapper for the windows calls, works fine, gives me each mouse separately :).
Any chance of pointing me to the API? when i looked into it everything i found required a custom mouse driver that attempted to fake two cursors, or used the touch input to fake it
how to make it work
the new input system makes sure that only 1 input device of a device class is handled at any given time. there is a setting though to change that so it handles all input devices of a class at the same time. currently busy but i'll post a link for it later
My team and I have noticed that our game is dropping joystick input from time to time, usually a few frames at a time and it gets more frequent with FPS inconsistencies. Nothing else input related has been touched, but we think it might have happened with an engine or input system update.
The only things we can guess are that our script execution order is set up wrong, or that the input system is just bugged. Has anyone else experienced this?
not on my end
Hey, I am using new unity input system so I replaced all my OnMouseEnter on colliders with IPointerEnterHandler and added to main camera component PhysicsRaycaster. My problem is that canvas is blocking raycasts from PhysicsRaycaster even I set event mask to dont react with UI layer, but it still is blocked by UI. It is a bug or I need to do something extra to ignore UI layer? Ignoring other layers works with no problem.
OOh, that would be awesome if you can find it! Thanks! (I never saw/heard of/noticed this in the docs before)
i just quickly skimmed through it so it might not be the exact thing i was referring to but i think it does talk about your case. i'll check more carefully later. https://docs.unity3d.com/Packages/com.unity.inputsystem@1.2/manual/ActionBindings.html#disambiguation
Figured out a solution, checking to see which pointer is the current pointer in seems to work well
Does anyone know if there is a way to reset a Pointer input device to a specific location in this new Input System? Something similar to Mouse Warp?
Does anyone know if there is an easy way to forward mouse events on a RawTexture to the attached camera? I have mouse events working if I use the camera as the player camera but I'm trying to make a UI with the Camera built into that UI.
You will have a much easier time simply overlaying UI elements on top of the raw image on the same canvas
Otherwise you'd have to do some custom InputModule stuff I imagine
The sphere there is a GameObject with a Collider. I want to be able to detect mouse events on that (and other) objects.
Folks, anybody know how to setup something like the gravity / smoothing behavior you got in the old input.getaxis, but in the new Input System? Ideally without coding it myself - I can do that, but I'd like it if someone could point me to the option in the new system...!
unfortunately with this kind of setup you're going to be stuck doing your own custom raycasting.
You have to code it yourself. There is no such feature in the new system
Thanks for the info! I thought it might be that way but I was hoping there would be an easy solution where I could use whatever the camera was doing.
Boo! Booo! Ah well, thanks @austere grotto .
How do you type "shift" in the input manager menu?
All the key names are listed here https://docs.unity3d.com/Manual/class-InputManager.html
Nice, thank you
Under "Mapping virtual axes to controls'
Has anyone noticed strange behaviour with Pointer.current.press.isPressed ?
When I use it, many times it will misfire and say the mouse was not being held when it definitely was
are you sure Pointer.current is always your mouse?
Do you have a touchscreen perhaps or any other pointer devices such as a pen
Or perhaps any other mice connected
Thanks for helping. No I cant think of anything that would interfere. I am coding on a MacBook and clicking the screen in playmode in the editor.
Do you have a mouse plugged in besides your touchpad?
if(Pointer.current.press.wasPressedThisFrame)
{
clickDuration = 0;
ClickStart();
if(!UIClick)
{
ClickedTarget();
}
}
if(Pointer.current.press.isPressed)
{
clickDuration += Time.deltaTime;
if(!UIClick && clickDuration > .5f)
{
DragCamera();
}
}
i watch the time delta in the editor and it randomly resets back to zero
what resets to zero
clickDuration?
clickDuration yes
I am trying to tell when the mouse is dragged. This is my makeshift solution but anything better would be welcomed
I had another solution that looked at distance the mosue was moved while held down but it was not consistent enough
have you tried using the built in IBeginDragHandler, IEndDragHandler, IDragHandler event system stuff?
though I guess it needs to be on a certain object for that
And/or have you tried actually setting up an InputAction for the pointer position and mouse click instead of using Pointer.current?
Also, again, maybe try printing out Pointer.current.name during the Pointer.current.press.wasPressedThisFrame if statement
maybe there's another device besides your touch pad
I haven't for that exact reason. I want it to detect when a drag happens no matter where it happens
If i did that, can you give me a clue how i would use it to detect a drag? And is 'Pointer.current' not a good thing to use?
wow!
I'll try that
just detect when you click and release the mouse button, and read the position of the mouse each frame in that period
Something is definitely fishy. I clicked WAY more than 6 times, but it only printed 6 times. And all the times it didn't print, it didn't execute the rest of the code either. It feels like dropped frames or something
device simulator touchscreen?
what kind of setup are you using?
are you in a virtual machine or something?
No, just a regular MacBook Pro with Unity
within unity's new input system, is there a replacement for Input.GetAxis?
just make an input action
yeah, but how would I get the value of the axis?
ReadValue<Vector2>()
It's a bit hacky, but my solution to this was to use an InputProcessor that transformed pointer position events from "real" screen space into the MainCamera's screen space. That might not work for you, though, because it looks like you need to handle events on both the full screen UI and the game window simultaneously? If you want to be able to cast rays into the small camera view and hit 3D objects I think you would need to subclass PhysicsRaycaster and override ComputeRayAndDistance.
(Also, in case you're interested there's a reasonably active community of classic crawler developers in the discord at https://dungeoncrawlers.org/ )
how can i make multi tap detect:
tap and hold like in minecraft i u need to sprint
any ideas how to do it?
normal multi tap dont work
any ideas how to fix?
Are there any bugs with the "hold" mechanic right now? Ive set up to bindings on the X key.
The top one has 1 binding "Hold" with hold duration of 2, which means it should not do "performed" before the button is held for 2 seconds... ?
The bottom one has 1 binding "Tap", with a max tap duration of 1.
However, in game, once I even touch the X button below press point, it responds with the hold.performed instead of tap.performed.
I never get a response from the tap function at all.
And no matter how I configure it, top/bottom/pressure/durations... it will still act in the same way
Do either of them work correctly if only one of the bindings is set up?
i removed all bindings on both, and now they both fire at once, working correct both of them
"actions"
then I tried adding the "hold" interaction on the top action (the hold action), and set duraiont to 2, but still they both fire once i press the button
if I then add a "tap" interaction on the bottom action, this will not register anymore
both are set up with .performed in the code
{
""name"": ""ActionHoldX"",
""type"": ""Button"",
""id"": ""faffc3a9-ef86-44b9-8fac-264bc5453c42"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": ""Hold(duration=2)""
},
{
""name"": ""ActionX"",
""type"": ""Button"",
""id"": ""68b8ffe8-6f76-45cb-b68f-bcf39355006e"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": ""Tap(duration=1)""
},
Ooooo! Thanks for the link. I am planning to implement a translation of the position on the overlay to the camera and do a ray cast. I don't think it will be super difficult. Just disappointed that I couldn't have a simpler solution 😝
Hi there I have an action of type tap (I want it to trigger just when a user presses a key and not as a hold) but I always get false if I use value.isPressed;
How do I get the "this is tapped" from the input value?
I have another action for the same key to be held and that works fine
ahh wait, I just removed all processors and it is all good I think, made it seem like I needed one
Hi, i changed to the new Input Manager. But the key binding ain't working for some reasons, Can't even get log from Debug.Log. No error. Any ideas on why that is, guys?
Create a new Input Action object and it works now. Weird.
I find the new input system to be a bit of a nightmare tbh, I don't think it's worth it, at least for me
It's overly complicated and I remember trying to do things that just weren't even implemented yet (involving holding down key combinations and stuff)
The new input system is good if you have both simplified game-y controls + you want easily reconfigurable bindings without rolling something yourself tho
I've just learned to use Unity recently and i have no idea how to do universal cross platform input. After some Youtube searching, i found out that the new Input kind of solve my problem for me (in theory).
Yeah you definitely want the new input system if you want universal cross platform input without writing it yourself or using an asset
So I'm trying to have different behaviour for a button depending on if you hold it for X seconds or if you quickly tap it
I've a "Hold" interaction to an InputAction
public void OnUse(InputAction.CallbackContext context)
{
if (context.started)
{
Debug.Log("started!");
}
if (context.performed)
{
HoldUse();
Debug.Log("performed!");
}
if (context.canceled)
{
if (context.WasPerformed){
QuickUse();
}
Debug.Log("cancelled!");
}
}
so, performed is never called if I quickly tap the button, so that's great!
but how do I check (in cancelled probably) if the InputAction was performed or n,ot?
Is there a function WasPerformed() to check this?
does any one know how to use the coroutine with the new input sysem
hello?
i want the void on shoot to be coroutine
Just Start a coroutine in OnShoot or as a lambda expression
dont work
What did you try? And why did it fail?
They're completely unrelated topics
wait
it works now
thatnks
wait
doest that just defeat my purpose
as making OnShoot a IEnumerator
how?
i want to make OnShoot aIEnumerator
wich needs a coroutine
i cant make a coroutine in the same class i want it to be
hello?
Why not?
can i?
emm... Sure. A coroutine can be defined anywhere. You can only start in a MonoBehaviour though.
it is mono behaviour
*start if from a MonoBehaviour. So you can even do monoScript.StartCoroutine(...) in a plain class.
Should've done that a long time ago 😄
i want this codeprivate void OnShoot(InputAction.CallbackContext obj)to be like thisprivate IEnumerator OnShoot(InputAction.CallbackContext obj)
so i can use this commmandLR.enabled = true; yield return new WaitForSeconds(0.02f) LR.enabled = false;
yeah.
err... If you want it to start in the current script, then you don't need monoScript...
that was just an example.
StartCoroutine(...)right
ok done should look like this right?
{
StartCoroutine();
RaycastHit2D hitinfo = Physics2D.Raycast(barrel.position, barrel.up);
if (hitinfo)
{
Debug.Log(hitinfo.transform.name);
LR.SetPosition(0, barrel.position);
LR.SetPosition(1, hitinfo.point);
}
else
{
LR.SetPosition(0, barrel.position);
LR.SetPosition(1, barrel.position + barrel.up * 100);
}
LR.enabled = true;
yield return new WaitForSeconds(0.02f);
LR.enabled = false;
}```
bro?
Emmm... Not really. You're not doing anything aside from adding my ***example! ***line of code...
You should look into unity docs about coroutines. How to start them and how they work.
well you do start it with StartCoroutine
Yes. Except that you don't start anything in your code above.😅 You probably get compile errors.
Follow the examples in the docs.
At this point, your issue is unrelated to Input system. It's pure coding question related to coroutines.
Anyone knows how to set up input system so it runs with my visual code?
Visual code? You mean like Bolt or something?
jup
Idk, sounds like a nightmare
It's probably easier to learn C# than set that up
Does Bolt even support events?
Has anyone successfully used RawInput to get controller data from C++ ... and then also made Unity's Input system work correctly? (the problem is that Windows only allows one app/window to access controller data at once - I can get all the controller data, but if I do that, Unity cannot receive inputs any more)
(right now I have multiple mice + gamepads + etc all working correctly - which I can't get to work in plain Unity, but works fine if you use the C++ APIs - but I'd really like to use UnityUI/UIToolkit/etc, and UnityInput 😦 )
I'd expect you'd use a native plugin in Unity to read the rawinput windows APIs from Unity
Or use a wrapper like this that is ready to go https://github.com/Elringus/UnityRawInput
how can i make an if statement with (_Input.movement.fire.preformed){
it gives me a error that _Input can only be used after =+or=-
after i put them it gives me unexpected =+
why would the input system "UnityEngine.InputSystem"
only read half of the joysticks axis - I'm using a 1D Axis Composite into a float
eg: it reads half of the y-axis - from the middle to the top
You shouldn't use a composite for a joystick
Use a normal binding, bound to the stick axis you want
The other method only gives me 0 /+1 or -1 , no decimal values in-between
That'll be down to how you set up the action or the binding
should action be analog or axis ?
It should be set to value/axis typically
ok its working !!! Thanks !
it gives me a error that _Input can only be used after =+or=-
after i put them it gives me unexpected =+
That's what I've already done. A native plugin by defintion will prevent Unity Input System from working ... hence my question 🙂
That appears to do the opposite - it only works in the background? - I've looked through lots of github etc projects but so far I haven't found any working examples that do this while also being compatible with Unity's own input handling 😦
input.movement.fire.performed is an event. you can not use that in an if statement
how do you get for example Button Released ? (with the InputSystem)
if i type input should it be orange or just blue
Hey hi, i have a composite Navigation (Digital Normalized) that i use for Navigation in the Event System.
However the navigation for the buttons is kind of unresponsive.
It navigates through buttons correctly, but the rate is really inconsistent.
Is there a reason why this might happen?
I want to disable certain inputs. I am able to do this sucessfully in a non-vr project. For example, if I want to disable Jumping I can simply say something like:
playerControls.Player.Jump.Disable();
However, in VR, I want to disable Turn input. This is located on Snap Turn Provider script. For some reason,
XRIDefaultInputActions playerActions = new XRIDefaultInputActions();
playerActions.XRILeftHand.Turn.Disable();
This does not work.
Basically, the context will have that information. Context has three states: started, performed and cancelled Cancelled is the release state.
cool thank you
Well you just created a new instance of your actions asset there. Disabling an inputaction on this new instance isn't going to affect any other instances your code may be using
Share your code and a better explanation/video of what you mean
Well this explains it. Thanks!
Hey! I'm having a weird issue with the Event System and the new input system. I have implemented IPointerEnterHandler into my script, and it only fires some of the time as you can see in the below video. If I slowly move it between inventory slots it seems to work, if I move it quickly it only fires every so often: https://youtu.be/CTaFScxTjoA
Here is the script I am trying to implement the functionality in:
📁 Get access to my tutorial project files over on Patreon: https://www.patreon.com/danpos
💬 Join in with the Blender and Game Dev conversation over on The Creative Magpie Discord Server: https://discord.gg/Pr2rFnd39X
❤️ Find me elsewhere on the internet:
Gumroad: https://gumroad.com/danpos_
Twitter: https://twitter.com/danpos_
Instagram: http...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Here's the issue again with some items in my inventory, you can see that because its not firing, I can't drop some of my items: https://youtu.be/HpQRvpSRGdk
📁 Get access to my tutorial project files over on Patreon: https://www.patreon.com/danpos
💬 Join in with the Blender and Game Dev conversation over on The Creative Magpie Discord Server: https://discord.gg/Pr2rFnd39X
❤️ Find me elsewhere on the internet:
Gumroad: https://gumroad.com/danpos_
Twitter: https://twitter.com/danpos_
Instagram: http...
anyone here using InputSystem beyond testing? i'm seeing something that contradicts the documentation, not sure if its me or a bug
this, i think, suggests that if a controller gets disconnected, when its reconnected, it slots right back in where it was
however, i noticed that the reconnected controller is given a new deviceId every time
hmm, okay well maybe its supposed to do that:
how am i supposed to reference that same gamepad then after its been reconnected?
how can i make it when input.movement.fire.performed Startcoroutine
pls awnser me):
As far as I know, on PC there's no way to tell whether a newly connected controller is the same device as one that was connected previously; there are no globally unique IDs for USB devices. My guess would be that the first thing you quoted is talking about consoles, where there is a concept of controllers being unique and tied to specific players.
i tend to agree, despite that not being mentioned
i can confirm though, on consoles, it doesnt do that
looks like its down to the console SDK to handle that
Even if the same user is signed in on it?
well...now you got me wondering...hold on
nope
it doesnt matter, the console knows, it just means i cant use some clever code on pc to detect the extensions
since the device id wont match the consoles one
start a coroutine when the event is fired
Here's an example:
private void Awake()
{
playerControls = new PlayerControls();
playerControls.Player.Enable();
playerControls.Player.Jump.performed += Jump; //Since I'm subscribing only to performed event, I only get notified of that.
}
public void Jump(InputAction.CallbackContext context)
{
StartCoroutine(NewCoroutine());
}
IEnumerator NewCoroutine()
{
throw new NotImplementedException();
}
Honestly, just watch the codeMonkey's tutorial on Input system. Its really well done. https://youtu.be/Yjee_e4fICc
✅ Get the FULL course here at 80% OFF!! 🌍 https://unitycodemonkey.com/courseultimateoverview.php
👍 Learn how to make BETTER games FASTER by using all the Unity Tools and Features at your disposal!
👇
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Gam...
for a frequent event such as mouse move, is it better to subscribe to events or to read their values in Update loop?
or it doesn't matter and is a question of code design?
FixedUpdate seems broken AF with the inputsystem 🤔
you shouldn't be getting input values in FixedUpdate. the Input System works well with callbacks
thank you im soooooooo thankfulll
ive been trying to fix it for threee days
);
Okay. I'm successfully able to do this in a non-VR project (that is, create a new instance of input actions and disabling that). This leads me to believe that creating a new instance of the input system (the thing that looks like a map??) is not a problem in non-VR projects but is one in VR projects. However, I'm not able to "assign" XRIDefaultInputActions (there is no placeholder on the gameObject where I can drag and drop this component. I have the field as public.
Just pass the reference around purely in code
Where do you get it from in the first place?
can you explain this a bit further? I think of FixedUpdate as a callback, from Unity.
i think of it more as another update loop, rather than a callback
FixedUpdate doesn't run every frame so you will miss input
the InputSystem fires callbacks when the desired inputs are pressed, and aren't checked every frame
So it's up to us, in Update or FixedUpdate, to digest those callbacks? If so, how?
yes and no. when the Input System sends data, you can do whatever you want with it, whenever you want. ill grab an example
So the callback, from the inputSystem, comes at a time based on when the input occurred, and acts like an interrupt?
anyone leaving FixedUpdate at 0.02 has bigger problems to solve than input.
public void OnJump(InputAction.CallbackContext context) { //im called when the input system detects that the jump button has changed state
if (context.ReadValueAsButton()) {
// get here if the button is down
// call some jump method
}
}
it's not exactly "interrupting" anything, it's just another step. if a change is detected, it'll be called early during the next update step i believe, since the script execution order is lower (or higher? not sure, but it happens sooner)
here, i can store the button state as a class variable for later, maybe for use in Update
for one-shot button actions, i tend to just fire an animation/coroutine
The number doesn't matter. And no not really there's nothing wrong with 0.02
i have fixed update step at like 0.5 because i don't use physics ☺️
plus physics turned off in player settings 👀
This uncertainty about when it's called is exactly the problem I'm trying to solve/understand. It's not as performant/low latency as setting the FixedUpdate to much faster than frame rate and using the old input system to detect input. Even on very fast touch response devices that poll and report touch rapidly.
Even if you have it set to .001, some of your users will run the game at a higher framerate than that and you will still miss frames. FixedUpdate is simply not the place to poll input
what are you doing in between frames that you need non-existent latency?
Please don't make strawmen. I'm trying to get good, low latency response, not perfection. That's simply not possible. This not a childlike request for absolutism, it's my observed testing that shows the new input system is simply unable to keep up with modern hardware.
maybe im not explaining it well enough
No, you said it perfectly, you don't know any more than anyone else about when the interrupts come from the New Input System, and it's true that it's not capable of keeping up with modern sampling and reporting rates from things like the iPhone 13 Pro models, gaming phones or even the long established iPad Pro Motion's faster inputs.
FixedUpdate provides a means for easy testing of the awareness of the old input system's flagging of input, and reveals it to be more aware of input from faster devices.
frame input update loop frame
|---------------v----------->|-----------<--------|
callback
from what i understand, it works like this.
if input is detected anywhere between frames, the callback will fire during at the beginning of the update loop, before the next frame
I understand that this was their intention, yes. It's not consistently true on iPhone 13 Pros at 120fps, and nowhere near this on Android devices with 90hz and faster screens, some of which report input far faster than their refresh rate.
And there seems to be no way to subscribe to the input when it occurs, which would make it possible to update the screen and/or audio response earlier, such as is the case when using either a very fast fixedUpdate to poll for input, or a faster or portional part of the Audio Thread
Correct. A fast FixedUpdate in unity doesn't even run between frames anyway
It still runs as part of the normal update loop
You'd need a separate input handling thread
It absolutely does, you can set it to report mach time during those updates and check for yourself.
It doesn't. It's part of the main thread and normal game loop https://docs.unity3d.com/Manual/ExecutionOrder.html
But I'll try what you said
set FixedUpdate to faster than the Update() (double or triple or quadruple) and put the mach time into a little struct along with when Update gets called in the exact same script. Also, if you want to see something funky, look at how many times it does additional fixedUpdates.
I know it does additional FixedUpdate that's how it can run it as part of the frame loop
Also, make sure you're doing some work in the fixedUpdates, this is less true when you don't have physics acctually doing anything in your scene. You need to have a real world game of physics happening, otherwise the fixedUpdates all bunch together because they know they have nothing to actually do.
I see, thanks guys
I'm basically agreeing with you. It's borked with fixedUpdate. It shouldn't be, but it is. You can use the old input system with fixedUpdate, with a few concessions, and it works very well.
Why doesnt the new input system get any values if they are fetched from a FixedUpdate anymore?
I can still use in Update, right?
Just be absolutely certain to set fixedUpdate to something other than 0.02. Pick a value that's 2x faster than frame rate, if you can get away with the overhead of physics being processed twice per frame. This makes smoother movement, faster responsiveness and fixes all sorts of funkiness with regards timings.
right now i'm polling mouse pos in Update and applying cam changes in LateUpdate, by the book
You can actually set the new input system to read input on cadence with FixedUpdate: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.LowLevel.InputUpdateType.html?q=dynamic
I've never tested it
okay, i'll take a note of this. no physx in my game so far
How, and how reliable is this for high performance touch phones, like the new(er) gaming phones?
Sorry, got in before your update.
it's in the project settings for the input system. And yeah dunno
If you're not using PhysX, nor 2D physics, you can definitely use FixedUpdate at very fast rates as a polling mechanism, and enjoy.
Why on earth didn't they give the New Input System a unique thread with its own polling mechanisms?
¯_(ツ)_/¯
me myself i'd rather just forget old input system ever existed 😄
If the new input system is working for you, all power to you!
I think Unity does this all behind the scenes. I don't use this anywhere but all the functionality works as intended. Like you know when you create a script from the Input Action thing?
Do you just make different action maps to switch between different ingame functionalities? Like if I want to switch between moveto click input style to wasd with use of a skill
Yes.
Usually UI interactions (menu) is in a different action map. Also like specific things like movement on land vs. in water
most awesome ty
Hey, im using the new input system to get touch controls up an running. I added an On-Screen Stick component to my image and setup my player controls. But my image doesnt seem to be responding to my touch... It was working fine the first time i added it, not sure if i did anything but it wont move or anything. Tried in a new unity project, same issue
Anyone got a clue as to what i might be doin wrong?
do you have an event system in the scene?
can you click on it and make sure the input module component is not yelling at you for using the wrong input module?
Yeah it looks fine. It was working when i first added it, now it doesn't work at all, even in new projects which is weird https://i.imgur.com/9KVpCcC.png
uh
the iinput module has no action bindings
I recommend removing the input system ui input module component and adding it back
The default fields and bindings should pop up
but right now since they all say "None", nothing's going to work
wtf... huh, you're right
confused
Did i do something wrong here or is this just some weird bug?
It looks like you put your own PlayerControls input action asset into the input module
I have a problem with the new input system that makes it that when I get out of a scene the get back to it (or just reload it) I get this error every time I press a button:
Your script should either check if it is null or you should not destroy the object.
reloading the scene gets the same problem```
The functions seems so be called from a gameobject that doesn't exist anymore since one of the line that causes this problem is:
transform.position += Vector3.down;
this is how I use the input system: ``` map = inputActionAsset.FindActionMap("controls");
map.Enable();
map["down"].performed += OnDown;
map["down"].canceled += OffDown;
map["left"].performed += OnLeft;
map["left"].canceled += OffLeft;```
I can do a null check for every input but it'll make the code run one more time every time I reload the scene
I think what I'm looking for is if there's a way to completely disable the inputActionAsset when I destroy an object or reload a scene
I found the solution I just had to do:
map["down"].performed -= OnDown;
map["down"].canceled -= OffDown;
map["left"].performed -= OnLeft;
map["left"].canceled -= OffLeft;
etc... before I reload the scene
Hey guys i’m using the new input system and i have a bug where whenever i press it once it acts like it pressed 3 times
Like I said you need to look at that parameter context
you are currently ignoring it
What do i need to do with it?
I basically need 1 player to join each tiem i press it
you should also configure your IDE #854851968446365696
don't do that
put cs Debug.Log(context.phase);
Okay its doing started performed canceled
Thats making it interact three times
How do i make it only perform the action once?
like I said, only do your stuff if it's performed
How do i do that o.O sorry im really bad at unity
Have you heard of if statements?
Yea
Use one of those.
if context.phase is performed, as we've been discussing
So put my code inside if(context.phase) {}
First step is to configure your IDE as per IDE Configuration link in #854851968446365696
then you will get intelliSense and see your errors and it will be much easier to write code
Use this thing I showed you before
I’m looking at it but idk where am i putting this
After declaring it
I put if (context.phase = performed) theres a error
How do i write it
You are missing C# basics.
Sorry i just really need this one thing to work for a project
I think you should invest in some time learning the fundamentals of C#
Ik i’m really bad at this just want to get this over with
Its not something i want to do thats why but school project
Ok its working now
But is there a reason only one of my controllers can input that action?
They can move later but to join games only the first controller can make players join
I'm using the new input system and I'm trying to make the player able to remap keys so I used the "Rebinding UI" sample from the package but it only seems to work half of the time in the editor and never works when I actually build the project does anyone know a solution ? (the only thing I did was adding the 3 elements that have a blue bar to make it work)
Inside a Canvas I have UI Buttons that should be responsible for "left", "right","down" and "up". Is it possible to define them as responsible Buttons in the Input Manager instead of Keyboard Buttons?
Essentially trying to feed input into the old input system from the UI? Afaik you can't programmatically feed input into the old input system. You'll most likely have better luck pulling something like this off with the new input system.
Is there an new Input System?
Depends what your definition of new is, but yes
THere's one that's been around for a few years now.
So this is the old one?
If so where can I get the new one
Pinned to this channel: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.2/manual/index.html
Ok thanks
Guys, why does my new input system always stop working for nothing?
I didn't make any changes and just from restarting my pc, now my input system don't work
private void Awake()
{
mover = GetComponent<Mover>();
combater = GetComponent<Combater>();
inputActions = new PlayerInputActions();
inputActions.Player.Enable();
inputActions.Player.Jump.performed += Jump;
inputActions.Player.Attack.performed += Attack;
inputActions.Player.Movement.performed += OnMovement;
}
void OnMovement(InputAction.CallbackContext context)
{
Debug.Log(context.ReadValue<Vector2>());
}
private void FixedUpdate()
{
Vector2 movementVector = inputActions.Player.Movement.ReadValue<Vector2>();
mover.Move(movementVector.x);
}
The OnMovement function does work, but the readValue in the fixedUpdate doesnt
Have you tried logging that Vector2 in FixedUpdate?
or even just capturing the Vector2 in a variable in OnMovement and using it in FIxedUpdate
Yeah, it always shows (0,0,0). The fun its that it was working until I restart my PC
do you have any other bindings tied to that input action>
Yeah
The attack and the jump actions works
While im pressing the keys
It does work in the Update method
Im so lost 😂
Just read the value in OnMovement or in Update and use it in Fixed
input handling isn't intended to be done in FixedUpdate generally anyway, unless you've set your update mode to FixedUpdate in the input system settings
Hmm idk that, thx
Yeah, now it works
Is there a way of mimicking a Event System Action and Input Manager(Old) from a script?
Like if I press the Left Arrow Key on PC it moves Left I want to mimic this behavior into a script and if I press a button down have the same effect like the Arrow Key on PC.
Is there a possible way of doing this? And if so how?
hello, I keep getting the "error CS0246: The type or namespace name 'PlayerInputActions' could not be found (are you missing a using directive or an assembly reference?)" error
There is no such class in the new input system with that name.
If you're thinking about your Input Actions asset and trying to use the generated code file from it, then you need to make sure you're using the same name as your asset.
(you can see the generated C# file it creates in your project)
Are you talking about for UI navigation?
does anyone have experience with the new inputsystem where the mouse input suddenly gets super choppy/laggy even on great fps?
controller stick input still works great and smooth
... wow now its back to normal again.
I would presume you're multiplying the input by Time.deltaTime.
If you do that that to mouse input it will cause issues
nope. im not. i even use the standard first person controller provided by unity.
If you mean their Starter Assets, they do that, which is incorrect
so the code provided by unity is wrong?
Yep
if i remove time.deltatime the input mouse/camera moves in increments. like it jumps. less smooth.
Make sure this is set to Dynamic Update
thanks, but this kills my wasd input and also doesnt feel alot better with mouse
Did you turn the rotation speed down to compensate?
If input.look is a position delta then you shouldn't have a deltaTime
Most unity tutorials get this wrong
thanks. got it working now. kinda sad that unity themself dont get it right
If you have an input that's sometimes speed (wasd/joystick) and sometimes displacement (mouse delta) then you'll need to multiply by delta time some times and not others. Personally I think the easiest solution is to split it into two different inputs for turn speed and turn delta, but in theory you could probably also do it with different processors on the different bindings?
I agree
Im making a keybind system. When I type a letter in a specific inputfield it saves that letter into the PlayerPrefs as a keybind. But I am not able to press TAB into the inputfield and i wonder if somebody know how i would do that. When i press tab nothing happens and its because the inputfield doesnt think that its a string when i press TAB so it doesnt happen anything. any tips?
I have a problem with the new input system:
I'm using the "Rebinding UI" sample to rebind my controls but the changes don't persist between scenes almost all of the time.
Anyone knows how to fix this ?
I'm currently using the InputActionMap dirrectly in the script so I can switch between any device while in the game: cs void Start() { map = inputActionAsset.FindActionMap("controls"); map.Enable(); map["down"].performed += OnDown; map["down"].canceled += OffDown; map["left"].performed += OnLeft; map["left"].canceled += OffLeft; map["right"].performed += OnRight; map["right"].canceled += OffRight; }
Im talking about pressing a button and be the equivalent of pressing down the left key in the Input Manager. Like have 4 buttons left right up down which all of them are going to mimic the 4 PC keys up down left right
But how is the event system involved? The event system is the UI thing.
What you're describing just sounds like a normal input binding
Oh wait actually I think you're talking about this, right?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.2/manual/OnScreen.html
So you know how the Input Manager not Input System I refer to the old one with Horizontal and Vertical
If you add the thing in your script with the axis for horizontal and vertical you can move with the 4 PC Keys
I want to make that into buttons
yeah look at the link I sent
You mean UI buttons on screen, right?
Let me put it more simpler
I have a script of movement using the OLD Input System I mean the horizontal and vertical axis
And I can control my character with the 4 Keys on my Keyboard (Left Right Up Down)
Yes i'm with you
