#๐ฑ๏ธโinput-system
1 messages ยท Page 62 of 1
jump?
like,jumping
I don't know anything about the tutorial you're following.
no like,making the bean jump
Yeah I understand you're talking about making your character jump. I can't tell you if it "works the same" because I have no idea how it works in your tutorial
Most likely it's fine
Hey! I am using the new input system and I'm adding sprint to the character. what would the code be? triggered is well... just toggling
how do u open it cause im too new to this,i dont even know how to open the script editor
@cloud anvil https://www.youtube.com/watch?v=yRI44aYLDQs&t=6s
How to use the new input system in Unity! Next video will show how to make a character controller using the input system.
๐ฅ Get the Source Code ๐ฅ
https://www.patreon.com/posts/38331467
๐ Relevant Video Links ๐
แ
Next part
Make a SIMPLE Character Controller using Unity's NEW Input System
https://youtu.be/w1vC32e11wU
แ
Playlist
Unity Beginner Mini...
thx
.
No
k thx
Its better in some ways
what should i use,visual studio editor or code editor
in package manager i only got visual studio code editor and visual studio editor
How does writing custom composites work? I don't understand the docs. https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/manual/ActionBindings.html#writing-custom-composites
It says create a a class based on InputBindingComposite<TValue>. How do I do so? Do I just copy the code provided into a new script called InputBindingComposite, and then edit that code?
both seem to be the same
now that i look,both are in my project but still doesnt seem to open the code editor
ok nevermind
Okay so I was able to do what I just described. However I do not know how to get my Custom Composite to actually show up as a drop-down option from the list of Input Bindings inside the InputActions Asset Window Nevermind. It did it automatically. I think as long as include using UnityEditor it should be fine.
I can't figure this out
got any ideas?
it's simple enough for me to understand whats going on,but i cant figure the issue
ive used like 4y ago C++ so i know a bit about whats going on,but not enough
i tried sth else and now i got 7 errors ๐
I didnt?
in wich line?
dont thell me that i had to write playerInput instead of PlayerInput
so the p is not caps
so i have to switch it with with what u wrote here,basically
and i guess that P instead of p makes a difference
makes sense
thanks for your help,ill deal with the issues tomorrow
I am having a similar issue that mentioned by agent5 awhile ago, but I don't see if it was ever addressed #๐ฑ๏ธโinput-system message
it's like it's dropping tons of scroll inputs
mouse scroll works fine in any other context
It's also happening on 2 different mice
if I scroll somewhat slowly, it doesn't pick up any input at all
Action:
binding:
@barren stump How about something like this
@cloud anvil Depends on what you're after :)
If it's how to screenshot: https://www.take-a-screenshot.org/
If it's how to handle movement, you're going to want to complete this tutorial: https://learn.unity.com/project/using-the-input-system-in-unity
Hey! Is there a way in the new input system that i can disable all external devices (mouse, gamepad, keyboard etc) and then add my own? I want to preserve bindings. For example I disable gamepad, add one programmatically then queue event via code that trigger X button on my "mocked" gamepad
is this using an older version of the input system or something? it's giving me an error that "PlayerControls" doesnt exist.
I do have the input directive for the input system
@barren stump
oooh the PlayerControls is the inputactions asset
for it was generated to have the same name as the project
why is it so hard to add movement
thanks, I was able to fix. the problem was that I had my camera movement processing in fixed update
um...can someone help me with the namespace stuff
This is not "namespace stuff" this is "You should learn the basics of the C# programming language" stuff
yea....i will after im done with the finals
Hey Is there a way in the new input
Anyone?
Does anyone know how to assign a user to a game object. I have a character select screne which creates the different users, then the scene loads the level. my spawn points spawn all the players that are going to be playing, but the player input component on my player prefab is creating an additional user
is there a way to simulate touch/tap events from editor with the new input system? Trying to google it only yields results relating to the default input system
clicking with the mouse works
I wont need anything more than this?
Looking at that link, this doesnt exist. Is it a module I have to add? I am using the new input systems
its not a thing that exists
I dont see anything to add or enable it
Sould just be part of the input system package
Make sure those are real errors in Unity not just in your IDE
Whatever is current and latest, version 1.3.0
yup doesnt exist
Its not working and I cant diagnose why, Im googling but there are no answers, type or namespace doesnt exist
I literally just made a new project, installed new input system, tried to register touch, and it doesnt work, doesnt recognize
I havent done a single fancy special thing,I havent changed any settings
https://gamedev-resources.com/implementing-touch-with-input-systems-enhanced-touch-api/ this tutorial says I should use the old input systems
I found the input debug options to turn on 'mouse click as tap'
How do I get the touch position from the new input system?
For mouse you can do this (pictured) but that only works because it gets the mouse position every frame, I need the tap position before the tap itself executes
uh, I have no idea wtf is going on but the top one doesnt work and the bottom one does work
if I rem out the top one, it understands the bottom one
I dont see a difference
those are exactly identical in my eyes
can anyone explain this?
like, im not crazy, that's impossible and stupid, right?
gif above, any idea why this is the case?
Im not trying to solve the bug, im trying to understand what the bug is in the first place so that it never happens again
I can just use the bottom one of I want the bug to go away
doesnt it say in the place where errors show up?
but that shouldnt be neccessary because what is happening there is impossible
the top one just says 'type or namespace' doesnt exist, standard error
i had that issue too
after saving, quitting, reopening it, now it has tons of ?s in it
apparently writing "namespace UnityEngine.InputSystem" did it for me,but i ditched that code for another one,cause that one had like 5 errors i couldnt figure out
but dont take my word,im very very new to this
and very bad
but ill get better
https://cdn.discordapp.com/attachments/763502300781477948/987417967052591184/why_tho.gif @austere grotto Name that IDE.
how do I attach an inputuser to a gameobject? like, attach controller A to player object A. I have my character select screen and add the playerconfigurations to a list. now in the game, I need to attach those configurations to the players.
@rugged ingot One of the best examples of this available is the Unity "Vikings" demo
@west oracle I watched the youtube video that unity made. I didn't know the demo would help. I will download it. Thank you
I also made a pile of these a while back; its a bit outdated now but the last one (local multiplayer) could be of use to you
Awesome thanks!
How do I raycast a tapped position?
everything im trying is failing, and googling isnt yielding any results either
this is stupid, this should be simple, literally every single mobile app in the world has to do this basic step
so why is there no reasources
Are you trying to raycast into the 3D scene, or onto the UI?
I dont know? Im trying to physics2D raycast but it doesnt hit anything
the DrawRay doesnt draw anything
I cannot find the debug anywhere in the scene at all
I dont even have a canvas yet
Is it possible to make a mod for a game with a different input system?
Like is it possible to make 2 mods for the same game but they both have different systems?
If you have source code anything is possible ๐
Right but how do I actually use it https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-GraphicRaycaster.html
nothing on this page is a tutorial explaining step by step to make it actually do a function
lol thats fair - this document is shit
What're you trying to accomplish in general? I'll get ya a headstart ๐
I want to interact with literal any elements of the game
I cant even register a raycast right now
I feel fucking stupid because this is bellow baby tier, this is literally the most basic of basic literally every mobile app must have
why is everything so hard, why am I so fucking stupid
There's a few approaches! If you want to use the Unity EventSystem, you go the Physics2DRaycaster approach. if you want to directly raycast, your method pasted above is pretty close
EventSystem is probably the most "Modern" with built-in events like multitouch, drag, drop, etc
What Unity version ya on?
What is the event system and how does it relate to the new input system? Ive heard of 'unity Events' but not some kind of system.
I am on not on latest 2020.3.32
2021?
turns out I am on 2020.3.32
I just assumed a brand new project would have been latest by default but I guess thats just another way that im stupid, assuming a new thing would default to new
lol, changing Unity versions is a big commitment ๐
Lemme whip up a quick example of 2D Physics Object interactions
I don't even want this to be a physics object, I am just trying to register the tap
there is no physics interaction going to be happening of any kind
Yes
or is it a Canvas Object?
all "Colliders" in unity are based on Physics. the Canvas stuff is entirely separate.
Collider2D, because thats the only way in past projects ive been able to get raycasting to work
gotcha - yea thats "Physics2D"
If this is for mobile I should probably throw all this out and do Canvas shouldnt I? because it actually matters on mobile performance stuff like that?
(Honestly 2D phys is probably more efficient than canvas; but Canvas has a lot of quality of life features for UI things like masking, scrollbars, etc)
Yeah I might have to add canvas later for UI stuff but right now I was focusing on the game interactions
Downloading
Unity wont let me drag that in, and it wont show up in the folder that its in when I go package manager -> import
why does everything have to so hard
why is there a difference between import package and import package
different type of package ๐
(Unreal is even worse about this - it stems from being a technology platform thats been around for more than 10 years)
Yeah a ton of bad decisions stacked on worse decisions that cant change because of legacy code ๐ฌ
I have been since 2018 yet somehow I still cannot do the most basic thing
I am looking at your package and I have no idea how any of it works. There doesnt appear to be any code at all? Yet it registered a tap
ClickableObject.cs
Yes I looked at it thats what I mean, it has nothing but a debug.log
there's no code there at all to handle a click, raycast, etc
Correct! It implements the IPointerClick handler
the EventSystem, and Physics2DRaycaster do the heavy lifting with this method
so your objects only need simple interfaces
when I try to goto implimentation it cant because I assume its a unity package thing
I really don't like using external packages like this because I have no idea at all how to use it, like its great that it does this ONE narrow use case, but the instant I have to do anything else other than click a thing, I can't do it because im rely on a black box that I have no comprension of
its not external
external to my own code base*
its been built into Unity since ~2012
If you wanna do your own barebones raycasts I can make an example of that too!
EventSystem is just a quick n' simple way to deal with it.
for mobile in particular, it greatly simplifies dealing with multitouch
the 'right' answer is that I should be using event system if it does everything better
I do barebones sometimes too ๐ depends on the situation
but for example, you can get the ray from inside that method too
Will this even work on mobile? Because it says 'pointerclick' and mobile devices have neither pointers nor clicks
https://docs.unity3d.com/ScriptReference/30_search.html?q=IPointerClickHandler.html no results for doccumentation
"Tap" and "Click" are pretty synonymous
In my experience I can never make any kind of assumption like that, as soon a I assume tap and click are synonmous, thats when something breaks because it ONLY recieves one thing
and its worse because I cannot find the internals of this thing to gain comprehension of it
Thank you for your help by the way, I would be stuck, lost, and probably in mental health crisis right now without it
thats what the discord is for! ๐
im supposed to be a professional developer but I can't do a single thing right and I get into agonizing pain the instant anything doesnt work right :/
iunno how everyone else handles this stress pain
persevere! its worth it.
https://forum.unity.com/threads/eventsystem-vs-new-input-system.850840/
so should I even be using the new input system?
because I am not seeing the linkages between that and the event system, and your example takes a tap without even considering the new input system at all
"Yes" ๐ฆ
it does actually!
If you add a Standalone Input Module, but have the New Input System enabled, it'll prompt you to update yours tuff
which it does pretty seamlessly ๐
ya - there you go.
wrangling the new input system itself can be a whole couple days of learning though lol
I defer to my own tutorials ๐
Anyway, this is why I say the "EventSystem" approach is probably the easiest to get started with.
Once those few modules are setup, you're pretty good to go with interactions using tap, gamepad, mouse, keyboard, etc.
thank you for the help, I will look at those tutorials
im afraid im in mental health freefall now and deeply in crisis because im a worthless failure so ill read them later after im done self abusing
Take care of yourself โค๏ธ Learning new things can help in a lot of ways on that front.
How Can i fix that my keyboard wasd and GamePad Left JoyStick uses same axis so how can i use it differently
So its like i am using split screen so 2nd player uses joystick to control and 1st player uses wasd(Keyboard) but as i am Using Horizontal and Vertical as my KeyBoard WASD when i try using left joystick it also control the player 1
Please tell me this is just a bug. Even with an array of Input Actions, they all just match each other. I'm SO close to getting this working.
Input manager
How'd you get here? What are we looking at? Give us some context
Yes I am using input manager...
That's where you set that stuff up
Ya bcz i am a beginner and the new input system is kinda hard for me
Tried making an array of Input Actions, but whenever I add a binding or change anything, it affects all entries of the array
But how did you create them
Sounds like you have a bunch of references to the same action in your list
public InputAction[] input;
Something like this
I donโt have an Actions file set up iirc. I thought I found a way to get away with not using it because of how itโs all structured
I mean how did you add actions to it
there anyone here who knows what the input key for left mouse button is,cause i aint finding it
nevermind
fixed it
Array of actions issues
hey im watching this tutorial and i have several questions
https://www.youtube.com/watch?v=HmXU4dZbaMw
The "new" Input System in Unity still doesn't come pre-packaged and is complicated to understand at a glance. It's no surprise new game developers don't know where to look in the engine to find it, or how to use it.
In this tutorial, learn how a beginner can adapt their current project to use the new input system in a simple way, as well as usi...
- he adds a PlayerInput component every single time, but then proceeds to delete it shortly afterwards? Whats the purpose of this component then?
- whats the purpose of the C# script that you can generate? He doesnt explain it enough for me
@sick dock I'd say putting "EASILY" in the title of that video is misleading. He's throwing around this and that, jumping all over the place, without explaining most of it. The actual tutorial is a much cleaner approach: https://learn.unity.com/project/using-the-input-system-in-unity
thanks
im looking at the unity tutorial now for the input system
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
private Rigidbody rb;
private float movementX;
private float movementY;
public float speed = 1;
void Start()
{
rb = GetComponent<Rigidbody>();
}
private void OnMove(InputValue movementValue)
{
Vector2 movementVector = movementValue.Get<Vector2>();
movementX = movementVector.x;
movementY = movementVector.y;
}
void FixedUpdate()
{
Vector3 movement = new Vector3(movementX, 0.0f, movementY);
rb.AddForce(movement * speed);
}
}```
they provide this script for the roll-a-ball movement
how does it get movement? does OnMove get called implicitly whenever you move?
Keep going :p They didn't piece it out into 11 parts just for shit and giggles
hey quick question
if i want to use several buttons to activate an ability
eg hold down shift and then hit w twice to activate dash
how would i do that?
Can someone link me to a tutorial that ACTUALLY answers "TAP (NOT click, NOT a mouse) on an object, and get that object"
Ive tried like 4-5 times now and it fails every single time, every single attempt to physics2d raycast fails, every single time
it never detects the thing ever
and visual studio wont debug it right, and I cant find any tutorials that answer tihs, and all the turorials I do find are completely bogus bullshit unrelated that dont work
I feel like im taking crazy pills, I feel like EVERY SINGLE TIME I try to do ANYTHING, I am always the FIRST person who has EVER attempted to do it, because the entire fucking internet is utterly completely barren devoid of answers
or more likely its SO simple that NO ONE has ever failed to this before, and im just that fucking worthlessly stupid that icant get something so fucking simple a literal baby could do it
line for line copied from the net, never hits a collider
show me how I misunderstood literally copied line for line code, zero original code of my own
You just gave me a bunch of mouse answers that are completely utterly useless to me because this is not about a mouse
I'm not using the old system, sorry that wasnt clear
What do you mean by that?
Hello, I've been trying to make a simple character controller using the new input system and I can't find a way to jump :/ please help
I have a 2d collider box, thats it, and im clicking tapping on it
there is no game, there is no other systems, there is nothing to debug, there is just a collider2d, and me tapping it, and no hits
Ive tried every single type of physics2d hit test, no hits, Physics2D.OverlapPoint, no hits
i must be just too fucking stupid to see what other successful competent people can see when they look at it, the answer is obvious to them but its not obvious to me and I hate it
i get more and more bitter and frustrated every single day i try to program anything despite doing C# 9-5 for about 4 years now
nothing fucking works, im too fucking stupid to succeed at a single thing, i cannot find a single person who will just help me, and there are no useful resources online becaue im too fucking stupid to comprehend them
I would like to help you but I don't know how I could do it. I don't even remember how to code a stupid jump...
im pretty much in mental health crisis 24/7 every single time I try to do anything
id love to try to help you but im too stupid
I reached out for help in like a dozen rooms in a dozen gamedev discords, no answer or help in any of them
those who can, do, those who cannot, dont hang out helping idiots like me in gamedev discords
my last braincell died when I installed cinemachine for the first time
Thanks for the link but that didnt help. That is related to canvas, I am trying to us the new input system to touch game objects in the 2d game scene
How can I make my TitleScreen, PauseScreen work with a controller?
I basically want the controller to choose the different options with a joystick
UI navigation is the keyword you are looking for. There are some tooling for this in EventSystem/InputModule.
and how do i get it to work?
HI, I'm using cinemachine, and i want to use it with mobile, so I want to:
With the onSwipe on Mobile the camera should rotate around the object
With Pinch (two finger zoom-in or zoom-out) I want to zoom in/out to the object in the scene
Is this possible?
So, I seem to be unable to use the keyboard all of a sudden. I did some breakpoints and found the function that is subscribed to the "Move" action just is not being called ever. I checked the version history in git and the player input asset hasn't changed in months. Is there something I could have broken in the project settings or anything that would make the keyboard just not register inputs? The maps are enabled, the mouse controls on it work just fine, and I can plug in a gamepad and it'll do everything, including the functions I can't get to work on the keyboard.
Actually, nevermind. I figured it out. Apparently, since I started Unity while remoted in to the computer, it is still trying to read input from that keyboard. A simple restart solved the problem
I'm trying to get input actions to work so that my enemy can react when it's clicked on. Unfortunately I don't see the callback function available here even though it has the right signature. What could it be?
alright, thanks!
I am using the new input system and my scene has 4 players in it. its a local multiplayer game and currently I can assign the current keyboard to one players and the current gamepad to another but can separate gamepads and keyboards. everything is just using gamepad current. I have been searching for 2 days and everything is saying to use input managers and player input stuff but I cant because my scene already starts with 4 players and I would have to insatiate the players. I need a way to get individual input devices and assign them to scripts.
https://gdl.space/nipuwetuga.coffeescript
This is the main bit of code I want to change. instead of trying to make them each equal to Gamepad.current I need to make the each a different gamepad. but you cant get specific gamepads. or at least I dont know how
is there a way to get a PointerEventData associated with an input system event?
for example, a UI/Click
is the expectation i just raycast myself?
alternatively, is there an EventSystem subclass maintained online that is better featured?
It comes in as a parameter when you use IPointerClickHandler etc.
well i'm really looking for retrieving the pointer event data / PointerModel associated with a given InputSystem Pointer / callback context
which the input module from input system has, but is not exposed publicly
the purpose being i'm trying to harmonize things that use input action references with things that use event system, like a camera control versus the UI
i'm not really sure why they declare it internal instead of protected
would have been a lot less painful...
A lot of people make custom input modules extending from the Unity ones, maybe explore that.
Is it possible to create a function there when i click "Shift" i will accelerate and stop clicking i slow down.
Why wouldn't it be possible?
I tried to create it but it fail.
i have a moveSpeed variable for the normal walking speed and have a "OnShift" Function to represent the moment where i click the shift key.
I try to put when i click the key, my speed increase like put moveSpeed + 10 but when i don't know how to make it go back to the normal speed
This is what i did but don't know what to do to return back to normal speed
I was thinking of a code where it can tell if i click shift the movespeed variable change and when i let go of it, it will return to normal.
You're in luck today, my friend! It's covered in this tutorial https://learn.unity.com/project/using-the-input-system-in-unity
(4th chapter)
how can i access the UI Input System? I was trying too but wasn't successfull instead i created another one in default section to do the same thing as i intended to do
i tried to use OnFire() but couldn't is there anything i was missing?
Hi, I have an issue unsubscribing from one particular action:
If I subscribe like this:
InputManager.inputActions.Gameplay.ZoomToggle.performed += obj => shooting.Zoom();
InputManager.inputActions.Gameplay.ZoomToggle.Enable();
And unsubscribe like this:
InputManager.inputActions.Gameplay.ZoomToggle.performed -= obj => shooting.Zoom();
InputManager.inputActions.Gameplay.ZoomToggle.Disable();
I'm getting MissingReferenceExceptions for this action when reloading the scene.
But If I subscribe like this:
InputManager.inputActions.Gameplay.ZoomToggle.performed += ZoomToggle;
InputManager.inputActions.Gameplay.ZoomToggle.Enable();
private void ZoomToggle(InputAction.CallbackContext obj)
{
shooting.Zoom();
}
And unsubscribe like this:
InputManager.inputActions.Gameplay.ZoomToggle.performed -= ZoomToggle;
(Seems I don't even need a Disable() )
There are no issues.
- From all other actions that seem to be sub- and unsubscribing the same way, why is this particular action causing issues?
- Why does the second method of subscribing resolve the issue?
Any help would be appreciated.
You can't unsubscribe with a lambda like that. It's not the same lambda instance
That's weird, unfortunately I don't remember where I got this from. But, I'm sub- and unsubscribing (apparently not?) this way with three other actions and there's no issue whatsoever. That's why I was wondering why the last action didn't work.
All I can tell you is that when you subscribe with an anonymous lambda like that, it is impossible to properly unsubscribe since you don't store a reference to the delegate anywhere
I am using the new input system and my scene has 4 players in it. its a local multiplayer game and currently I can assign the current keyboard to one players and the current gamepad to another but can separate gamepads and keyboards. everything is just using gamepad current. I have been searching for 3 days and everything is saying to use input managers and player input stuff but I cant because my scene already starts with 4 players and I would have to insatiate the players. I need a way to get individual input devices and assign them to scripts.
https://gdl.space/nipuwetuga.coffeescript
This is the main bit of code I want to change. instead of trying to make them each equal to Gamepad.current I need to make the each a different gamepad. but you cant get specific gamepads. or at least I dont know how
I'm using the new input system but as soon as I add a Canvas these errors start popping up. Any idea what is causing this?
Answering my own question: apparently the Event System has an Input component. Switching that out with the new input system fixes the errors. Yay!
Input Module - yep
Thanks
Hey guys, I've been using the new input system to create an OnScreenJoystick for my mobile game
the only issue I have tho is that the joystick is fixed
is their anyway to make a floating joystick that appears when the screen is tapped
Good to know, thanks! ๐
how make a joystick that follow pointer down position? with input system.
There are some on-screen touch joystick examples in the docs
check the optional items in the Input System package download
Hey guys, is there a way to make the Input System UI Input module play nice with action maps? I want to be able to enable my gameplay action map and all the UI action map be disable, but it doesn't work
Should I use Quarternion and Vector 3 for movement and rotations? Or is something like this good enough: https://www.toptal.com/developers/hastebin/ahuxiduxok.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I am using the new input system and my scene has 4 players in it. its a local multiplayer game and currently I can assign the current keyboard to one players and the current gamepad to another but can separate gamepads and keyboards. everything is just using gamepad current. I have been searching for 4 days and everything is saying to use input managers and player input stuff but I cant because my scene already starts with 4 players and I would have to insatiate the players. I need a way to get individual input devices and assign them to scripts.
https://gdl.space/nipuwetuga.coffeescript
This is the main bit of code I want to change. instead of trying to make them each equal to Gamepad.current I need to make the each a different gamepad. something kinda like X = gampad1.xButton.WasRealisedThisFrame; but you cant get specific gamepads. or at least I dont know how.. anyone know how??
does anyone know a good keybind rebinding tutorial?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/HowDoI.html#create-a-ui-to-rebind-input-in-my-game
The docs say the Tanks Demo sample has an example of a rebinding UI.
thanks im gonna try that
i cant find the demo sample
*pain
idont see any examples of a rebinding ui
https://gdl.space/apeqepahaq.cs
Hello I seem to be having a problem with making my Movement code link to my Action inputs and also how I make the flip function work only when the A and D key pressed, at the moment it just flips the sprite on every keypress and my movement code is not working.
hey guys
I'm using a joystick from brackeys tutorial
everything seems to work fine
but when I move my player to left
and release joystick
he keeps moving left
same is the case with all other sides
any idea how I can resolve this issue
hi im using unitys new input system and i cant go up stairs is there any videos that can help me with this
how do i capture a mouse hold on touch screen devices
it seems like its triggering both press and release at the same time
yes use SwitchActionMap
Anyone ?
Hi i tried to make the player capable of jumping once and then not being able to do it again by putting an is grounded check it worked and i could only jump once then when i landed i wouldnt be able to move at all so i put another is grounded check that would say if Isgrounded = true then you could walk however now i am back to the start with infinite jumps being a thing
How do I find out if the mouse is over a UI element (Unity UI)? IsPointerOverGameObject gives a warning saying not to use it within an InputAction callback. And it seems to return true when it is over ANY game object, even non-UI objects.
What I was trying to do:
public void OnClick(InputAction.CallbackContext context)
{
if (context.performed && !EventSystem.current.IsPointerOverGameObject())
{
Debug.LogFormat(this, "OnClick: {0}", context);
}
}
How am I supposed to do this?
what are you trying to accomplish?
Move the player to where they clicked, but only if they did not click on the UI.
Why not embrace the event system? Use IPointerClickHandler to detect when the player clicked on the game world
then you won't have to worry about it going through UI
IPointerClickHandler only works if you have a collider on the game object though, right?
yes
So I'd have to have the background tell the player controller that it was clicked, and the click position?
Because I don't know what else to attach the collider to...
And if I also want to select an object if the player double-clicks it, then have a script that implements IPointerClickHandler on each selectable object, and have them notify a SelectionManager or something to say "hey, I was clicked"?
something like that.
Layers, layer masks, and layer based collision
Hey fellas
I have a character controller system where the mouse is really jerky and janky, and I'm on a dynamic update system rather than fixed
by the way the fps remained around 120
its only in the mouse
Be sure to @ me if you know something
my assumption is that it's a Time.deltaTime problem?
Building the scene fixed it, how can I make it work in editor?
I've heard something about Time.deltaTime making the mouse jerky, can it maybe be that?
This is the reason
Mouse input is already frame independent as it's expressed in raw movement units, rather than a state (like keyboard keys) that affects movement over time.
how can I remove all events for all inputs in the new input system? I have an issue where when my player gets recreated its still trying to invoke events on destroyed scripts and gameobjects as well as the new player
also do I have to make them all use an InputAction? because currently I'm just doing something like playerInput.actions["Interact"].performed += interact => Interacted(); which from what I have heard makes a new lambda meaning I cant just remove them
apparently you cant remove if you use lambda
also you're subscribing in a non-traditional way
why not use a method that accepts callback context
So, you can define an Input System action in the inspector, right?
action = GetComponent<PlayerInput>().actions["Place Object"];
action.performed += AttemptPlaceClient;
ok so I have tried this
now is their an easier way to get all the actions assigned to a GetComponent<PlayerInput>().actions and unsubscribe them from all events
Not as far as im aware
If you use the player input component you wont have to worry about that tho
The way I'd do it is to keep player input in its own empty object thats never destroyed, and actual player locomotion script has a reference to it
I believe thays the way unity does it with their sample projects
Fire button not working
Hi all
My goal is to provide for my mobile game experience, similar to this video: https://youtu.be/P5JxTfCAOXo?t=492
I am talking about feature that allows you rotate in real world while holding your phone, and rotate your camera in game world same way
The problem is, my phone (and most phones) don't have gyroscope
I tried to use UnityEngine.InputSystem.AttitudeSensor instead of gyroscope - i believe its similar thing but it uses accelerometer to detect player's phone attitude
It would work fine, but it has strange behavior: while you rotate along any axis, rotation degree goes from 1 to 180 (for example) and then goes reverse, and this completely breaks rotation in game world. Maybe someone know how to handle this?
In this video, we look at how to use the Gyroscope, we also implement a simple mechanic that helps us look at around our scene, using real world orientation
โบ-------------------------------------------------------โ
Join the community, keep on learning.
โบ Come hang out in discord! This is the most efficient way to reach not only the team member...
Hello, I'm trying to use the new input system by subscribing and unsubscribing to events at runtime so I can have inputs that do different things for items. However, I get a couple null reference exceptions when I perform the inputs. Any help?
NullReferenceException: Object reference not set to an instance of an object
Game.ItemSystem.Items.Firearms.Gunplay.GunViewModel.Shoot () (at Assets/Scripts/Game/ItemSystem/Items/Firearms/Gunplay/GunViewModel.cs:342)
Game.ItemSystem.Items.Firearms.Gunplay.GunViewModel.SemiAuto (UnityEngine.InputSystem.InputAction+CallbackContext callbackContext) (at Assets/Scripts/Game/ItemSystem/Items/Firearms/Gunplay/GunViewModel.cs:288)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.CallbackArray`1[System.Action`1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at Library/PackageCache/com.unity.inputsystem@1.3.0/InputSystem/Utilities/DelegateHelpers.cs:46)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
NullReferenceException while executing 'performed' callbacks of 'Player/Fire[/Mouse/leftButton]'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
Sometimes I also get this error when Im subscribing to inputs
ArgumentException: Value does not fall within the expected range.
Game.ItemSystem.Items.Firearms.Firearm.SubscribeToInputEvents ()
k ill look into it
this looks like you're not unsubscribing properly to me
or you missed an unsub somewhere
Instead of subscribing and unsubscribing you could create a class that manage the events of the input system and create a layer of abstraction. For example if you want that the player moves only sometimes add to the InputClass a Vector3 property, that represent the direction of the movement, it will be always updated even if the player can't move and let manage the player's movement by the player's script.
Do you mean like not subscribing directly to the unity input events but having my own events that unity input subscribed to?
Yes this is also an alternative that you could choose
I'm confused what your saying here tho. What exactly do you mean by "manage the events of the input system"?
Like what I'm trying to do is subscribe to events at runtime since I have a inventory system and I want to subscribe and unsubcribe to different input events as I change the item im using
It depends on what you have to do
Could also just fix your sub/unsub code
Just create an object for each item and then change the reference of that object
I can remember that I had in the past the same problem
For me had been much easier change the design of my code
Lots of people try things that don't work like sub/unsub with lambdas
There are correct ways to do it and incorrect ways
is their a way to just clear all the methods that an action subscribes too?
You could just show your code and we can help you fix it
ok hang on
Instead of jumping to alternative solutions
Why you don't create a class with a list of items each items is rappresented by a basic class or interface that hold a method like UseItem() and each time that the player change the item you have just to change the current item and the input system will always call the UseItem() method of the current item
Thats what I was originally doing at first but for things like a gun object, I want to handle multiple bindings like reloading, shooting.
so what you're doing is having the input system care about the gun
instead of the gun caring about the input system
It's helpful if I want an Item to handle multiple controls with different inputs
I dont think so
for the second image
Then I have this code which is called when the server stops/when I exit playmode which is supposed to handle the unsubscribing
But then when I subscribe and unsubscribe, I get this error
ArgumentException: Value does not fall within the expected range.
Game.ItemSystem.Items.Firearms.Firearm.SubscribeToInputEvents () (at Assets/Scripts/Game/ItemSystem/Items/Firearms/Firearm.cs:60)
Game.ItemSystem.Core.ItemBase.OnClientEquip (Game.Player.NetworkGamePlayer player) (at Assets/Scripts/Game/ItemSystem/Core/ItemBase.cs:49)
Game.ItemSystem.Items.Firearms.Firearm.OnClientEquip (Game.Player.NetworkGamePlayer player) (at Assets/Scripts/Game/ItemSystem/Items/Firearms/Firearm.cs:21)
Game.ItemSystem.Inventory.Inventory.EquipItem (Game.ItemSystem.Core.ItemIdentifier item) (at Assets/Scripts/Game/ItemSystem/Inventory/Inventory.cs:80)
Game.ItemSystem.Inventory.Inventory.Start () (at Assets/Scripts/Game/ItemSystem/Inventory/Inventory.cs:33)
you might have to pass in a reference to the input object
a reference to the method?
this is how im managing the inputs
and the InputActions is the file unity generates when u create the action maps
I think you need to access the instance
you need an actual object
right now your subscribing to class fields
I think that's where the problem lies
you mean like this?
that's still the class
doesn't he need to get the instance tho?
He's accessing the instance of InputActions
well idk why it wouln't let him subscribe otherwise
Depends where and when he's trying to subscribe/unsub. We see the method that does it but not when and on which object it is called
@austere grotto
here is the error
it happens when I unsubscribe as well
I wish Unity would make the new input systems the default ones.
But to be honest I never use the input systems.
Just saying, I know some people who get irked about the input systems
I agree with this
did i do something wrong ?
@toxic mountain Bot looks for repeated characters like spaces in the code now. Cleanup formatting or post using third party site #854851968446365696
Hey guys I'm not sure I'm in the right place to ask, lmk if it belongs somewhere else. I'm using the unity inputsystem for a project and on my side it works but my friend I'm working with gets updates through github and the input system throws an error (he has the package installed I checked in window=>package manager). So far I haven't been able to fix it
The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine'
You mean regenerate project files? Yes but unfortunately it doesn't help :/
Did you read the entire solution?
Ah sorry I skipped over the 2nd answer with assemblies. On his side the assembly definition (that reference the inputsystem) can't be loaded for some reason. He gets it over the github. I tried sending him the file directly and it didn't help neither
make sure package manager settings are included and regenerate with packages project files on
Other settings could be missing as well, which set to use it in player settings
I didn't get your second answer, which other settings? The ones that are ticked in preferences => external tools to regenerate the project files?
Anyone know the difference between value/pass through action types?
The different action types are documented here https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/manual/Actions.html#action-types
Whats the best way to check which type of input device the player is currently using with the new input system?
Player input component handles that
Is there another way? My game is setup to use a custom script I made and it would be hard to switch to the player input component. Another way I could get my issue fixed is if thereโs some kind of event that gets called whenever any key is pressed, and includes context of what kind of device, tho as far as I know that only exists for the player input component
See the event action triggered; https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/api/UnityEngine.InputSystem.InputActionMap.html
From there u can get the device
I think i can help u with that
Anyone know why Scroll/Mouse Wheel isnt there? And if so, how do I get it/add it?
I know this may seem very simple but does anyone have any idea on how to make the joystick change the "turn" value to control how much the car steers? I'm modifying the karting microgame and would like to add mobile support.
Randomly started getting this error when trying to assign functions for inputs with the new input system, any ideas?
just looks like an internal unity error with the UI
any work around? How else would I assign the functions for my inputs?
restart Unity?
yeah, tried that and also tried updating the package
when exactly do you get the error
when trying to click the function list dropdown
nothing happens and the error appears
which is why i assume the error is for drawerpopup list
What happens if you assign a different object in the slot
hmm it works when changing the object
something weird on that object then
one of the scripts has a weird function the UI doesn't know how to handle or something
so pretty weird problem
in my Update
i initially had this
if (Input.GetMouseButtonDown(0)) { [function and whatnot] }
in the game, when i clicked, this would fire twice even if i added a flag
however, when i use this
if (Input.GetButtonDown("Fire1")) { [same stuff] }
```it works?
what's happening under the hood for the second function?
most likely issue was just that you had multiple copies of that script in the scene
it doesn't work with the new input system after I set it up for the new input system I have a jump command and it says that it can't find the jump action and then when I start it says NullReferenceException: Object reference not set to an instance of an n object Player.UpdateMovment () (at assets/Player.cs:68)
Anyone have any idea why Unity's input system doesn't work when built to exe? It works in the inspector/play mode perfectly fine, but as soon as it's independent it just stops working.
Mouse button stuff works, right now it appears to be exclusively a keydown/axis thing. code I'm using is
if(Input.GetKeyDown(KeyCode.M))
{
print("Toggling all cubes to \"Active\". ");
ToggleAllIn(inactiveCubes);
}
//the rest of the inputs use getAxisRaw. Cube Movement time!
float HorizontalAxisPos = Input.GetAxisRaw("Horizontal");
float VerticalAxisPos = Input.GetAxisRaw("Vertical"); //this should probably work with controllers, too, now that I think about it.
Vector3 MoveVect = new Vector3(HorizontalAxisPos, 0, VerticalAxisPos);
MoveVect = MoveVect.normalized * movementSpeed * Time.deltaTime; //basic Vector stuff, move it in the dir of the axis based on the speed var. Deltatime prevents it from pissing off at mach speeds.
foreach (GameObject cube in activeCubes) //only move the active ones.
{
Rigidbody toMove = cube.GetComponent<Rigidbody>(); //not a fan of doing getComponent in a loop like this potentially every frame, I could probably cache these but there's an extent where the extra complexity isn't worth.
toMove.MovePosition(cube.transform.position + MoveVect);
}
which is in update. excluded is the typical raycast select stuff
Issue applies to controllers as well
I'm thinking this HAS to be a build setting issue, but I have zero idea what it COULD be
using UnityEngine.InputSystem cannot be found(I regenerated project files). In VS2022 I can see Unity.InputSystem but its says it is ignored Can somebody tell what to do with this problem? Thanks
what part isn't working?
Keyboard inputs in general. When built to an exe they simply don't work.
works as expected in the play mode window
That's not the experience I've seen anyone else have
Correct, which is why I'm confused.
btw I see an error in your code: toMove.MovePosition(cube.transform.position + MoveVect); MovePosition should not be used in Update
it will not result in smooth or predictable motion
like most things involving Rigidbodies, it should be done in FixedUpdate
I'll keep it in mind, but It doesn't fix the issue.
I think your assumption that Input.GetAxisRaw is the issue is wrong
something else is going wrong
do some debugging
could also be a window focus issue
Everything else works as expected. window is in focus, tabbing out and back in makes no difference.
Clicking/the actual update stuff works, just not keyboard/controller inputs, hence why I thought it was a build settings issue.
This is wrong right? I shouldnt have a 1D Axis, if im tryin to make a first-person controller
if you're using joysticks you don't want a composite at all
You have named your actions things like "Movement/LeftStick" which is... you shouldn't include the name of the control in the action name
just call it "Movement"
Oh well I already wrote the scripts
and it can be Value/Vector2 and a simple binding for the joystick you want
Because what if you want to change the binding
or allow the user to change the binding
now the name makes no sense
Ahh I see
Is there a good way to using hold vs toggle input based on device? Like I have a radial menu that when using a keyboard should have a button held to keep it open, but when using a controller I want it to be a toggle open.
Anyone have any idea why this might be generating this error...when the right mouse button isn't even getting pressed?
Well what is at line 299 of PlayerInputController?
Well that's not the issue I'm having. The problem is .performed shouldn't even be getting called, because the right mouse button isn't being pressed when that error occurs. And the right mouse button is a modifier for that action.
Ah, ah I see I misread originally by bad. The reason is because it is passthrough
Nope. I still get the same issue when I changed it from Passthrough to Value.
using UnityEngine.InputSystem cannot be found(I regenerated project files). In VS2022 I can see Unity.InputSystem but its says it is ignored Can somebody tell what to do with this problem? Thanks
idk try to reinstall input system package
Doesn't work
Turn off Unity and delete Library/ScriptAssemblies folder, start unity, regenerate project file and see if it fixes it
Is someone knows smth about such problem:
touch controls does not work in my project.
Input.simulateMouseWithTouches is true
When i click with mouse, input debug correctly shows info about simulated touches
But Input.touchCount shows 0
Actions through PlayerInput component does not work too.
Touches in android build does not work too
additional info: game correctly registering clicks on UI buttons both on PC and android build, so touchscreen and mouse definitely work
Nope, it doesn't work
Are you using Unity Remote
Also - simulateMosueWithTouches creates mouse input from touch input, not the other way around.
no, i create apk and install it to my phone
i meant this debug option, sorry for mistake
If you have an apk on your phone how are you using a mouse?
have you attached a mouse to your phone?
i am talking about two different situations. touch doesnt work BOTH when i simulate it using mouse in editor, AND when i am trying to test in on my phone
how can i reproduce input.getaxis("horizontal"); on new input system
value was starting from 0 and increasing
than becoming 1
Unity has a primer video on their YouTube channel covering the new input system. It goes over how to implement movement.
yeah i looked at that
but it works like input.getAxisRaw()
becoming 0 to 1 suddenly
for smoother movement i want it to slowly increase
Right, you have to implement your own acceleration/deceleration.
Okay, thanks. I was kinda lazy for doing that so wanted to know if there is a built-in method to do that for new input system
I have a player, with a playerlook script that seemed to be working fine, I added a model and animations but now the camera is being erroneous and feels like its following certain meshes and/or skewing off a straight line
what does this have to do with #๐ฑ๏ธโinput-system , and what is your actual question?
What about it?
does that not have to do with the input system?
Sure it does, but do you have a question about it?
its not me, but from the looks of his comment it seems something is up with his mouse delta
no?
Oh you were attempting to answer their question. Who knows. The description was really vague.
idk if i am doing this right, but i get this error
NullReferenceException: Object reference not set to an instance of an object Button.Awake () (at Assets/Scripts/Objects/Button.cs:16)
is there a PlayerInput attached to the same object
ofc i forget that
why does Input.GetAxis work outside of Update, but Input.GetButtonDown doesn't?
Oversimplification but get button down only gives you meaningful data for a single frame
FixedUpdate doesn't run every frame so it can miss that single frame
actually another question
Input.GetAxis does work outside of Update right
hey hey, anyone here working with a steam deck? I'm trying to get access to the handhelds tilt value with the gyro, but unfortunately I don't get anything back with Input.Gyro. Also tried Rewired as an input system, but nothing here either. Is there something I'm missing?
Does anyone know how to bind a composite input into multiple axis? For example, if I wanted forward to be on the left stick vertical axis and backward to be on the right stick vertical axis, how would I do so? is it possible? or would I have to make a different input action for each, rather than doing a composite input
You'd do an up left right down composite probably?
Not sure how well it'd work
Hi! I have a basic question. How do people usually utilize the new Input System? There seems to be different ways to use it (c# events, unity events, and i'm s ure there's another one I don't remember). How is it usually used on games? Also, can someone please link me a GOOD tutorial on it? I really want to learn it
u were right, i just had to change it to value - axis, and it worked nicely
thanks brother
How do I do this? When I press [x] on Xbox controller it should behave like I'm pressing [F] on Keybord
I press x on Xbox controller. It do nothing
move look jump sprint is working
You have to add another bind, but for "Xbox Contoller" instead with the path of the X button
you can start with many of the tutorials from youtube. they cover the same topics. some may provide more info so it's always good to watch more than one. i've seen both unity events and c# events, it really depends what you're more comfortable with . . .
hello guys because of some reasons my input manager is running completely differently, I mean the vertical and horizontal ones
haven't seen that before, how so?
I don't know can I share my screen somewhere like in your dm?
nah, easier to post/explain the issue here so anyone can help. it's almost 5am for me, so i can fall asleep at anytime . . . ๐
ok I dont know why but my input manager works fine when the player is rotated 180 degrees but wont work when it is not like it will go back when press w and right when press a but why?
bro did you got the problem?
how are you moving the object? you're probably not moving based on the object's forward direction . . .
this is my script https://paste.ofcode.org/hrArdYSrm8NFywqTA976K6 and after it wasn't working I also tried this script from a tutorial https://paste.ofcode.org/cfkTM5J5xNt3bxGcTjWCSm and it was still not working and I also sen't my input manager screenshot
bro u slept?
is there a quick way to test single touch with new input without having to create new inputs and actions?
TouchScreen.current.primaryTouch
I keep getting ArgumentException: Value does not fall within the expected range. when trying to subscribe/unsubscribe from input events at runtime. Anyone know what this error means?
show your code? I think it means your function doesn't have the right signature or something like that
@austere grotto ?
what exactly do you mean by "signature"?
the signature of a method is its return type and argument list
so unityevents dont seem to work at all for me
idk why it wont work
i have a space bar setup as shoot
correctly
i got all this
and the controller.cs as this
and yet, nothing works
im not missing anything
apologies if wrong place to ask
i just switched over to the new inputsystem and it doesnt register at all. i changed the settings in player and in eventsystem but it doesnt register any inputs
Show screenshot of your input module
you mean this?
do i have to set my controller to the input module?
Ok that looks fine
You need to also have a graphic raycaster on your canvas
Or wait are you asking about UI stuff
Or what
Oh, how are you trying to listen to them
its in my player object
script has reference to the controller and a getcomponent
oh nvm i had to enable it on start i didnt know that was a requirement
oh well but gamepad doesnt work at all
What are you doing in the script? When you use SendMessages mode you don't actually even need a reference to the PLayerInput component
switching between gamepad and mouse&keyboard since the controls are different for each ingame for example
things like this but now the mouse and keyboard part works but the gamepad just doesnt so it might be the fact that i have a bootleg controller
you also have actions that are bound to both mouse position and gamepad joysticks
that's generally... not feasible
try unbinding the mouse
i did and well the two situations are handled differently depending on wether youre using the mouse at the moment or the gamepad
its all good my gamepad literally doesnt work anymore apparently
Is there a reason a single action would not be rebinding? I have action 'A' that is working perfectly and rebinds, but action 'B', which is the exact same type and inputs the exact same thing but on a different key, doesnt rebind at all
it simply just doesnt register the new key press
theres nothing on the internet about it, so idek what to do at this point
Unity.21.Android touch input -
seem to get controls for player/ main menu to work, but when adding a vehicle and using touch canโt make it happen, vehicle works with keyboard and controller tho.
Not sure what Iโm getting confused on, Iโm new, as u can tell..
There would only be one vehicle, and the vehicle would be treated as player aswell
Changed to use player controls, still nothing, canโt get vehicle to move, everything else is fine, what am I missing?
/Touchscreen/press,/Simulated Touchscreen/press]'
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)
Swapped to default standard asset vehicle, still vehicle doesnโt move with touch. Player, menu, vehicle with keyboard and controller work
can you subscribe to InputActions per controller?
that is to say i dont want to use playerinput or player input manager
i have a pad id, and i want to receive actions from that pad
sounds pretty simple ๐
Buler?โฆBuler?โฆ
heya, i asked at a very inactive time of the night yesterday so thats my bad, but has anyone got an answer to this:
im using unityevents with player input component, however it wont register my inputs, even with everything setup
ill provide screenshots of anything u want, i just wanna know if im missing anything
That's strange, can you show your input action asset?
sure thing
the simplest one is just this
the move one doesnt matter, cuz this doesnt work either
and it should as its only meant to detect spacebar
@cinder basin
its just really confusing as ive done everything right to my understanding
ok i think i have an idea on a fix
nvm didnt fix
lol still wont work
Me and you same boat, but I canโt get my vehicle to work, menu and player is ok
the documentation is pretty bare
There are examples on the package manager page of input manager you can import and compare how it should be setup.
After importing the sample how to view?
Last time I looked at them they described 3 different ways to use input system
There's also large forum thread with explanations and examples
It's pinned in this channel as well
Itโs the pointing in the right direction really is what Iโm asking not to solve it for me just fyi and Ty much appreciated
Good, because I haven't touched it for a while.
decided to switch from playerinput component to c# script, works but i woulda preferred to use the unity type system
Still lost, do I need to remove the car controller and make a new one? The car would use the same controls as the player so shouldnโt it work if I set the player input on the vehicle aswell to the same control sceme as player, I just donโt understand why Iโm so confused, looking at videos 10 times, nothing explains switching from player to vehicle with touch atleast that I know of if there is some more info somewhere that Iโm missing
Oops, sorry you couldn't get it working in your preferred way, but you may try reinstalling the package or creating a new input action asset and see if it solves the issue. I've looked at the screenshots you sent didn't find any stuff that'd prevent it from working..
Isn't 'E' mapped already as I'm seeing 'E[keyboard]' from the screenshot?
ok, so from there, i go to the vehicles player input in the inspector, select invoke Unity Event, drop down Events>player> enterexit and there is no option to add control im stuck here
i drag the player/vehicle to the enter exit callbackContext, select PlayerInput i dont see the control
i dont actually need E key just E key triggers the event, now i need controller X button to act as E button
you can check the other scripts in the onedrive
Did you get that setup as in the image?
gettinginout.cs controls the E key and disabling vehicle/player
Rename to 'EnterExit' in the N'o Function' drop down you should probably see sth like, yourscript.OnEnterExit
ok, new screenshots in link above
Also make sure you have this setup in your script:
public void OnEnterExit(InputAction.CallbackContext context) {//Logic}
In your input Action asset, rename enterexit to EnterExit
Sorry for the bad code formatting as I'm currently on mobile...
Where's the link?
Why the 'enterExitKey' field ?
Isn't that meant to be handled by the input action you setup?
not sure how to sort that dont think i put it in the right place, still not showing, no errors tho
this is to get in and out of the car, it was with E key, now i need to change to controller
maybe i am mixing old and new?
Oh I see
ive watched the videos 50 times today lol all they explain is movement
player.transform blah
not what im after
anyways so i guess i need to rethink this not sure
get rid of the gettinginout
๐คท
ive tried not using it, that removes errors about input system when on android platform, but taking a step back, on PC version and making sure to get controls working on controller as backup
everything else is fine, i can get menu to work aswell
but secondary "player" a vehicle is giving me a hard time
think my brain is just mush trying to solve something so simple i cant think anymore
btw havent made a game in like 10-15yrs, now im just trying to get back into it while making a friend into a game lol, not looking for selling production just it works lol
Sorry it's giving you a hard time, def there'd be a fix for this
Ibebs your great, you deserve the world, thx for your time
no worries, i tried all that, i dont think im gonna figure it out easily so for now ill stick to c# scripts
the script solution isnt too bad, its just a matter of figuring out the implementation
Anyone dealt with reversed mouse buttons in the new Input System? It doesn't seem to recognize them.
I'm having some trouble with the new Input System where my mouse movement is almost "snappy"
It's like the mouse delta gets locked at zero for a split second then continues normally
it's super distracting for gameplay and I couldn't find anyone online who had the same problem
this is all I have
I'm making a platformer controller using the new Input System and trying to control Smooth movement for jumping and moving... I'm pretty sure I can lerp, slerp or SmoothDamp over the values. The problem now is I'm using a Player Input Component and Unity Events to control the Move and Jump.... And I cannot figure out where to add the Vector2.SmoothDamp.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private Rigidbody2D rb;
[SerializeField] private Transform groundCheck;
[SerializeField] private LayerMask groundLayer;
private float _horizontal;
private const float Speed = 8f;
private float jumpingPower = 16f;
private bool _isFacingRight = true;
private const float GroundedRadius = 0.2f;
// Update is called once per frame
void Update()
{
rb.velocity = new Vector2(_horizontal * Speed, rb.velocity.y);
if (!_isFacingRight && _horizontal > 0f || _isFacingRight && _horizontal < 0f)
{
Flip();
}
}
public void Move(InputAction.CallbackContext context)
{
_horizontal = context.ReadValue<Vector2>().x;
}
public void Jump(InputAction.CallbackContext context)
{
if (context.performed && IsGrounded())
{
rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
}
if (context.canceled && rb.velocity.y > 0f)
{
var velocity = rb.velocity;
var gravity = rb.gravityScale;
velocity = new Vector2(velocity.x, -(velocity.y * gravity * 2f));
rb.velocity += velocity;
}
}
private bool IsGrounded()
{
return Physics2D.OverlapCircle(groundCheck.position, GroundedRadius, groundLayer);
}
private void Flip()
{
_isFacingRight = !_isFacingRight;
var transform1 = transform;
Vector3 localScale = transform1.localScale;
localScale.x *= -1f;
transform1.localScale = localScale;
}
}
Any advice?
I want to take a stab and say somewhere you have conflicting controls, as this would happen with my character and the movement would cut out unless I move the stick again. Just a guess for u
Hey everyone, just wondering if anyone has also had a problem with WebGL & Gamepad support. Strangely, only in WebGL, my gamepad sticks (which are bound to a Vector2 composite) wont register Up and Down. Left and Right work though as well as all other buttons.
I've tried searching around without much success. It only happens in WebGL, in Chrome & Firefox, Editor / Win / Linux builds all work fine. My controller works fine on https://gamepad-tester.com/. I tried making a new Project in a 2022 Version of Unity and I'm having the same problem.
is unitys new input system sending each frame like the old one the events , or does it only respond to the event when it actually happens
like in the old one its checking if that event has happened
is it under the hood also checking each frame if it has haeppened in the new input system ?
When trying navigate my main menu, things seem to work fine if I go from Start -> Controller.
However, if I click anywhere on the screen with the mouse, then attempt to use the controller, the controller will no longer select anything, at all.
Better yet, why is it as well that Controller input sends "Is Selected" but Mouse is "Is Highlighted"
Thats highly annoying...
I'm not entirely sure if this is what you're after but in the Input System UI Input Module, there is the Deselect On Background Click option, turning that off may be what you need?
That fixed the mouse issue.
However, now when I swap from Controller -> Mouse. One of the UI buttons now remains always "Selected" because Hightlighted (Which the mouse provides) != Selected (Which the keyboard/Controller provides)
I'm assuming Im going to have to code something to sort this out vs it just being built into unity
Ah I see. So ideally once you move the mouse the selection should disappear?
Correct.
And then when swapping from Mouse -> Keyboard, Ideally:
Hightlighted = Nothing
Selected = EventSystems first selected.
I actually figured it out and this is something I didn't see coming. I found a post on Reddit saying that you shouldn't multiply your mouse movement by Time.deltaTime, and lo and behold, I was doing exactly that
So I removed that multiplication, lowered my sens and it was solved
Thank you for reaching out though
Oh also I think that's a problem with your Dead Zone settings for the controller
It was multiple controls, never touched dead zones, but cool
How can I control the cinemachine orbital transposer with scroll wheel? I'm porting from using input manager and having trouble here. I have the input provider on the camera. I think I need to use the XY Axis slot, and it wants a vector2.
I got a question so basically Iโm trying to add a 2d vector component and it wonโt show up anyone know why
-
Make sure your input action is set up as:
Action Type: Value
Control Type: Vector2 -
It was renamed to "up left right down composite" instead of "2D vector composite".
https://stackoverflow.com/questions/72878115/how-to-control-the-curve-of-a-jump-mechanic-in-unity-while-using-the-rigidbody2d Any thoughts?
Use an AnimationCurve and apply it to the y velocity of your body
Hello ! I am using the new input system to make my player look into the direction of my mouse.
The issue is that after some research, the Mouse.current.position.ReadValue() or playerInput.actions["LookDirection"].ReadValue<Vector2>(); are not detecting my mouse position nor movement.
Does someone know how to fix this please ๐ ?
Hi! I'm trying to get my 3d character to move a set distance on a keypress but I'm struggling to figure out how to get it to move that distance in the direction that you are facing.
You can move you character in the direction transform.forward, that is the vector pointing in the direction of the given transform.
I think that a part of my issue is link to the editor mode and more precisely the "window mode" (I mean when you don't maximize the window) because I just found out that when the window is maximized, the mouse position work but in normal small game window, it doesn't
I just spent hours on a massive, massive brick wall and it's very discouraging. I had a Unity project with all my HP Reverb G2 buttons implemented, I had the player movement done, everything. Now, no matter what I do, I don't get any input at all from the motion controllers. Even clicking Listen on the Input Action I already set up - nothing. I even made a brand new project, imported the MRTK again, added OpenXR, and created an input action, then when I go to Listen, I get nothing. SteamVR is running but I guess it doesn't make any difference since it looks like it just plays through the Mixed Reality Portal.
woah the input system has its own channel?
thats how complicated it is
how do check check if pressing shift button
if you're getting started with the new input system i would recommend following a course on how to use it
I changed an action map name and now im getting this error, how can i "remake" my c# script?
in the inspector for the input actions asset there's a button to generate it or something like that
i deleted and remaded it keeps giving me errors
deleted and remade what
the c# script
the C# script is actually kind of irrelevant to the PLayerInput component
so I'm not sure why it matters
https://imgur.com/89aZyIu
is something wrong with this?
the error you are getting is from a PlayerInput component
yes that's the PlayerInput component
now is not giving any errors what lol..
I'd say you probably had a function mapped to an action in the "Player" action map and now you deleted that action map or osmething
I think that the default map was saying player before ye
somehow it didnt update or something
ok it works thankfully
ok really stupid question i have openXr setup but i just want to put into a script if i press the say A button on my touch controller then do something. like
if (openXr.rightHand.getKeyDown("A")){
//do something
}
how do i do this?
I have a newbie to Unity question. Iโve tried googling it and canโt find the answer. Iโve managed to implement movement to a sphere with keyboard inputs and an now trying to implement movement to a person. Ive made a model in a external software and have managed to implement animations. However I canโt implement movement with keyboard inputs. Idk what Iโm doing wrong. How do I get past this dead end? - http://pastie.org/p/0gBN7OQ8M6o8VRycUk5H4C
done
hi, new to coding/unity in general
after reading a bit about Update() and how it is recommended to check for inputs in the old input system within Update() to avoid input loss, I was wondering how that applies to the new input system
if you poll for input, your polling should match the setting you have for the input system (it can be set to poll each frame (Update) or each physics frame (FixedUpdate)
If you use events, you don't poll anyway so it doesn't matter
that's the advantage of the new input system that people still don't seem to understand
you don't end up with juggling the update and fixedupdate loop anymore, it's event driven and will reliably detect input with fewer physics glitches
guys, How do I make a long press repeat the function I know it must be from the input action asset but i dont know how to set it up.
I have solved the problem temporarily by using the update function but I want to know is there a way to not use update?
You must either use Update or a coroutine. The input system won't repeatedly call something for you
I see, thanks
Hello, a very quick question if anyone can help please. I am starting to get to grips with the new input system, however on setting up a very basic scene for testing I obviously don't understand how the X and Y inputs work, as left stick movement on the gamepad is moving by character side to side (fine) but also up and down, rather than forwards and backwards. Obviously this is due to Unity using Y axis for 'up', would anyone know the very simple thing I have missed here please? Many thanks in advance.
so can you add a playerinput script and tell it which device/user it should manage?
it seems playerinput is the only way offered to handle mutliple local players, but it suggests the gameobject is instantiated by playerinput which isnt really what i want to do
Do I subscribe to all events on awake for an input even if that action map isn't enabled to start?
Like I have UI and player and vehicle action maps. Do I subscribe to all even though UI is the only one to initially be enabled
You can subscribe before it's enabled, no problem
How can we use the c# events to get input from player input component??
Hey guys, I'm getting this really weird issue with the input system. I'm using the OnXXX() function to receive analog stick movements from a gamepad, but the vector2 seems to flicker between the real value and 0. This only happens when I'm clicked into the game window, but not when I click on any of the editor panels. I've checked everything and can't seem to fix it. Any ideas?
hey quick question, we shifted our project to the new Unity input system and consequently our event system changed to use the "Input system UI input module" instead of the "Stand alone input module" as well. For some reason this called callback functions like OnPointerClick() to not work anymore. Anyone got any idea on how this can be fixed or are the callbacks just not supported by the new input system?[resolved]
is there a difference between using this
vs
private void OnEnable()
{
Player.Move.performed += movement;
}
You'd need to unsubscribe manually with script
May or may not be a problem depending on how ur project is set up
Hey, im switching to the new input system, i have a script for 2d movement,
And i get this error when pressing a move key
InvalidOperationException while executing 'performed' callbacks of 'Player/Move[/Keyboard/a,/Keyboard/d,/XInputControllerWindows/leftStick/left,/XInputControllerWindows/leftStick/right]'
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)
Does someone know what i did wrong here
does this help ?https://forum.unity.com/threads/solved-invalidoperationexception-while-executing-performed-callbacks.883633/
Yeah i fixed it already, i made a mistake with creating the profiles
But thank you anyway! ๐
I switched to this powerfull new input system today, and i need to get used to it, cus its more complex then i thought it was, but the possibilities are amazing! ๐
But i had to figure out the 1D axis for the error that i had, and i found it, so its working perfectly fine now. I can't say that i miss the old input system ๐ But i think learning this new system is a challenge
what do these errors mean? I went from 2020 to 2021 and these started popping up. Is it a UI Toolkit thing?
also got these when stopping execution
Im working with the unity input system and it works and all,
But i get mega spammed with an error, looked it up for about an hour but cant find a solution,
Any one seen this before?
https://gyazo.com/443779bde6a3fd188272cd54401d7f98
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.EventSystems.BaseInput.GetButtonDown (System.String buttonName) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:126)
UnityEngine.EventSystems.StandaloneInputModule.ShouldActivateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:227)
UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:474)
^ Solved (setting the input handling to Both
Is there a way to print the name of the input device currently sending inputs? [Resolved]
I have a feeling this issue is because I'm using a JoyCon with software to map it to xinput, but unity is capturing both the raw and the mapped inputs, causing it to constantly switch input devices, and therefore cause stuttering when focused on the game window. [Confirmed]
Input debugger window?
Yep, the input system seems to be switch between gamepad and joystick... follow up question, how do I make it completely ignore / disable all inputs except for the gamepad? [Resolved]
If I go into input debugger and manually disable the device it fixes the issue, but this resets when closing
Inside your playerInput component, I think there's an option for that, that's if you have their actions setup separately already
Sadly Yeah
This is what I see inside the playerInput
I could manually remove the devices from the playerInput c# script
Are you asking?
They're restricted to gamepad, but unity still captures inputs from the other controller and stutters when it switches, even though there's no actionmap for them
Oops, sad stuff
That's already how it's set up unfortunately
Mine is setup this way, it maps to the actual controller:
Got it working, I think the issue was before playerInput, where Unity was switching HID device constantly because of the JoyCon motion sensor being mapped as a joystick. I found a way to block the raw HID device though. Thanks for your help ๐
Hey, last time I checked there was no easy way to check if a button is currently pressedโฆ
Is there now a smooth option?
With the new input system
Depends
You can use .triggered to check if a button is pressed.
So:
var wasPressed = action.triggered && action.ReadValue<float>() > 0;
var wasReleased = action.triggered && action.ReadValue<float>() == default;
Or you can set smt up like this:
if (InputManager.GetInstance(). GetSubmitPressed())
Is that what u ment?
Is the output the hole time true while I press the button?
Or just at the frame where I press it down
Hi im following a tutorial for the input system but for some reason for them theres an option to drag the Controls script into Controls in unity but for me its not there. how would i fix it?
What tutorial are you following?
Why are you writing @Controls? I'm led to believe that's the name of the auto-generated C# class from the input system but those are not and never have been serializable
if it's the auto generated class you normally just create it with new e.g. controls = new Controls();
does anyone know any good tutorial to know how the new input system works?
I personally watched the tutorial of Brackeys, also, reading over the wiki & unity guides is probably even a better way to learn, also, just start coding with the new input system and just look up the things u are struggling with, that is IMO the best way to learn.
controls.Enable(); & controls.Disable();
Does someone know if you HAVE to place those 2 in void onEnable and onDisable ?
Or can i use void start as well
You can do whatever you want.
But you do need to enable and disable them right?
Ive heard that you can get massive issues when not doing so
If you don't enable it, it won't be enabled
If you don't disable it, it will remain enabled
The rest is up to you
If you want it to process input and perform your callbacks etc, you will have to enable it
Ive just figured out that if i want to use a key function (button) 1 time press, and i enable it in a void awake, it wont work and bug out, wit h a OnEnable it does work, so for some reason its forcing me to use onEnable.
Its not a big deal to use onEnable, but just wondering why its forcing me to use onEnable, since awake is also starting up at the very start of the script.
But it could be just me, it just seems a bit wierd ;p
it will definitely work in either place. The only difference would be if you enable it, then disable, then re-enable, OnEnable gets called again, Awake does not
Yeah but its not working for me if its in awake
Maybe i need to place awake above onEnable & update ๐
I think i need sleep
๐
no, none of that matters
you'd have to show your code
Hello, is there any bug report room for the input system ? I am using the 2021.3.5f1 and my inputs doesn't work if I don't play the editor "game view" in full screen. Plus the mouse position is broken, I have to use the old system for the mouse position
To report bugs to unity: https://unity3d.com/unity/qa/bug-reporting
what would be the best way to check if a button is still being pressed?
right now my only solution would be to make a new function just to set a bool on .started and .canceled
you can poll the value, or use started/canceled
I'm sorry, but I'm having a hard time trying to find out how to do just that from inside a different function (I'm new ๐ฅบ )
wdym by "from inside a different function"?
either:
- poll the value of the InputAction each frame
or: - subscribe to started/canceled events to set a bool, which you read each frame
I have a jumpsquat that is activated on jump press which is animated and then on a certain frame of that animation I have an animation event that I want to check to see if I'm still holding down that jump press to do a short jump vs normal jump
the animation event calls a separate function that does the check
am I going about this the wrong way?
what's the issue then?
I don't know how to do that check
Have that animation event function either:
- read from the input action
- check your bool if you're doing the started/canceled
oh I am just unintelligent then
this whole time I thought IsPressed() was from the old input system and couldn't be used
InputAction is the new input system
everything in UnityEngine.InputSystem is the new system
I see now, thanks!
the old system is the UnityEngine.Input class
Is it possible to use both the old and new input systems in the same project, on separate scenes, without the old one breaking?
sure
Alright, how do I make both of them work, in the same project?
set active input handling to Both
oh...
Its that simple?
Damn... I was just going there.
I set it and it works. Thank you @austere grotto for helping me so quickly with this.
Hey y'all, I'm having a bit of a problem with the new input system and was wondering if anyone had any tips. I have a system setup where you walk up to something and press the a button, which then opens a UI list of buttons to choose between. Since the a button is also the button setup to select UI elements in my EventSystem, it auto fires when the window opens and auto selects the first in the list. Any way I can make it not fire on open?
also strangely it only happens the first time, every subsequent time it actually works as expected
relevant code: https://paste.ee/p/egZzH
I came up with a workaround, but I'd still be interested in a proper fix if anyone can think of one. My workaround is to move the selection of the GameObject to Update so that it selects it the next update cycle
private void Update()
{
if (!IsVisible || !Choices.Any() || EventSystem.current.currentSelectedGameObject != null) return;
EventSystem.current.SetSelectedGameObject(transform.GetChild(0).gameObject);
}
you could disable the ui action map until the UI is showing
Hello everyone.
I'm facing a weird issue :
using UnityEngine;
using UnityEngine.InputSystem;
public class Playermovement : MonoBehaviour
{PlayerInput _playerInput; bool leftPressed; void Awake() { _playerInput = new PlayerInput(); _playerInput.Controls.Left.started += OnLeft; _playerInput.Controls.Left.canceled += OnLeft;}
void OnLeft(InputAction.CallbackContext context)
{
Debug.Log("Left button pressed");
leftPressed = context.ReadValueAsButton();}}
But when I press the Left button ("Q" in this case) I 've got the folowing message :
So "OnLeft" not found but the debug log message is displayed
#854851968446365696 for how to post code here
Looks like you're mixing up two different approaches here
You have a PlayerInput component with the SendMessages/BroadcastMessages mode enabled
that is what is giving you that error
you're then separately manually subscribing to input actions in your code
So your manually subscribed thing is working, but the broadcast messages thing is giving the error, because it expects you to have a method with an InputValue parameter, not a CallbackContext
The solution is to pick one approach or the other, not both.
Good suggestion, I thought simply switching the current active action map would be enough, but disabling it fully works. Thanks!
I have the mouseX and mouseY in my games project settings set to 1.5 but when I play the built version of the game it is a whole lot higher. Any idea why?
I have the mouseX and mouseY in my games project settings set to 1.5
What does this mean?
sorry i meant to say I have their sensitivity set to 1.5
If you're seeing differences in the built game especially related to the "speed" of something, 95% of the time you have code that is framerate dependent
for mouse sensitivity - I would guess you're probably doing something inappropriate with your mouse input like multiplying it by deltaTime
I just noticed there's a PlayerInputs and a PlayerInput
now I'm not sure if I am using the right one
does anyone could help me? im trying to put if (view.IsMine) in this code but its just saying error
- Does this have something to do with the input system?
- Post code using our guidelines mentioned in #854851968446365696
PlayerInput is the only one that is part of the input system. if you have something called "PlayerInputs" it's something you created. Possible the auto-generated class file from your input actions asset?
How can I handle input from two gamepads. I've looked up some videos online, but the solutions are unsatisfactory because I don't want to spawn in a player prefab, I just want to separate the input from two gamepads.
Hi, I've been trying to use the new input system, but when I try to change the value of a binding in the inspector via double click it doesn't respond
Anyone know why?
(talking about this menu btw)
So like, you can't add a new binding then?
I can add more bindings, but they just have the default value of <no binding>
Ok, so the thing you highlighted is the button you are double clicking? If not please sent an image of what you are double clicking
The part I am double clicking is where is says <No Binding>
you have to press the + to add a binding
I have done that, which makes the <No Binding> part, but I can't change the value of these bindings
Hmmm, maybe you have to do something in the settings panel, and add something from there, it could also be a drag and drop panel. I'm sorry for not being able to help much just haven't really worked with it in awhile/:
seems like a UI bug
do me a favor what happens if you put an InputAction field directly in the Weapons script?
Does the UI work correctly then?
No
Another weird thing that I have noticed is that the - sign to remove the bindings I work is always greyed out, and only sometimes actually works
Hmm seems like a bug I guess
I don't use direct InputActions usually
Typcially I use an input actions asset
Should I try a reinstall to fix?
what version of unity / input system are you on
see if you can update either/both of those
ehhh maybe because you're on an alpha version of Unity
You might have better luck with an LTS or at least a Tech Stream release
will Unity let me downgrade my project?
Also, for future reference, are Alphas or Betas usually more stable?
not in a happy way
betas are more stable than alpha
but neither is stable
they are experimental
well then I guess I'll just go to 2022.2.0b1, last time I had an editor bug it got fixed by a very small upgrade about the same size as this one
Can anyone tell me offhand what the equivalent of Input.GetKeyDown is in the new input system? With the code below, pressing any of the buttons set up in the input actions simply rotates the camera once by whatever the value of rotationSpeed is, whereas what I want is continuous movement while the key is held down.
public void RotationControls(InputAction.CallbackContext inputValue) { { float value = inputValue.ReadValue<Vector2>().x; transform.rotation = Quaternion.Euler(0f, value * rotationSpeed + transform.rotation.eulerAngles.y, 0f); } }
The transform.rotation = Quaternion.Euler(0f, value * rotationSpeed + transform.rotation.eulerAngles.y, 0f); part needs to go in Update
and value needs to be a member variable
and you don't need those extra brackets { }
oh those brackets are leftover from an old if and I forgot to remove them
also eulerAngles is a funky way of doing this. Would be cleaner and less susceptible to gimbal lock to do this:
transform.Rotate(0, value * rotationSpeed * Time.deltaTime, 0, Space.World);```
Thanks, I will try those changes
So after update it still does not work ๐ค
Any ideas?
because im really lost here
well you went to another beta version of Unity right?
Maybe try a released version
And/or file a bug report
and how do I file a bug report
With the new input system, how can you detect whether they're using WASD or gamepad? I want to use L-Shift for run if they're on keyboard, but just the L-stick magnitude if they're on controller.
You can either set up control schemes that require specific controller types, or you can just define different inputs in your existing action map. AFAIK they are equally valid methods.