#🖱️┃input-system
1 messages · Page 61 of 1
It's like this: if I press to move and the flag is false, the player won't move. If I keep it pressed and the flag is set to true (with the Move key pressed), the method isn't called, it'll only be called if I press it again... Would there be a way to subscribe ir so it's called WHILE the move key is pressed, not only WHEN I press it? Sorry about the confusion...
i'd make key down set on=true and key up set on=false. then if(on) move();
basically remember the key is down between frames.
really, it doesn't have a way to query the state of keys ?
Sounds like a good solution... I'll try it out, thanks!
oddly enough their snippet doesn't work. InputAction has no definition for onPerformed
ill just use the unity default definition for now
it might be perform? they have something like start, cancel, and perform. i'm new, I haven't memorized each state.
there is a definition for performed (its a bool) but it doesn't take any inputs which would make the second half of the expression useless. I'm just going to use the other method anyways
ok!
I'm trying to understand from InputAction.CallbackContext context how i get the cursor position on the screen.
you can get the mouse position from Mouse.current rather than getting it out of context
I have a few errors from these codes can yall tell me whats wrong
I use Unity 2021.3.2f1 and im making a FPS game
Is it normal for an input event be called twice when the input is triggered?
idk
This "context" log is getting called twice if I press the Jump key (all of them are doing that, so I'm not sure if I did something wrong...)
So I get 4 logs, two for 'Performed' and two for 'Canceled'
I cant understand this, probably because im new to Unity
What errors are you getting, friend?
These ones
You're missing a ";" in the end of line 7
The arrows?
Move lines 25 to 29 so they're after line 23 (and remove line 30)
or remove line 24. same thing.
private void Awake() {
playerActionControls = new PlayerActionControls();
playerActionControls.Player.Move.performed += ctx => movementPressed = relativeMovement !=
Vector3.zero;
}
private void Update() {
movementInput = playerActionControls.Player.Move.ReadValue<Vector2>();
}
i have a problem when i use a keyboard and press only one button of the movement keys the player doesn't move but when i press two of the movement keys at the same time he moves and then he keeps moving even with one key pressed
so its a problem only at the start before he starts moving
i don't have this issue with a controller
Why InputAction can only be used to press and release keys
I can't keep pressing the key and keep firing the event
This problem comes from the most basic and has been pressing the button to achieve movement
GetInput.Player.Move.performed += OnMove;
I kept pressing the key and it only responded once so my code like this
i need to make an up slash in my game and i want the input to be left button (on mouse) and w (on keyboard) but how do i code it so you need to press both to perform that action?
using new input system btw
If you want to do something every frame use Update. The input system only gives you event invocations when something changes.
But this way I'll be checking every frame just to check if I'm pressing the move button
I want to try to avoid this unnecessary overhead
Is there no good way for InputSystem to solve this problem?
This is very minimal overhead and similar to what the input system would be doing anyway
Continuous input like movement is best handled by polling. Events are better suited for things like button presses
Ok, I understand, thank you for clarifying my confusion
Yo, I'm trying to make a multiplayer game with the input system, but when a new player is spawned, they are controlled with all devices (So for example, with one player already spawned via controller A, if i use controller B to spawn another player, both players are controlled by controller A AND controller B.) How can I fix this?
New input system has a whole system for this. Use PlayerInputManager and PlayerInput
im using both of these though
you're doing something wrong
Someone last week asked the same question and it turned ou they were not actually using the PlayerInput component, they were using the generated C# class which they conveniently named "PlayerInput"
ain't got them mixed up
yep you're doing exactly the same thing I said
you're using thie PlayerControls object to handle your input
that is not using the PlayerInput component
if you want it to work properly you have to actually use the PlayerInput component to handle input
PlayerControls is your generated C# class
huh. I've been pulling my hair out at this. How can I use the PlayerInput instead then, may I ask?
Does anyone else get this issue with the input system. Basically the returned value of this input in this code never resets to 0.
It just keeps the last value it got from the input.
you'll need to subscribe to the canceled event too if you want to get the zeroing-out events
for look and move I recommend simply polling in Update instead
much simpler
void Update() {
input_Look = playerInputActions.Player.Look.ReadValue<Vector2>();
}```
alternatively you can keep your current setup and switch the action to a Pass Through
or subscribe to canceled
three options for ya
Ah ok, so I'll have to subscribe to each event manually to have each stage updated.
Started
Performed
Canceled
It's weird because I've seen similar code reset for others without the canceled event being called.
I've tried the update method as well but for some reason it doesn't update constantly it always hitches unless I move my mouse very slowly then it updates but still hitch.
I gave you three options. Two of them don't involve subscribing to canceled.
Hitching may also be caused by bugs in other parts of your code (not pictured here)
Yea, something might be wrong system wide for me then. I've tried this code in a few new projects and it's the same result.
It's just that one script attached to a game object in the scene and while watching the values in the inspector.
I can see it hitching both when I subscribed to the canceled event, go directly through update, or switch the action to Pass Through as you mentioned.
Thanks for replying and providing a few solutions.
I'm not necessarily sure what's wrong but that's why I wanted to know if anyone else was having this issue.
the editor is generally prone to performance hitches in general
it could just be that
a particluarly long frame will result in a frame with larger mouse input values, which is good and expected
How Can I Convert Input.GetAxis to Input.GetKey ?
Maybe just explain what you're trying to do
it depends on what you actually want.
For Example I Want to Convert This https://pastebin.com/KAd0pW14 Script Input to Input.GetKey etc.. So I can assign any keys i want
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.
You can already assign any keys you want in the input manager
unless you mean to assign them at runtime
I am Using Old Input Manager so
Like i want to Change it On RunTime
Ok that's what I asked
as you said
Your options are:
- Use the old input system as you are. You'll need to change your code to have separate handling for left and right and up and down instead of one thing for the axis. You'll also need to replicate the "gravity" part of Input.GetAxis.
- Use the new input system which supports runtime rebinding. This will require a bit of a learning curve because the new system is not that beginner friendly.
- Use ReWired which is a paid asset.
How Can i go with the first option any examples
?
...
I tried another new project and the input worked fine. Also tested it with a basic camera controller and everything's fine, no hitching.
I moved the code back to the old project and got the same issues.
No clue what's causing it but it seems I'll have to move to a new project.
Hi, I have a project that was working normally but for some reason it started lagging when I move my cursor around.
I've tried disabling all the things in my scene and it didn't solve the issue, has someone experienced this other than me?
Also here is the screenshot from profiler:
can i Mouse.leftButton.ReadValue() to get the pressed state?
Enenra do you have a git commit from just before the problem started?
sadly no
I was working on another script but I disabled it as well as all the other scripts but that didn't solve the problem
ok, well... lesson for next time.
what is the last thing you worked on when you saw the problem?
can you disable that?
I did
well... keep triaging.
that's free right?
git is free, github private repositories are free iirc.
ok, thanks
can i Mouse.leftButton.ReadValue() to get the pressed state?
sure but it's simpler to use Mouse.leftButton.isPressed
aha, thanks!
Hi. I'm having a small problem with New Input System. If someone could help me on DMs that would be great. Thanks!
Anyone have any experience creating custom devices and using QueueDeltaStateEvent for partial state updates?
My device gets removed when I call it, so I'm probably using it wrong 😅
Guys, is it normal for an input event be called twice when the input is triggered? This "context" log is getting called twice if I press the Jump key (all of them are doing that, so I'm not sure if I did something wrong...)
yes, it triggers once with context.started = true and once with context.performed = true. If you have a more complicated setup (say you have a Hold interaction on the binding) then started will trigger when you start holding the button and performed will trigger when you've held the button for the hold duration. But in the simple button press case they both trigger immediately
and it will trigger a third time when the button is released with context.canceled = true
oh, wait, I just looked at your whole screenshot rather than just the line with the red box. It seems weird that Jump.performed would trigger twice... hmmm....
Thanks! I think I found the issue... For some reason I had two instances of the Inpur Manager in scene... Silly mistake, sorry xD
got an tmpro, when im on new input system only, it doesnt find inputfield.text , when im on both it finds the text property
why is that so?
They're completely unrelated.
Should i use the new input system or the Old?
are you new or exp
if new => use old
Yeah
The new is so advanced
it uses stuff that even i struggle with and i got some years of coding exp
I Got some weeks lol
Hey, is there any neat trick to restore all input actions' state after disabling all of them? I want to have a cheat console and type there freely without performing any gameplay input actions and then re-enable all of the previous input after closing the cheat console. I know I can enable specific input maps but I wonder if Input System can somehow store its state and then read it to enable proper actions so I don't have to check what maps and actions were enabled at the time of disabling them. Thanks.
For the new Input Sytem, how do you differentiate between .performed and .canceled when you have it set to SendMessages?
It passes through an InputValue, but what can I do with that to get the .performed and .canceled from it?
You don't. It just sends a message for everything
You can't tell if it's performed or cancelled
If you want to differentiate that you would use one of the other modes
so there's no way to detect a buttonUp with sendmessages?
I guess look for a zero value? SendMessages is like the dinky prototyping mode
thanks for the help
this is a far shot, but any idea why my Quest 2 VR controller connected through Virtual Desktop will not show "primarybutton" and "secondarybutton" actions? the "primary/secondarytouched " actions work, as do other actions such as grip and trigger. this is unity 2021.3.3f1 but it was also broken in 2020. menu accessed from Window->Analysis->Input Debugger.
this just started happening after not touching the project for a month, before that it worked
by "not show X actions" I mean that I press the physical button but the value in unity doesn't change from a 0 to a 1 as it does for other actions
I have an action map for gameplay and UI
should both be active at the same time?
seems like a lot of trouble to enable and reenable maps whenever I implement a UI feature
they CAN both be active, just depends on what behavior you want the game to have
doesn't ui often do input handling above the map level -- and it only trickles down to the gameplay which uses maps if it wasn't already consumed (like by a modal popup)
idk how much of that applies to unity
They should be active or not depending on whether you want them to be active 🤷♂️
I have implemented camera controller using new input system for touch input and I want to implement it for keyboard/mouse input as well. Keyboard/mouse input actions are different from touch system completely. I cannot define one input action with different binding for them.
What is your suggestion? Define separate input control for each or action maps to handle keyboard/mouse and touch inputs?
CameraInputControl
Movement_Touch (ActionMap)
Movement_Keyboard_Mouse (ActionMap)
//...
CameraInputControl_Touch
CameraInputControl_Keyboard_Mouse
😐
Hi, how can I determine the device used from a CallbackContext? and is there an enum for the devices??
particularly trying to make a look funtionality for both controller and mouse. I'll need two different sensitivities
I'm currently using rewired as my input system manager but for whatever reason all of a sudden it isn't detecting inputs for my pro controller over bluetooth. Any ideas what might be causing this? It was working fine like a week ago but I tried testing it on the same project a week later and the button presses aren't being detected. I can post a link to my repository if it's helpful.
Hi, I'm trying to disable an Action Map when the game is paused but some of the bindings are still being triggered while the game is paused and the Action Map is disabled. Don't know if I'm doing something wrong.
On PauseController.cs, I Disable() player movement and opening a map. The player can't move but I can still trigger opening the map.
_inputManager.InputActions.Player.Disable();
On MapController.cs I check if the map is available and if the player has pressed the binded key.
if (_isMapInteractable && _inputManager.InputActions.Player.ToggleMap.triggered)
I would expect the ToggleMap binding to get ignored if the Player's bindings are disabled but they aren't. There is a binding for player movement that is getting disabled and debugging it returns Player.Move.enabled: False, whereas ToggleMap is always "true". They are both part of the same action map I'm disabling so I'm so confused. I'd really appreciate any help.
I have no clue, but some thoughts, are you generating a c# class? Could that be not-updated maybe?
and are you disabling when receiving an input from ToggleMap I'm guessing, right? could it be that you're trying to disable while an input is ongoing or something? What happens if you delay the disabling a frame or till next update?
I'll check if there's something wrong with the c# class.
I'm disabling the whole InputActions.Player action map when I press the InputActions.GameState.Pause on another MonoBehaviour but I don't see how they could conflict. At least I have a clue that InputActions.Player.Move is disabling correctly.
I'll check if working around the frame cycle works.
Thank you!
could it be the actual controller??
It's possible, I'll try another one.
Tried another and it has the same problem. They're definitely detected but the inputs aren't.
The wired controllers work fine as well

btw, regarding my question, I discovered procesors are a thing : )
I've been cleaning up some old files that I thought could be the issue but still not working as expected. What I have noticed is that only the MapController.cs MonoBehaviour is returning Player.ToggleMap.enabled: True while other scripts with the same reference to the InputManager.cs are returning Player.ToggleMap.enabled: False after disabling.
I'm doing a simple FindObjectOfType<InputManager>() (where I've got the InputActions) so I don't see why one script would show no change while another does show the values toggling.
That last thing gave me the information I needed. I forgot I had the same InputManager component on a GameObject and later on I chose to instantiate the component on a PersistenObject to use on different scenes. So they weren't getting the same InputActions.
How do I recreate the old input system GetAxis? (not GetAxisRaw)
anyone have an idea on this? https://forum.unity.com/threads/how-to-i-use-ixboxonerumble.1009810/
Hey everyone, I have a problem, I am making a game with 2d movement and I am using the input system. When I run it on my computer it works, but when I build it for my iPhone, the ui buttons suddenly stop working. Is anyone else having this problem?
Yesterday it worked fine, but since I updated my iPhone to IOS 15.5 the ui buttons just stopped working.
Hi, gamepad (xbox one and xbox360) work in editor but not in build, using Unity 2019.4.24f1 with Input Sytem version 1.0.2.
https://forum.unity.com/threads/controller-bindings-not-working-after-build.752834/
Anybody figured a solution for this besides building for x86_64 which does not work for me?
Can I use IPointerClickHandler in a project that's using the new input system?
Hello. I'm using the new input system and am implementing control rebinding. I'm able to detect whether a binding "conflicts" with another binding. I've thought of two ways to handle this - one way is two immediately swap the two bindings OR show the other (conflicting) binding as "empty" to the user. Other than Enabling or Disabling actions, is there a way to assign "null" to a binding or set the override path to point to an empty binding? (do reply to this post so I get the notification from discord)
I'm trying to set a boolean for my animation condition to go from idle > running. I'm using the new input system, so what should I be checking for? I'm trying to make it change to running via polling if the gamepad action "Move" is currently being performed.
Yes you can - IPointerClickHandler is part of the UI event system. It's not related to which input system you're using, except by the input module which translates input into events for the event system.
Awesome, thank you.
Are you asking how to set boolean properties in an Animator? (that would be a question for #🏃┃animation or #💻┃code-beginner )
Or are you just asking how to read input in the new input system?
I’m asking how to poll an action in code, so I can use it to check and change my animation states. I was redirected here from #💻┃code-beginner lol.
Pseudo code would be:
If (movement action is currently active)
Walking bool = true
Else
Walking bool = false
I was trying to make readvalue of vector2 work, or action.triggered but both cut the animation short without looping
ReadValue should work. I would just worry about Debug.Log right now because it's plausible you also have some issue with your animator. Focus on one thing at a time
Mouse.current.position.ReadValue() any idea why this could always return 0,0?
I also tried to set a manual vector2 for the position, which is also returning 0,0
This guy has an older version of Unity and it's not the same inputs as im getting, the Composite on mine doesnt have 2D Vector for some reason, Does anyone know why?
Idk which one is what the guy selected
Your action type should be Value
Control type Vector2
Then you can pick up down left right composite for the binding
(it was renamed)
Oh ok tysm ❤️ i tried to search on unity documenting but couldnt find
Hi Everyone, Im not sure if anyone can help but Im missing the active input handling option in project settings -> Player then under the configuration section. I upgraded unity to 2021.3.3f1 and its still missing. If I make a new project its there. it seems to have been removed from the projects settings menu configuration section entirely. The new input system is installed also and working, just have no way of changing to old, new input or both options anymore.
Im guessing that you can take the new project (project files) and add it into the current project files and it will probably ask you to rewrite or write over the existing and you can just cancel.
Hello everyone! First time poster here, I’ve been learning unity for a couple of months now, and really enjoying the engine so far (as well as C sharp). I have a question about getting unity to recognize my microphone as an input to inter-text. I’m going to start a thread and explain the problem in more detail if anyone is interested.
Can i talk about input field here?
Hello @austere grotto Sorry for disturbing I don't have any rights to do so but I was having an issue after switching over to new input system and the inventory i've made keeps opening and closing at superspeed instead of opening with 1 click,
Can you show us your code for opening/closing the UI?
public void Update()
{
if (Keyboard.current.tabKey.isPressed)
{
if (Keyboard.current.tabKey.isPressed)
Cursor.lockState = CursorLockMode.None;
if (inventoryUI.isActiveAndEnabled == false)
{
inventoryUI.Show();
foreach (var item in inventoryData.GetCurrentInventoryState())
{
inventoryUI.UpdateData(item.Key,
item.Value.item.ItemImage,
item.Value.quantity);
}
}
else
{
inventoryUI.Hide();
if (Keyboard.current.tabKey.isPressed)
{
if (Keyboard.current.tabKey.isPressed)
Cursor.lockState = CursorLockMode.Locked;
if (inventoryUI.isActiveAndEnabled == true)
{
inventoryUI.Show();
foreach (var item in inventoryData.GetCurrentInventoryState())
{
inventoryUI.UpdateData(item.Key,
item.Value.item.ItemImage,
item.Value.quantity);
}
}
else
{
inventoryUI.Hide();
}
}
}
}
}
}
This code doesn't use the new input system yet
Oh what rlly
I'll help you through DM!
Oki
hi hi greetings 🖐️
I need a hint for my whole input field, to be able to use Tab button
as a functions of next from one input field to another
currently I need to click using left click to go on input field
after we filled previous input field
isPressed happens every frame
this is the new input system though the other person is wrong about that
yeah might be better to switch to events instead of using the update loop
or just use WasPressedThisFrame() instead
Hey guys! I got a question as well. Unity tells me: Calling IsPointerOverGameObject() from within event processing (such as from InputAction callbacks) will not work as expected; it will query UI state from the last frame.
I understand what it means, but is there a different new way to check if the mouse is on a UI element?
using event system callbacks
I've got help and I've switched over to new input 100% but now I don't know the logic on how to close the UI (basically disabling it again) with the same button (tab)
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.EventSystems;
public class InputManager : MonoBehaviour
{
public ThirdPersonInputActionsAsset playerInput;
public InputAction inventoryOpen;
[SerializeField] GameObject inventoryUI;
void OnEnable()
{
inventoryOpen = playerInput.Player.Inventory;
inventoryOpen.Enable();
inventoryOpen.performed += OpenInventory;
}
void OnDisable()
{
inventoryOpen.Disable();
}
private void Awake()
{
playerInput = new ThirdPersonInputActionsAsset();
}
private void OpenInventory(InputAction.CallbackContext openinventory)
{
inventoryUI.SetActive(true);
}
}
i mean youve switched to a different input handling style but taken a big step backwards in terms of your code actually doing anything
is it good or bad ?
cause if the case is where it's harder for me to close the UI again which I don't think it is
Not everything in your old code is implemented in the new code
yeah,
Is it bad practice to put the Player Input component on multiple game objects within one scene?
For example, if I want to have the player be able to interact with an object check for input via the Player Input component rather than having an event sent from the player to the object.
In what kind of method can I put the code instead of update
Or how can I implement WasPressedThisFrame into the code?
In update method
Like literally what you had before
but replace isPressed with the correct thing
So Question; I'm using the new system as Invoke unity events. Subscribing using, InputAction.callbackContext.
how can I create a custom function using the classes in this fire script in another? I've set up an input manager script and a locomotion script.
void FirePerformed(InputAction.CallbackContext context)
{
// If SlowTap interaction was performed, perform a charged
// firing. Otherwise, fire normally.
if (context.interaction is SlowTapInteraction)
FireChargedProjectile();
else
FireNormalProjectile();
}
So I've got a good amount of experience using the new input system on Windows, but I'm working on some new touch controls so I can port one of my desktop projects to mobile. But absolutely none of my touch controls are getting any response when i build to mobile, even stuff that I'm 100% sure works correctly on Windows. Anyone else had this problem? It's a fresh Unity project but with the input actions and scripts copied from another project. Editor version is 2020.3.21f1 and the input system is version 1.0.2
Should I take the time to learn the new input system and convert my old project to use the new input system if I definitely have no plans on using controllers or anything like that?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sc1 : MonoBehaviour {
public CharacterController controller;
public float speed = 12;
public float gravity = -9.81f;
Vector3 velocity ;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
public float jumpHeight = 3;
bool isgrounded;
void Update () {
isgrounded = Physics.CheckSphere (groundCheck.position, groundDistance, groundMask);
if (isgrounded && velocity.y < 0) {
velocity.y = -2f;
}
float x = Input.GetAxis ("Horizontal");
float z = Input.GetAxis ("Vertical");
Vector3 Move = transform.right * x + transform.forward * z;
controller.Move (Move * speed * Time.deltaTime);
if (Input.GetButtonDown ("Jump") && isgrounded) {
velocity.y = Mathf.Sqrt (jumpHeight * -2f * gravity);
}
velocity.y += gravity * Time.deltaTime;
controller.Move (velocity * Time.deltaTime);
}
}
@solar sorrel
the player isnot jumping
jumpHeight might be too small
You’re multiplying the jumpHeight by a really small decimal (time.deltaTime) so the product could be super duper tiny and unnoticeable
Also I began unity two weeks ago and I’m probably not the best person to ask 😅
Hope it helps though
make sure your ground check is working. log it
also log jumpHeight of course
how
where is it
where is what
i didnt find it
.
?
.
What am I supposed to do with that
Maybe explain what you've done
.
Where in that screenshot is it telling me if the ground check is working
i dont understand
We are trying to figure out if your ground check is working
You need to log information that tells us if it is or not
i logged it
Something like: $"Is touching ground: {isgrounded}"
I see "3" and "GameObject (UnityEngine.Transform)"
this is not useful information
i lose my references when i destroy and instantiate an object how do i fix that
ok now keep logging that and see if it matches what's happening in the game
it should say true whne you're touching the ground
if it doesn't, the grounded check is not working right.
also make sure "Collapse" is not turned on in your console window
itsnot working
time to start looking into why
is there any way you can keep references when you destroy and then instantiate an object
Is the ground check in the right position?
Is the layer mask correct?
Is the ground's layer correct?
keep references to the destroyed object? No
they are not the same object anymore there's nothing to "keep"
is there any work around for this?
reassign your reference to the new object?
but i cant really do that in the middle of the game
of course not
run that when you spawn the new object
or:
- use a singleton
- Use an event that the enemies listen to
I instantiate multible times so can i make a prefab and make that the new object
how are you having your enemies get the reference in the first place?
Public transform Player;
Try instantiating the original game object from a prefab and reference the prefab when you need to maybe
so all the enemies are in the scene at the start and you've manually assigned the reference? That's not very extensible
I already am doing that
So whats the better aproach?
have the enemies discover the player when they spawn
via making the player a singleton, or a FindWithTag or something
I have a player tag on him
then you can just do that same method of discovery when they find that hte player is null (when it was destroyed)
perfect then you can use FindWithTag
Alright so make a transform variable and then do find with tag in the start Function?
Or use this code but instead of respawn then player? https://docs.unity3d.com/ScriptReference/GameObject.FindWithTag.html
Is there an event for each time the Input is updated?
that's how the new input system works
you subscribe to the .onperformed events and it will fire off every time that input changes
My current game has the “player” re spawn when they die (their dead bodies stay around in the world (isDead bool activates and they done move anymore). In the editor this works fine, new one spawns and I can move around. But when I build to WebGL, the newly spawned characters won’t respond to controls. Using the new input system.
anything obvious as a reason for this to anyone?
differences in bnehaviour from editor to builds are usually due to:
- framerate dependent code
- code that depends on scripts executing in a certain order
- code that depends on objects being returned from functions like FindObjectOfType<> in a particular order
I'm really not sure why it's not detecting my clicks. Any ideas?```cs
private void OnEnable()
{
shoot = inputActions.Powers.Fireball;
shoot.performed += fireball;
shoot.Enable();
}
private void fireball(InputAction.CallbackContext context)
{
Debug.Log("Fireball!");
}```
show the input action bindings?
get rid of the Press interaction
also show the Fireball configuration
The interaction?
This is the fireball
It's still not detecting my clicks
Is your OnEnable code running? Verify with a log statement.
Do you have any errors in console?
Ok so with the new input system, can I do the same as with the old one if I want to find where on the screen the player clicked?
yeah the mouse click usually reads as a vector2 for the x and y
Ok Thanks :D
I'm trying to subscribe a certain function to the onActionTrigger() event for the PlayerInput class but I don't see it as a function of the PlayerInput class
You're mixing up your generated C# class or your own custom script with the PlayerInput component from input system
I think the latter
there's a class called "PlayerInputController" but no PlayerInput..
Ahh it's a struct inside the PlayerInputController named PlayerInput
I never generated a class though, weird...
I'm currently working on split screen local multiplayer, and one issue I've come across is the "correct" way to filter out which device to receive input from for each player. I need to specifically use the generated C# file, not the PlayerInput component. Any ideas?
PlayerinputManager and PlayerInput were custom built for precisely that purpose. I highly recommend using them. They pretty much take care of all that automatically
For all other purposes I recommend against PlayerInput but for local multiplayer it's the best.
IPointerExitHandler, IPointerClickHandler and other similar interfaces stopped working after upgrading from 2020.3.25f1 to 2021.3.3f1. Are they discontinued or am I missing something?
they are not discontinued
double check that you still have an event system, you still have a graphic raycaster, and that nothing is blocking the object
Event system updates its "selected item" field when I click on them.
Also corresponding unity events work fine, so I doubt it's related to the setup.
show the code?
When someone gets the chance, I have in the player the option to choose which input system i want to use, i set it to both but my problem is that parts of my game that use the old system dont work eventhough it is set to use both
how do you know they're not working. What are you expecting the code to do and what is it doing instead?
Are there errors?
when i press the pause button for example it does nothing but moving which uses the new system works just fine
and no there are no errors
it just dosent do anything
also every time i add an actoin to the input action it dosent work even if i have it generate a new script the only thing ive done to get around it is to delete both remake everything and generate the script which is tedious for adding anything to the input thats why ive kept both
I forgot the keyword when adding to an event. do we call it "add" or "register"?
Event += MyFunc;
i did some testing and discovered that it is not getting the axis
for example (this is my pausing that isnt working)
if (Input.GetButtonDown("Pause"))
{
if (gM.isGameOver == false)
{
isGamePaused = !isGamePaused;
Pause();
}
}
i put a debug in and found that it didnt log the message so i think it is not getting the axis
subscribe?
Thankyou
Where are you running this code?
in update
Does a log statement outside the if statement run?
And can you show your Pause axis in the input manager>?
then your Update is not even running or at least that section of it is not
can you show the code?
ideally the whole script
Do you have this script attached to an object in the scene?
Is that object active?
Is the script enabled?
if you have no log outside the if statement then your Update is just not running
it's not an input problem
then why would a Debug.Log not work
Either Update in this script isn't running
Or there's an error happening
Or you've done somethign with your console window to confuse yourself
like put a search term in it
its in the if (Input.GetButtonDown("Pause"))
so i conclude its not getting the axis for some reason
also in player the input is set to both
I asked you to put one outside and you said that one didn't log...
Also asked to see this - can you show it?
i thought u ment if (gM.isGameOver == false)
I just wanted to see if Update was running
well ill just mess with it more
my laptop is wack
most of my problems are bc of it
and they require a wack solution
ill fix it eventually wuth enough time
how can I check if a key is just pressed, or is held down? Example: I only want an event when a key is just pressed .x secs ago, or I want the event to occur every update frame while the key is being held down.
how do I do Input.GetKey() and Input.GetKeyDown()
Is there a standard way to make an input do two things with Unity's input system? For instance, I want left click to be how the player both moves and gathers things. Do I just need to do a raycast on my gatherable items to see if the mouse is hovering the gatherables when the left click event is fired?
of course
Been using unity for ages but never jumped into input land. When it comes to canvas buttons, how do they 'know' I'm left clicking on them? Is this hard coded, or could I switch the 'left click' input to be the 'a' key?
It's based on the InputModule component which is on your Event System object
That will define which input axes / input actions (depending on which input system you're using) trigger the UI actions
Ah, I see that object now. Thanks!
I found a solution to my issue that doesnt use the PlayerInput component. I just create an InputUser and associate the InputMap (with the interface IInputActionCollection) to the user. Works perfectly and only took 2 lines to setup.
question... what does this error mean
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)```
it means there was a NullReferenceException when one of the callback functions for performed on your Fire1 action was running
thank you
Hey all I'm super new to unity and c# in general so I'm sorry if this is a dumb question.
I've seen several people use something like
defaultInput.Character.InteractPressed.performed += e => InteractisPressed();
But I've equally seen people using something like defaulatInput.Character.InteractPressed.performed += InteractisPressed;
They seem to behave slightly differently but I see both being used and not once have I seen someone explain why they used their method over the other
What are the pros/cons two these to methods (unless one is just flat out wrong, in which case please inform me)
People use the first one out of laziness.
I'll tell you it's objectively worse because it's not possible to unsubscribe from the event with the first form
Or because they think lambdas are cool or clean looking
Or they just saw that example somewhere and don't know any better
no. people use the first one because they do not need access to the input context.
and the correct way to write it would be defaultInput.Character.InteractPressed.performed += _ => InteractIsPressed();
I have created a custom clamp2d. It is OK but now, I cannot see it in the list
and in an example in unity doc
#if UNITY_EDITOR
static Clamp2DInputProcessor()
{
Initialize();
}
#endif
[RuntimeInitializeOnLoadMethod]
static void Initialize()
{
InputSystem.RegisterProcessor<Clamp2DInputProcessor>();
}
What does it mean? It uses editor preprocessor to call static ctor only in editor but when I run it in the editor, Initialize method executes directly without calling static ctor
is there a better way to do this?
Not really that I've found.
You could probably set it up programmatically but that's not as user friendly.
My FPS camera keeps seeing the back of my player's head when I look up. Any ideas for a workaround for this? Here's a clip:
Just exclude the player model from the fps camera's culling mask
Yeah, I thought of that, but I wanted to still have the player's legs visible for platforming. Can I cull out certain parts of the player model?
If you split the mesh up and use separate renderers
Or make a headless version or something
Oh dang, I have no clue how to split a mesh but that's a great idea. Time to start researching. Thank you
I have a PlayerInput component on a game object and I want to respond to a mouse button being clicked and when it's released. I have an action map set up, and I have an OnUserAction method being triggered via event broadcast from the PlayerInput component, but I don't know how to identify if it's triggering from a press or a release.
The event signature has no arguments.
Ahh never mind it's only executing on press at the moment.
So I suppose what I am trying to find out is how to detect the input from the button being pressed as well as the release.
Sorted this out, needed to look into interactions on input actions.
And have an InputValue argument so I could query the state in at the time of the action being triggered.
Hey Everyone! I am having a struggle to make mouse aiming in my sidescrolling platformer with new input system. The thing is, i am trying to do something similiar to this in video: https://youtu.be/-bkmPm_Besk
I have covid atm so apologies if i sound odd in this.
Make sure to subscribe for more content!
Main Channel: https://www.youtube.com/c/bblakeyyy
Patreon with fully explained c# scripts:
https://www.patreon.com/BlakeyGames
NEW SERVER LINK: https://discord.gg/cyskvvyDeH
Silhouette Dash free download:
https://blakey-games.itch.io/silhouette-da...
But right now, i only can read the position of the mouse on a screen
i would greatly appreciate if somone could guide me to a good info source on how to make this right
youre trying to shoot?
have you added shoot input to your input system?
Yes. I have shoothing working on player while pressing "E" but the ball instantiates only in one place in front of a player
And I want to change that to be dependent of mouse position
Hello i use the new input system. I have so my INPUTS scripts where i listen the input action.
And then on my PLAYER scripts i have a reference of my INPUTS scripts for do the action according to what action happen, do you have better solution ?
what's the solution to the scenario where if I press a button to bring up a window
and the next window expects the same button press for confirmation, it skips confirmation
tap interaction im guessing?
What is the current state of the input systems polling API? Are there any ways one can check for any key being pressed? (not to be mistaken for action)
Is there a simple way to read a button press like you can with a Vector 2 input?
ReadValue<Vector2>()
example: Mouse.current.leftButton.wasPressedThisFrame
is there something similar to this when the mouse button is held? Ping me if you know
Using the new imput system how can I detect mouse scroll up or down? I cannot bind it in any way
Also most of the online solutions seems already obsolete since Unity staff said 1 month ago they were changing it
have you tried experimenting with making it a value type? i would see if scroll wheeling returns a value like 1, -1. if it doesnt, i wouldnt know
The only thing that work for now is | Value - Vector 2 - Scroll [Mouse] | but then I have to extract the direction via code, as far as I read they were implementing direction reading already in the actions so I can directly trigger an event only when wheel goes down.
if thats works then thats better than nothing tbh
a short while after I press play my project stops accepting input for a few seconds, it's happened across multiple projects in different unity versions, Is it a bug with the input system?
Idk if its a problem with the new input system or not but as you can see in the console, i pressed the options buttons 5 times and could open it 2 times.
I'm using the Player Input by using his behaviour set on "send messages" by code.
How is it even possible ? I tried with the Event Trigger but also the Button On Click () method and nothing worked correctly
BUT its working when i use the Pointer Click or my mouse
Are there any good tutorials you guys know of that show me how to make a character controller using the new input system? I'm really new to coding so I need it watered down.
Id be interested in that too, along with wiring up mesh models
Hi! i got this code for my game :: if (Input.GetKeyDown(KeyCode.X))
which works but, i need the inputsystem version of it. Which is a reference to an input system button from another script,
how do i do that?
if (InputAction.(ButtonInteract.triggered))
this also doesnt work for example
i really dont understand how to call it
new input system in the Package Manager has examples you can import and see how it works. There are three different ways shown there
ill ask somewhere else, its not in there, gotta spend 8 hours again looking for something someone could tell me in 10 seconds.
Documentation is in the pins as well. It's not 10 seconds you need to understand how to set it up and use it
but its already set up, it already works. i just dont know how it works when referencing it in within another script
if (ButtonInteract.triggered); does it already, but it doesnt work like that in another script outside that class
probably dont even need a reference since i can use using UnityEngine.InputSystem;
but still it does not work
guys i am using unity new input system
private void Walk_performed(InputAction.CallbackContext context)
{
input = context.ReadValue<Vector2>();
Walk_animation(input);
}
private void Walk_canceled(InputAction.CallbackContext context)
{
input = Vector2.zero;
Walk_animation(input);
}
void Walk_animation(Vector2 input)
{
animator.SetFloat("InputX", input.x);
animator.SetFloat("InputY", input.y);
}
``` when i press W and D , its move north-east with slow movement , not even normalized vector , its my action binding setting
why are you using stick deadzone with WASD it should be for controllers and also 0.9 is a lot
i added for all joystick too
its useless with a button it can cause problems i'm sure its not the main problem but you never know
what would be a good set up for switching between swimming and ground movement should i just make a new action map for swimming and switch between the two ?
nah i directly switch by asking the playerInput , there is a method to swtich playerInput.SwitchCurrentActionMap(actionMap Name);
nice
then on trigger enter the water i switch the action map
did you find the problem ?
nope
i'm fairly new to input system as much as its great its frustrating to learn at first i wish i could help more
i wish i had photoshop :((
why though
lol why not use gimp
i am not familiar with interface :(( ,, can't find the option where to go and where to not
or if you are used to photoshop workflow there is this website that is just like it literally a ripoff lol but in browser only i use it quite often https://www.photopea.com/
Photopea Online Photo Editor lets you edit photos, apply effects, filters, add text, crop or resize pictures. Do Online Photo Editing in your browser for free!
try it
there are plugins that make gimp look like photoshop but never tried any and that requires some research and work to set up so i never bothered
thanks man :)) you are my hero
can someone help me with multi tap? the tutorial I followed didnt write it like anyone else so I have no idea how to get it to work. It currently just activates as if its single tap. heres how it looks now
hi there, so I'm making a pc game, but I'm wiling to make it compatible to smartphone as well, does anyone know any tutorial about it? Is it too complicated?
so unity sometimes makes game template projects like the kart racer
is there a project they made that uses the new input system?
i wanna see how they use it
i know there's an input sample but that's just for basic movement
It is not very complicated
I recommend this article to read
try their new game demo, Gigaya. maybe
might have something to do with the spacing of the taps?
hello! just want to quickly ask if there is a way to access unity's Sensor class? i'm trying to follow what's in here:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Sensors.html#stepcounter
because i'm aiming to access the StepCounter class
idk how my visual studio's not recognizing it even though i already placed "using namespace UnityEngine;"
my unity version is 2020.3.31f1
oh wait, i think i have not yet installed the input system package 😅 mb mb
I made the tap count requirement 5 in the input manager and it was still being detected as pressed when pressed once. Theres got to be more to its set up but I cant tell what I have to do. It has to be that ReadValueAsButton is the incorrect thing to use but Ive tried a bunch of random things to see if anything could work, but nothing has.
@crisp bluff did you create the prerequisites class?
this is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NPC : MonoBehaviour
{
public GameObject dialogPanel;
public Text dialogText;
public string [] dialog;
public int indexi;
public float wordSpeedi;
public bool playerIsClosi;
void Update()
{
if(Input.GetKeyDown(KeyCode.F) && playerIsClosi)
{
if(dialogPanel.activeInHierarchy)
{
zeroText();
}
else
{
dialogPanel.SetActive(true);
StartCoroutine(Typing());
}
}
}
public void zeroText()
{
dialogText.text = "";
indexi = 0;
dialogPanel.SetActive(false);
}
IEnumerator Typing()
{
foreach(char letter in dialog[indexi].ToCharArray())
{
dialogText.text += letter;
yield return new WaitForSeconds(wordSpeedi);
}
}
public void NextLine()
{
if(indexi < dialog.Length - 1)
{
indexi++;
dialogText.text = "";
StartCoroutine(Typing());
}
else
{
zeroText();
}
}
private void OntriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
playerIsClosi = true;
}
}
private void OntriggerExit2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
playerIsClosi = false;
zeroText();
}
}
}
im trying to convert it to the new input system, but no ideia unfortunately
So generate the InputActions object in your project first
Once you’ve done that, create your control scheme and click the checkbox in the editor to generate a class
The direct translation of Input.GetKeyDown(KeyCode.F) in the new system would be Keyboard.current[Key.F].wasPressedThisFrame
but there are better ways to handle things like this in the new system than reading keys directly
as i used a tutorial for this, i wasnt really sure how to modify it, thanks!
i got input actions to use for the character moviment
Disable it in OnDisable sorry
thanks! i'll try it
I recently upgraded my project to the new input system but whenever I try to move using the joystick it can only go exactly diagonally or vertical and sideways
So I can't move it in a circle or anything
And I'm not sure what even causes it
I'll record an example 2 secs
Ignore the background noise
Boy what the hell
show your input action configuration and bindings
Sorry I'm not even really sure what I should show lol
Action Type: Value
Control Type: Vector2
Is how it should be configured
now show your code too
Doesn't seem to have worked for me
I have a Shoot value but it never seems to update no matter what. It always reports as False. How could I fix this?
Why value
because i'm storing a bool value?
Thats for button
For a Title Screen's "Press Any Key" prompt, how could I set up the InputSystem to detect if keyboard keys are pressed and excluding mouse input?
from input action callback context you can get lots of details
Thank you @jagged wyvern! I'm checking them out.
i did that but it didn't do anything
how are u calling it
i figured out what the issue was. i wasn't enabling the input
So I want to modify that hold time value, that's ticked off default, through code
For this I would need a reference to that interaction from that specific action
All I managed to achieve was to set/get the value with the input default settings
InputSystem.settings.defaultHoldTime = MyValue;
but what if I want to modify that value without changing the default one ?
Seems simpler to just implement the hold timer in your code
Hi there, I don't know if anyone has any ideia about it, but in order to make work a key, do I need to make something more beyond the code and the input action? I'm trying to make a npc with a collider that when the player presses a key, it pops up the ui. I tested the ui and it's working fine, just the collision and key thing not working :/
no error appears as well on the code, it just doesnt happen anything when i press it
Did you enable it?
i think so?
yourAction.Enable();?
i had put it like that
i was following a tutorial, but it wasnt working, then i tried to convert to this 😅
the original part was that
Yeah I figured that part out
i tried to put a inputaction as a component inside the npc, but nothing happened as well
by any chance can i put it this line before the if?
No that is only if you are using InputActions
I would try following this if you haven't yet.
https://learn.unity.com/project/using-the-input-system-in-unity
I'll check it, thanks
hey guys im trying to make this thing work but it doesnt work at all
i have just a 2d vector WASD in playerinput
and this is my code
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
// Start is called before the first frame update
private Controls control;
public Rigidbody rb;
private Vector2 movement;
public float movementSpeed = 5f;
private void Awake()
{
control = new Controls();
}
private void onEnable()
{
control.Enable();
}
private void onDisable()
{
control.Disable();
}
private void Update()
{
movement = control.Player.Movement.ReadValue<Vector2>();
}
private void FixedUpdate()
{
rb.velocity = new Vector2(movement.x * movementSpeed, movement.y * movementSpeed);
}
}
the controls is the inputaction that i created and it has only WASD 2d vector
am i doing something wrong
onEnable and onDisable do not exist
what should i do instead?
Use the real methods
have you tried googling onEnable and onDisable and looking at how you actually write them
every goddam youtube videos has onEnable and onDisable thing which didnt work
that why im here asking
They do not, no youtube video will have onEnable and onDisable
well the one that ive watched so far to learn this new input thing did
They may have used the real methods, https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnEnable.html, https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDisable.html
The ones you can google and find how to actually write
sorry just figured that it was just a typo lol
Anyone have any idea why my input system code is working fine in the editor but returns zero response when built to Android? I've asked here before but got zero responses, so is there something else I need to include?
I'm using version 2020.3.21f1 and my input system package is 1.0.2
Upgrade your Unity and input system versions to start with.
Does anybody know how I can get input from the Primary and Secondary buttons on an XR Controller and detect which controller they were pressed on? I'm using the new input system with the latest XR interaction toolkit and the Action Based XR Rig.
I am not sure if/how you can find the controller from the pressed button. But you can assign actions to a specific controller (left/right) in the first place:
Thank you for your reply, yeah I have setup some custom actions for the controllers but my aim was to use a button to interact with an object while it was being grabbed. So if its in my left hand I press the left primary button and right primary button for right hand.
Doesnt the XR interaction toolkit already have a solution for triggering actions on grabbed objects? IF so I would look at how they handled the input
Is it intended behaviour that an InputAction that is referenced in multiple different scripts e.g. via InputActionReferences has to be enabled separately in each script?
I have a click action and I need to figure out somehow whether smth in UI was clicked during that click
So that would avoid doing game related logic
Any idea how it can be achieved?
[Quick Question]
When using WASD-keaboard input with the new input system and i press W and A or S and D together it delivers (-0.71 , 0.71) and (0.71 , -0.71) . Shouldnt that be normalized? I know that (-0.5 , 0.5) is the same direction just smaller vector scale, but since just W delivers (0,1) i think that the input should be normalized or am i not seing something? Why did they do that?
Oh damn, just as i wrote it i realized my mistake. Pythagoras theorem and stuff.... 0.71 is normalized and correct. 😄
https://srcb.in/4QZ2Wbs9q9
Im making this input manager ( not sure if its something good to do ) But looks good to make things more clean?
My question is, how do i make my character move without update function?
If u use rigidbody just feed move vector to it
if i use
while(ctx.performed){
Vector2 inputVector = ctx.ReadValue<Vector2>();
// Event to send this value to my PlayerMovement script
// Then PlayerMovement has a coroutine that moves according to the value
}
Would that work? or maybe program would crash..
but it will only execute during 1 frame
no?
Input binding
Ok i cant test it yet but hope it will work
thx
now it doesnt shows there
ye i dont get what he did
hes move function is private
and he doesnt calls it anywhere
Btw is it a video that i dont know how to activate or just text?
Every tutorial i see they use either c sharp events or message thing. Should i use c sharp events instead of unity events?
But the problem is that i still dont know a way to make player move without handling input stuff on the player script
ok i think i found the solution pretty simple actually, i just thought this wouldnt work
hello! just want to ask why the stepcounter code here only displays zero in the text?
code here: https://pastebin.com/K66mhYr3
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.
hey all I added an anykey action and I would like to get the keycode on key press , is there any way I can do this using the new input system please?
hey I already posted in code-advanced and saw this chat. would this be a good place to ask how to inverse a pinch scale system built on the input-system
Hey everyone! How can i check, if my Mouse.current.position.ReadValue() is negative or positive in script?
Hi everyone, I'm new here and would like some help with an issue that I've been having. I setup the right stick in the input system (old Unity input system) and I'm trying to get the right stick of my gamepad to move a camera on the X axis but all it wants to do is spin the camera. How could I fix this?
Position should never be negative
Hi, this is being called every time I want to set the pause perms, for some reason even though I'm not pressing the button, its registering input and calling my pause method? What is happening? thanks.
if (dominantGamepadInput != null) Destroy(dominantGamepadInput.gameObject);
dominantGamepadInput = PlayerInput.Instantiate(dominantInputPrefab.gameObject, controlScheme: "Gamepad", pairWithDevice: dominantGamepad);
dominantGamepadInput.gameObject.transform.parent = gameObject.transform;
pauseAction = dominantGamepadInput.actions.FindActionMap("Player", true).FindAction("Pause", true);
pauseAction.performed += context => CheckPause();
hey guys, so im trying to work with the new input system, and i started off with the default 1st person controller project that unity provides, and im trying to add new inputs, but all of the inputs i add for some reason dont work the same way that the existing inputs work, even tho i copied the code for my new inputs from the existing inputs.
public void OnSprint(InputValue value)
{
SprintInput(value.isPressed);
}
public void SprintInput(bool newSprintState)
{
sprint = newSprintState;
}
these are the existing methods for inputs that actually work,
public void OnInteract(InputValue value)
{
InteractInput(value.isPressed);
}
public void InteractInput(bool newInteractState)
{
interact = newInteractState;
}
and these are the methods i copied and repurposed to my own inputs. the problem is once i press my interact button once, it sets the interact variable to true, but it never sets it back to false once i let go of the button. any ideas on whats happening? (i have added new input actions in my input action asset and initialized the interact variable, just to get that out of the way)
Yeah, someone already told me that. It was a stupid question off of me tho. I manage to figure this out on StackOverflow.
<@&502884371011731486> ^ crypto scam ty
the mouse is working like charm with the Ui main menu but no keyboard or gamepad is working
this is my canvas if it helps
i double checked there are their controls in the Ui action map
ok so using the first selected highlights the button when i go into play mode and gmaepad and keyboard works
so that's the problem but sadly this won't work in pause menu nor the options menu it only works in the first start menu when the play button is highlighted so i can jump between buttons
not really an input system qwuestion at this point, but just set the selected object in your code when opening those various menus
its a solution but isn't it supposed to be automatic or am i missing something because on another video i've seen the keyboard worked by default on the menu but it was a straight forward Ui not using child menus
Can someone tell me why when i call InputUser.CreateUserWithoutPairedDevices() it creates a user WITH paired devices ?
I just wanted to know that does unity have any toggle function to enable and disable any game object
I can just find to play it and stop it.
I want to toggle it
Do I have to do it through script only?
have to do it through a script
Do you have a question?
I was just wondering that is there any function directly where I can toggle it
like here I can either stop it or play it
but cannot toggle it
Yep, I answered you above
ohk
I hope it is the right section
Hello everybody,
I have a problem that I cannot solve.
I have loaded all the scenes in "build settings" but when I start the game the maps do not come out.
the "MainMenu" and the scene to select the "character" exit without any problem. When I select the PG, it spawns in the void, the map is not there. Can someone help me?
Thks In advance
are there any tutorials on detecting which input device the player is currently using?
probably a simple question but how do I make it so that when the joystick hits 1 on the x axis it does the movement part 1 time until the stick is back to 0 and then put back to 1
like i want it to be like a button where it acts as pressed if it hits 1
right now it repeats the block of code I have
and comparing it to the previous frame doesnt work
depends how you're reading the input.
this should work, as long as you're comparing the correct thing
I figured out a way of doing it but its prob not efficent
basically now when theres a bool value called zeroed and when the stick is at 0 for x value it will be true but when the stick hits 1 it sets it to false until its brought back to 0
Seems fine
Any good resources for figuring out gamepad-specific values for the input system. I'm trying to get a value that correlates with how far a trigger is pressed.
so no one knows how to detect which input device is currently being used? (I just checked Unity Answers, several people have asked the same question but not gotten any replies)
Inputaction callback context provides it
Depends on how your project is set up
Alternatively use player input component
I have an input system setup with "move' and 'jump' - I've got keyboard controls working fine, but adding dpad and controller buttons fails to move the player… Any guidance to getting the controller working would be greatly appreciated
what action type is move?
is it value, button or passthrough
Move is Value Vector 2 - WASD = 2D Vector/Digital Normalised / 2D Vector (should be renamed dpad 🙂 ) = 2D Vector/Digital Normalised
Let me rename the control schemes
Removing the two control schemes - fixed it…
Weird
No, I had to remove the two control schemes… that made both sets of controls work
Odd, kind of defeats the point of having two control schemes and setting the default to my gamepad setup…
I'll try again later…
for no my character moves 😄 which is always good!
Anyone have an example or link to documentation for finding how how pressed a gamepad trigger is?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Gamepad.html
Note: Buttons are also full floating-point axes. For example, the left and right triggers can function as buttons as well as full floating-point axes.
So you just change your trigger mapping from Button type to Axis type and read it like you'd read any other axis. It'll give you 0-1 values (maybe -1 to 1?) depending on how pressed it is.
Uhm i am currently working on a Game and I added Cinemachine and am using the new Input system package but i always get this error message is there a way to deal with it? Or is it just not possible to use cinemachine with the new input system at the same time?
thanx
am i tripping or did TriggerButton used to be called interactUI before? Something changed and my VR controllers are no longer able to click on my world space canvas...
is this a steamVR thing?
this is what it used to look like
ok so I got a character model with a capsule collider on it. the guy is a bean with feet (not connected to the body). I put 2 box colliders on his feet and they don't collide with anything, his feet just sink through the ground. Anyone know the reason why?
Yea
I'm having trouble getting haptics/rumble working with ps4 controllers. SetMotorSpeeds doesn't seem to be doing anything even though I seem to have a reference to the controller?
Any ideas?
StopPropagation()
Any elaboration on this method?
Description
Stops propagating this event. The event is not sent to other elements along the propagation path. This method does not prevent other event handlers from executing on the current target.
I'm seeking for a way to stop input action queue event to execute
in case the very first registered callback calls this or maybe smth similiar I'm looking for
try to see here if find the answer: https://www.youtube.com/watch?v=WSw82nKXibc
Could someone help me understand why my function isn't showing up in the selector here?
public void IncomingPlayer(PlayerInputManager.PlayerJoinedEvent context)
{
Debug.Log(context);
}
attach that script to a game object as a component then drag that object
like we do on buttons events
i've done that - (it's "GameManager") - but it still won't show my function
A PlayerJoinedEvent is not a PlayerInput
The types do not match
i guess i'm misunderstanding how the Player Input Manager is supposed to work. Apologies.
Can anyone explain what's going on here?
The inputs still seem to work fine regardless of these errors.
public void OnBeamInput(InputAction.CallbackContext context)
{
if (context.started)
{
SetNodeSpeed(0, true);
beamController.TryBeam(gameObject);
tryingBeam = true;
}
if (context.canceled)
{
SetNodeSpeed(0, false);
beamController.StopTryBeam(gameObject);
tryingBeam = false;
}
}
so how would i get a collider for the feet?
a hit box, and so my mans feet dont go thorugh the floor
so just make the capsule bigger?
the problem is that there is no legs, just feet. that would mean you could hit a empty area and it would register a hit
doesent a collider work like a hitbox. like if it was shot
oh
my bad
so it doesnt madder the shape of the capsule really
just for colliding with objects
There haven't been any announcements about deprecating the old system.
k
If you're brand new you should use the old input system, it's the simplest
Thanks for the link, His method did not initially work but then I tried plugging my controller in with usb and that works so now I am wondering: Is it possible to use rumble/vibration over bluetooth or is it only possible with wired controllers?
I dont knoe, never worked with gamepad sorry
:(
Is there a proper way to use key combinations in the new input system? Like fire a specific action if two keys are pressed at the same time.
No
So does that mean the only way to check for that sort of situation, is by manually checking? i.e. if(Keyboard.current.shiftKey.isPressed && Keyboard.current.tabKey.isPressed)
I'm trying not to do that at all, and let the input system handle everything.
Binding with one modifier is a thing
Can someone point me to some help on how to remove players from my Player Input Manager?
For example, if one player destroys another, I want to remove that player from the game.
i got now the new input system setup and on WASD it sends vector3s correct but only on perform and cancel... its for movement so it do that permanently
how can i make it that it sends permanently the data
what
i wanted Input.GetKey in new system.. so its executed as long as its pressed... but im done now with new input system..
i make a tiny wrapper around old one.. only had problems with new one
just poll it in Update rather than listening to events
Hey guys how can i port a project of opensourcd github to mobile? Like only the controls. It uses the new input system. I am just confused on how I can port a binding of pc to mobile/touch
so I'm trying to figure out which type of input I am getting
and the only way I could figure out was using this janky method-
{
Debug.Log(playerInput.Locomotion.Move.activeControl.device.displayName);
switch (playerInput.Locomotion.Move.activeControl.device.displayName)
{
// PC and Consoles
case "Keyboard":
ChangeInputType(InputType.PCAndConsole);
break;
case "Gamepad":
ChangeInputType(InputType.PCAndConsole);
break;
case "PlayStation Controller":
ChangeInputType(InputType.PCAndConsole);
break;
case "Switch Pro Controller":
ChangeInputType(InputType.PCAndConsole);
break;
case "Xbox Controller":
ChangeInputType(InputType.PCAndConsole);
break;
// VR
case "LeftHand XR Controller":
ChangeInputType(InputType.VR);
break;
case "RightHand XR Controller":
ChangeInputType(InputType.VR);
break;
}
}```
and the thing is
it works, but it doesn't return "LeftHand/RightHand XR Controller", and instead returns the name of the Oculus Controller that I have
so, how should I go about this?
honestly? use the new input system. It figures all that out for you.
I am
I just need to know what type of controller I'm getting input from
I figured out a better way
{
case typeof(Keyboard):
}```
hopefully it works
nope
I literally just need to get this value
and I can make it work using that
or the control scheme
Yeah but
For VR controllers
It returns Oculus
Like
The actual name
Not, LeftHand XR Controller
So I just, for now at least, check if the name contains "XR" in it 😭
@west oracle
Is there a way to get the binding currently active?
And then it's Control Scheme?
if anyone could help me with this issue I would be very happy ^-^
Asked and answered
awesome, thanks!
i didn't know that happened, i've been subtracting lambdas this whole time
Hey guys whenever I try to bind a button I get this error:
UnityEngine.InputSystem.Controls.TouchPressControl.WriteValueIntoState (System.Single value, System.Void* statePtr) (at Library/PackageCache/com.unity.inputsystem@1.3.0/InputSystem/Controls/TouchPressControl.cs:49)
UnityEngine.InputSystem.InputControlExtensions.WriteValueIntoEvent[TValue] (UnityEngine.InputSystem.InputControl`1[TValue] control, TValue value, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr) (at Library/PackageCache/com.unity.inputsystem@1.3.0/InputSystem/Controls/InputControlExtensions.cs:418)
UnityEngine.InputSystem.OnScreen.OnScreenControl.SendValueToControl[TValue] (TValue value) (at Library/PackageCache/com.unity.inputsystem@1.3.0/InputSystem/Plugins/OnScreen/OnScreenControl.cs:196)
UnityEngine.InputSystem.OnScreen.OnScreenButton.OnPointerUp (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.inputsystem@1.3.0/InputSystem/Plugins/OnScreen/OnScreenButton.cs:20)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerUpHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
Hi! i'm really new to this input system, and i implemented my battle actions rn. I found this interface worth trying implementing, by myself:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : Entity, PlayerInputs.IBattleActions {
public static PlayerController Instance;
public List<Chip> actualChips;
public Chip BasicAttackChip;
public Chip BasicDefenseChip;
public new const EDirection FacingDirection = EDirection.Up;
private void Awake() {
Instance = this;
}
public void UseActualChip() {
actualChips[0].ExecuteChip(ActualCase, FacingDirection);
}
public void OnMoveRight(InputAction.CallbackContext context) {
Debug.Log(context);
MoveToCase(ActualCase.RightCase);
}
public void OnMoveLeft(InputAction.CallbackContext context) {
MoveToCase(ActualCase.LeftCase);
}
}
Is this not how it works? Bc it seems like it's not doing anything lol
How do I stop my button that is on a disabled canvas from being clicked?
When I press the submit button, the button that is on a disabled canvas gets clicked 😦
mouse delta is way too fast and sensitive. Any solutions people have found?
typically you multiply mouse delta by a sensitivity variable and allow the user to adjust it to their liking.
It's also possible you're doing something wrong in your code. One common mistake with mouse input is multiplying it by Time.deltaTime. That is unnecessary and in fact will add unpredictable jitter to the controls.
Hey there. So I need to implement local multiplayer. I have two cars with specific scripts and both have a PlayerInput Component and a script which checks for the input logic like for example this:
if (playerInput.actions["Accelerate"].IsPressed())
Now I have two controllers attached. But when I execute that action (pressing the button) both cars move, but that's exactly not what I want. Anything I missed to setup?
Use PlayerInputManager and PlayerInput. It will automatically assign players to devices
As said, the cars have the PlayerInput Component attached.
I tried the PlayerInputManager already, but it did nothing
No I'm not spawning them directly, I set the behaviour to "Join manually" bc the game is setup in a specific way (I'm porting the project)
but the InputManager recognizes the PlayerInputs at startup of the scene
I'm not an expert exactly on PlayerInputManager but it is typically the piece that handles all the assignment of different players to different input devices
if you're not using that you need to do that part yourself - not totally sure how it works
Yeah, so I was told, that#s why I included it.
As you see in the Debug Section, it recognizes the PlayerInputs, I dont know exactly why it's numbering that way with #0 and #3 since I think it should be #0 and #1...
Does this mean they are joined?
I made sure to omit Time.deltaTime, but in addition to that, my code is supposed to have an Object always update to the mouse's position, but the mouse delta is so fast it doesn't allow that to happen
that doesn't make sense
show the code
And what happens instead?
I do this by having a Vector2, VirtualMousePos which starts at Vector2.zero and then the mouse delta using Input system just does
virtualMousePos += MouseDelta
Ok but we need more context. Where is this code running?
Can you just share the whole script
And maybe a video of what's happening?
Third direc Func is just a func name btw
and this is the problem. When I move the mouse even slightly, the delta sensitivity goes wild
Can you show how you set up the input binding?
Did you use Delta or Position
Also how are you subscribing this function to the input action?
and UpdateMousePos just runs ThirdDirecFunc and then returns
and under the Binding properties are no Interactions or Processors
Can you remove the gamepad and joystick bindings for a minute
and also show the Look action itself
Also That looks different from the one above
but it looks good
TestLooking vs Look?
this is the binding for TestLooking
I didnt wanna delete Look so I just added TestLooking and made Look do nothing and TestLooking fire the UpdateMousePos method
@austere grotto I guess the multiple bindings were throwing it off
yeah - especially if you're mixing joystick style and poiinter style inputs
they get kinda funky
you could also have have a joystick that was leaning against a keyboard or something?
nope, literally just me and my laptop
hmmm, for some reason my VirtualMousePos += MouseDelta constantly returns a (-,-) value
idk, its just that when I move my mouse in any direction, my VirtualMousePos moves towards bottom left of the screen
what's a (-,-) value
its weird to describe. When I debug.log MouseDelta, it shows support for all four quadrants, but I think that when I do VirtualMousePos += MouseDelta, MouseDelta for some reason acts like its in the negative, negative quadrant
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour {
[SerializeField] private PlayerInput _playerInput;
public InputAction DebugModeToggle;
private void Awake() {
DebugModeToggle = _playerInput.actions["Toggle Debug"];
}
}```
private void Start() {
GameManager.Instance.InputManager.DebugModeToggle.started += ToggleDebug;
}```
Assets/Scripts/GridmapManager.cs(31,9): error CS0123: No overload for 'ToggleDebug' matches delegate 'Action<InputAction.CallbackContext>'
public void ToggleDebug() {
foreach(var item in _tiles){
if(item.Value.State == Tile.TileStates.Friendly) item.Value.Renderer.color = Color.green;
if(item.Value.State == Tile.TileStates.Nuetral) item.Value.Renderer.color = Color.yellow;
if(item.Value.State == Tile.TileStates.Hostile) item.Value.Renderer.color = Color.red;
}
}```
can someone please tell me why I throw that error?
Because ToggleDebug doesn't have the right signature
it needs to be an Action<InputAction.CallbackContext>
meaning it needs to take a InputAction.CallbackContext parameter
Oh thats no good
Hello everyone,
I'm encounter an issue with the new InputSystem and the Controls Changed Events :
I have a scirpt to manage the character movement and I would like to notice the event thaht specified thaht the player is switching between Keyboard+Mouse to a Gamepad mainly for the control of rotation of the player (Mouse or Right Stick)
public void OnDeviceChange (PlayerInput pi)
{
isGamepad = pi.controlSchemes.Equals("Gamepad") ? true : false;
}
But in the Controls Changed Events I don't see my function "OnDeviceChange"
I'm using Unity 2021.0.2f1 and the input System 1.3.0
Can someone please help me ?
Hey ppl I have been migrating to the new input system and some of my code is based on "OnMouseDown", OnMouseDrag" and OnMouseUp", I have been looking around for a bit to find good ways to replace this. Because its all related to an Specific object that needs to be clicked on. How would i go about checking this with the new input system ?
hey guys i wanted to ask one thing
like do we normally define the inputaction everytime we write a new script or its only meant to be instanced once?
on the YouTube video he named the inputactionreference variable jumpaction reference
you named yours inputaction
Im still having trouble getting controller vibration to work when connected over Bluetooth, Any Ideas?
https://forum.unity.com/threads/input-system-bluetooth-controller-vibration.1294047/
im making a local multiplayer game and am not used to unitys input system. I have everything working except I cant get double jump working because the unity input system is counting me holding it down as a jump is there a way i can make it have to be tapped because it will use up all the double jumps instantly because it counts me holding junp down
I am trying to make a typing game and I have no idea how to do this using Input System. I want to achieve something like this
ayo, so i'm creating a key rebinding system and after a bit of digging, it turns out that if i try to rebind an individual binding of a composite action, unity is going to throw an InvalidOperationException saying that its not possible. Is there truly no way for me to reassign a binding thats part of a composite action?
Without doing it manually in code ( i.e. Mouse.current.position.ReadValue()) is there a way to get the position in a InputAction.CallbackContext that was fired from a button press?
Ah. Never mind. I just switched it around. I made the mouse position the binding and the button the modifier.
I am fairly new here and this is confusing me cuz I don't have a mental map of where things go yet.
There is a pane of project settings such as the mapping of buttons and axes for the game controller. When I restart the sample game I am using (GameKit) it resets these assignments. Where would I look to find the actual main settings? I am using Cinemachine in this sample. I am trying to fix a bug where the sample is assigning the wrong axis to the game controller
I dont know why but the input system just randomly decided to brake. Has anyone experienced something like this or have i done something wrong?
is it set up as an axis input?
yes
Bruh after half an hour searching for the issue i found it there was a space that didnt belong there
or its not fixed now it always returns 0 and one Unity restart later everything is fixed restarting>debugging
Guess I still need an answer to my question. Can you read the modifiers of an InputAction in the code?
im using the input actions system and I cant figure out how to make it so when i press a button on a gamepad (from input actions) it does something in my code?
try following one of samyam's youtube videos
Is there anyone who knows how to change the split screen on the Player Input Manager to horizontal?
PlayerinputManager doesn't handle split screen
That'd be down to your cameras
PIM handles assigning input devices and spawning player prefabs
can anyone explain what is this?
Looks like a KeyNotFound exception to me
what does it means?
It means you tried to access a dictionary with a key that wasn't in the dictionary
You'd have to look at the stack trace of that error for more information
how do I do that?
Click on the error and look at the full log of it in the console
The full log contains the stack trace
ok
KeyNotFoundException: The given key '25210' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <d4cde64232cf45659d86aafa597faa77>:0)
UnityEditor.Presets.PresetEditor.DestroyInternalEditor () (at <36f62d8e760b48f7af5d32916f997ce1>:0)
UnityEditor.Presets.PresetEditor.OnDisable () (at <36f62d8e760b48f7af5d32916f997ce1>:0)
I don't understand any of this
Hi, i want to share my solution for doing Gamepad and Keyboard inputs with the unity new input system, it's more easy this way in my opinion : https://pastebin.com/urU09HSX
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.
How could I prevent a window from responding to input made on a previous window? I have a "confirm quit game" prompt but it's triggered by previous input. I'd like to know if I can do something right within the input system for these situations.
You can use an eventData so it's not used elsewhere https://docs.unity.cn/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.AbstractEventData.html#UnityEngine_EventSystems_AbstractEventData_Use
Thank you @austere grotto! I'll look into that.
can someone tell me if i can use a script to swap scenes and where i would have to put it (swap on a key press)
Not really an input system question
ok it seemed more up this ally cause of key stuff but my b
"how to detect a key press" is a separate question
yea sorry just couldnt really figure out where to put it
@austere grotto I just got around to reading what you shared and it's really useful. However, reading my question again I now think I wasn't clear enough.
I have a Quit button on my pause window that prompts another window to confirm if game should quit with a Cancel and Confirm button that are both triggered when triggering the Submit action (Enter key). When I press the enter key to quit the game the confirm prompt is triggered as well because the next button is also waiting for the Enter key to be pressed.
I managed to solve this by resetting the action when opening the new window but I'm not sure that's the cleanest solution:
private void ResetPromptWindow()
{
_isConfirm = null;
_inputManager.InputActions.UI.Submit.Reset();
_inputManager.InputActions.UI.Cancel.Reset();
}
private void Update()
{
if (_isConfirm != null) return;
if (_inputManager.InputActions.UI.Submit.triggered)
{
// Edit: Deleted this check to avoid confirming when
// pressing Enter while on Cancel button.
Confirm();
}
if (_inputManager.InputActions.UI.Cancel.triggered)
{
Cancel();
}
}
I think my main issue is not managing correctly the target of the input actions to the currently focused window because I'm also finding out just now that when I trigger the Cancel action (ESC key) the game resumes instead of just Cancelling the quit game prompt. I'd appreciate any tips or resources on this.
Alright, is there someone that might be able to help with the new Input System here? I've found a bug in the new Input System and I honestly have no idea how to get around it.
The main gist is that if I have 2 keys (doesn't matter which 2 keys) if you hold down the first key and then the 2nd key, if you lift up on the first key Unity never registers it and still thinks that you're pressing the key.
I've tried it with multiple keys, multiple actions types, multiple data types, anything and everything has this same behavior and it's a fairly basic behavior that occurs a lot in games. My example is movement, if I want to have walking and then hold shift to run, if the player ever stops holding the movement key while still holding shift they'll run forever.
And I can say, the only thing that works is that if the 2nd key is in a different action map then it's fine. So can a single action map only handle a single action at a time (seems silly no?)?
you'd have to show your code
There's nothing to the code, its quite literally just an interface implementing the input actions and firing events. I found even weirder, it's just shift that's the issue...
and doing what with the events?
there's something to the code, it may be important
"Unity never registers it and still thinks that you're pressing the key." - trying to figure out precisely what you mean by this
public void OnRun(InputAction.CallbackContext context)
{
RunEvent?.Invoke(context.phase);
}
Quite literally nothing
so what is Run and what is bound to it
Input Action
The class inherits from the Input Actions interface that's generated by InputActions, when you implement it and call .SetCallbacks it will fire your interface as the callbacks for the events registered in the Action maps.
Interestingly enough though, it only seems to be when you hold down shift Unity doesn't register any other key presses in play mode.
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
Ah
That's silly.
Is the input system purposefully designed to fire a cancel event if you have to concurrent inputs that are opposite of each other?
For example, If I press the w key and the s key at the same time or the left and right movement buttons at the same time. When I press both a cancel event is called even if I still have the button pressed
hey, does anyone have a way of taking an XRInput of trigger press and making it do a single action? Currently I'm using the left trigger press to spawn blocks, but since the trigger value is a bool and its in update method it spawns way too many blocks.
im thinking something like this, but make it only run BuildBlock once instead of every frame.
Use an extra bool as a lock
That’s vague, what would I do with this?
This can go
(Pretty sure it's inefficient)
Here's the manual page as well
https://docs.unity3d.com/Manual/xr_input.html
I'm completely new and been looking at various tutorials and guides, when it comes to 2D movement, some seem to use GetComponent<Rigidbody2D>().AddForce(new Vector2(x * speed, y)) and others use GetComponent<Rigidbody2D>().velocity = new Vector2(x * speed, y) - what's the actual difference between .. what i can see being the only difference .. using AddForce in this case vs not. Sorry if this is in the wrong section, if it is please let me know where to move it!
In this video I go over a few methods on how to move a player or an object around the screen. I think share my thoughts on which method is best for each use.
SUBSCRIBE: https://bit.ly/2Js78lE
In this video I discuss:
0:28 - Moving An Object Using Translate
2:20 - Problems with using Translate
2:50 - Using RigidBody for Physics & Co...
that vid goes into them
awesome, thank you!
What's the "appropriate" way to navigate a menu with the new input system, like with the unity UI assets (buttons, boxes, etc.) all linked up for tab order? I'm trying to google how to do it, but basically everything i can find ends up pointing me at code using the old input system
It's handled through the EventSystem and Input Module. Afaik the default input system input module implements UI navigation.
At the end of the day it's unlikely fundamentally any different, just collect the equivalent input from the new system.
alright, ill take a look, thanks!
yep, looks like that works, pretty much plug and play! thanks!
Sounds good, thanks man
(for VR) I have been trying to deconstruct the XRBaseInteractable Interactable Event architecture (i.e. Activate event listens for the Activate InputActionProperty InteractionState phase change) in an effort to add my own events.
I'm just wondering if anyone out there has been able to do this? At this point I just need to know its possible so I can keep trying lol
what's the recommended way for using touch screen input? new input system touch controls?
because i've heard that the old way is recommended for mobile
should i use this?
how do I get drag, pinch, camera zoom in and out? pinch scroll?
Is there a easy way to convert my old input system to the new unity input system?
in config, use both old and new if you are working on an old project
otherwise, just use new
project settings... its some where in there. might have to google it
I mean stuff like this:
private void MyInput()
{
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
and stuff like
if (Input.GetKeyDown(slideKey)
you are going to have to re-write the code.
Like, i want to add controller support, and its easier with the new input system, but can i even add controller support with the new system and use keyboard with the old system?
🤔
however, if you can't/don't want to, you can go to project settings and use both old and new input system
might take a performance hit, I've no idea.
yup, the new input system is designed to replace the old one. try to replace all of they keyboard stuff w/ new input if you can
otherwise, start your next project with the new input system. It isn't too hard to learn, I learned it all during a day's time in the middle of a game jam
I recommend samyam's tutorial on youtube
Cus i already have all my scripts with the old system
xd
and i want to change to the new one, but i have no clue how/where to change my code ;/
and no clue what to change it to
Is it a really really bad thing to use the old input system then?
Or is it still fully usable ?
But will i have big disadvantages? Or is the new system the same but just easier/more friendly to use 🙂
Sorry for all my questions lol, its hard xD
Fully usable.
The new system is much harder to use, especially if you're a beginner. But it's more powerful and flexible.
Good evening, running into an issue where holding the joystick in any position scales the input up to the maximum magnitude in the given direction. I’m using a callback on my InputAction to store the resulting Vector2 from the left stick input
private Vector2 move;
public void OnMove(InputAction.CallbackContext context)
move = context.ReadValue<Vector2>()
Debugging the value of move here always looks correct - the Vector2 returned by ReadValue has the expected values.
Inside of an Update I read the private variable move and send it’s magnitude to my Animator. If I debug the value of move at the start of the Update function it’s already displaying the unwanted behavior of maxing out the input. So if I’m slightly tilting the stick forward it believes the Vector2 is (0, 1) even though the debug log in the OnMove callback is still showing the correct values. Note that it only happens when I'm holding it at a given position in the 2D vector space - when moving the stick the values are briefly correct until I've held the stick for too long in one spot.
I have tried using FixedUpdate instead of Update and I have made sure that my controller is working otherwise using the input debugger. I made sure I am not assigning to move anywhere outside of the OnMove callback. It's almost like the input is stacking on itself really quickly because I've noticed that the value of move.magnitude grows exponentially in my Update function despite looking 'correct' in the OnMove callback.
Is there something fundamental I’m missing here? Thank you for your time.
are you ever normalizing the move vector? Maybe later in your update routine, after sending it the animator?
what's the difference between horizontal & debug horizontal
public UnityEvent onPress;
public UnityEvent onHold;
public UnityEvent onRelease;
I feel like a total scrub. I want to make a simple script that triggers UnityEvents like these. [should be pretty self-explanitory.]
create an Input Action with a Hold interaction. The action's started event is onPress, performed is onHold, and canceled is onRelease
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Interactions.html
I guess making an action on the script doesn't help?
I mean... you could, but setting up all the bindings with your actual input devices would be a pain. It is a lot easier to do it through the ui
so i'm seeing a really weird issue with jumping and I really don't understand why.
The jump code i'm using: rb.velocity = new Vector2(rb.velocity.x, jumpHeight); (rb being a reference to rigidbody). I've also added a debug statement above, just printing out 'space pressed'.
When I add the above to Update() (my understanding is that using vector2 should be added here rather than FixedUpdate()), it does work.. kind of. I can see the debug statement being printed in the console every time I press space, but the actual jump only happens about 1/5 times.
I tried the same jump code block in FixedUpdate() just to see what happens. When I did this, i get similar behaviour, except this time the debug is also only printed at the time when the jump is successful vs every time space is pressed(note that the debug statement is before the actual jump code).
What am I doing wrong?
big facepalm moment, i was using rb.position.y in movement, I changed it to rb.velocity.y and everything works perfectly - I'm not sure why this happens.. so i guess i'll need to do a little reading haha.
if(Input.GetKey(KeyCode.LeftShift)){
if(_pressTime < _pressTimeTollerance) {
_pressTime += Time.deltaTime;
}
else{
speed = 20f;
}
}
else if (Input.GetKeyUp(KeyCode.LeftShift))
{
if(_pressTime < _pressTimeTollerance){
speed = 10f;
}
_pressTime = 0f;
}```
Im making a sprinting system, I want `speed = 20f` activate when i HOLD down shift, but instead it requires me to click shift again to turn off sprinting, help?
In the `void update` method
also i have these 2 floats
private float _pressTime;
private const float _pressTimeTollerance = 0.05f;```
it requires to click again because you are using GetKeyUp I think
Ye well I dont think thats how getkeyup works
from what ive read, getkeyup activates when im holding a key, but then i stop holding it
Returns true during the frame the user releases the key identified by name.
do you need the timer? is it for delaying the sprint end?
if you mean _pressTime, then i use it so Sprinting doesnt activate instantly after clicked shift
instead do Input.GetAxis with the shift as axis https://docs.unity3d.com/ScriptReference/Input.GetAxis.html
you can configure the axis to increase to 1 once held in say 0.5 seconds and decrease after you stop holding it in 0.05 seconds
then you check if the axis is over or equal .99 to activate it
Alright thanks lemme check it
(the input manager is in project settings)
It's not necessarily recommended, but it is far more powerful. It makes it a lot easier to support multiple input device types and multiple input maps (ie, running controls vs. driving controls).
But it comes at the cost of requiring a more advanced understanding of code, since it's a little abstract (what makes it powerful).
It seems to be really hard to get controller support working with the old system (code wise)
Yep, hence why the new input system is great for that. No code needed to add additional support, just add the controller button to the mapping.
Is general C# experience enough for this?
Cus i make applications/software
Im new to game development ;p
Sure. Unity has a primer video tutorial on the system on their YouTube channel. Check it out and see
is it bad to still be using the old input system?
hey,can someone tell me how to make basic movement with the input action thing you can download
cause im watching a tutorial but its quite old so im not sure if stuff still looks like what tutorial is showing
cause its saying to add a 2d vector composite,and i ain't finding the option
it was renamed
it's called Up Left Right Down composite now
um,i still dont see it
your action needs to be configured as:
Action Type: Value
Control Type: Vector2
then you will see it
i got negative/positive and one and two modifier
you have the wrong action type/control type
got it