I'm trying to detect clicks on squares on my chess board with IPointerClickHandler, I assigned the script that had the interface thing and a BoxCollider2d to the square game objects, I have an event system in the scene, there's a Physics2dRaycaster, but it still doesn't work
#🖱️┃input-system
1 messages · Page 33 of 1
am I missing something here?
if you can help me ping me please I'm gonna continue trying to fix this
Is this a ui object?
no it's a 2d game object
Maybe something is blocking the way
like another gameobject?
You should probably show your scene hierarchy
I have no problem with OnMouseDown()
Does it work if you deactivate the pieces?
Hello everyone hope all is well.
I'm going to assume the pieces are blocking the squares
no
sorry I misunderstood
I thought you asked me to deactivate the squars
when I deactivate the pieces it still doesn't work
I was wondering if anyone could give me some clarity.
Long story short, I updated project from 2021 to unity 6. And I’m running into some kinks.
Use the IPointerClickHandler Interface to handle click input using OnPointerClick callbacks. Ensure an Event System exists in the Scene to allow click detection. For click detection on non-UI GameObjects, ensure a PhysicsRaycaster is attached to the Camera.
yes I triple checked it's all there
Can you show the inspector for the square and piece?
forgot the bottom part of the square GO in the inspector
I’ve read documentation and watched official videos on input system.
It doesn’t explain any relationship between the player input component and action asset.
I had both working before updating.
I also don’t understand the UI folder beside asset. I haven’t been able to find info on it
ok it works now
I adjusted the size of the BoxCollider2D on my squares and it works as intended now
The size of the collider is quite small... is that expected?
it wasn't but it's fixed now
mine was basically the same thing praetor just told you to do
you never gave any feedback
you just ignored it
you never showed issues when you actually had the setup correct
you definitely asked way more than twice
Is inputactionmap better than inputactionreference
Cause can I just map[0].action[1]?
From memory
you cant directly serialized a reference to an action map, but you can always access the action map from a input action reference. maps are for grouping actions and enabling/processing them as such. you don't ever use positional indexes in your input discovery (they will break), if you can use a stable direct reference like an input action reference.
hi guys im making a weapon bench in my game when u enter it switches the input map but when i try using it nothing happens no errors no debugs that its null even tho i enable them all
`var values = playerGeneralValues.Instance;
if (values == null)
{
Debug.LogError("playerGeneralValues instance is null!");
yield break;
}
values.playerInput_i.Enable();
// Get and enable the weapon bench map
weaponBenchMaps = values.playerInput_i.weaponBenchMap;
if (weaponBenchMaps == null)
{
Debug.LogError("Weapon bench map is null!");
yield break;
}
weaponBenchMaps.Enable();
// Find actions
leaveAction = weaponBenchMaps.FindAction("leaving");
clickAction = weaponBenchMaps.FindAction("click");
mousePositionIA = weaponBenchMaps.FindAction("mouse");
// Verify actions were found
if (leaveAction == null) Debug.LogError("Leave action not found!");
if (clickAction == null) Debug.LogError("Click action not found!");
if (mousePositionIA == null) Debug.LogError("Mouse action not found!");
// Enable actions
leaveAction?.Enable();
clickAction?.Enable();
mousePositionIA?.Enable();`
i am not using a player input component
i am not receiving any input
`if (playerInput_i == null)
playerInput_i = new PlayerInputs_im();
playerInput_i.defaultMap.Enable();` this is what i use to get input system
Posting code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
hi guys is there a way to disable all action maps in the same time from and input asset? in code
myActionAsset.Disable();
i want to enable one and disable all others
So do that?
@austere grotto Should I continue here?
'PlayerInput' does not contain a definition for 'actions' and no accessible extension method 'actions' accepting a first argument of type 'PlayerInput' could be found (are you missing a using directive or an assembly reference?)
i dont know why its not working guys
it worked on a different project
but now i dont know why this error is showing
it's because you named your Input Actions asset "PlayerInput", so the auto generated class got that name
There's a built-in component in the input system called PlayerInput that your name is conflicting with
You have a few options to resolve it:
- Rename your actions asset
- Disable "Generate C# class" on the asset
- Use the fully qualified type name here
oh thx buddy it worked
Hey, I have a problem with my input settings that I am not able to use my mouse to control the Pitch and Yaw direction with my mouse, I've tried diff tutorials on youtube but many of them have a outdated version of the Input controller so I duno if there are like any minor changes that I mustve missed
Ok i see some issues here but can you explain exactly what you mean by "I am not able to use my mouse to control the Pitch and Yaw direction with my mouse"?
What happens when you try?
You should also show the configuration of the PitchYaw action itself
sorry, here you go. but atm nothing happens, when I move forward and try to use my mouse it doesn't follow
!code
see the "large code blcoks" section below please
<:error:1413114584763596884> Command not found
There's no command called
code see.
Posting code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
It looks like you set up a Control Scheme
Can you show that control scheme?
it seems like you're applying deltaTime to the mouse input
but it's kinda hard to track with the file
Yes not only that but you're treating the input like a joystick that remains actuated permanently after receiving a certain input. Mouse delta doesn't work that way
But the biggest problem I think is that you're using control schemes meaning it's probably binding your PlayerInput to certain devices not including your mouse
If this is not a local multiplayer game my usuall recommendation is to avoid control schemes entirely
There's no control scheme set up, I'm just using the all control scheme set up atm
I see something called "New Control Scheme" in your screenshots
And your mouse binding here is not included in it
I'm not sure what you mean by that
idk how it's showing up, at least it's empty for me
the "new control scheme" is there
i don't think there's a concept of global control schemes
honestly I don't remember how it even got there
but regardless it seems just like the same settings
Okay. So the problem was the "new control scheme", just deleted it and it worked all the sudden haha
Minor mistake that just went over me, thanks for helping out!
yep, was trying to say...
But I don't know how it affects it when it wasn't being used. Was it because it was a set as global controller?
just trying to understand what it was
or what it did
Control schemes are used to group input devices so that PlayerInput instances can grab exclusive use of a "set" of devices to assign to a single player
they're really there for local multiplayer
when you have one, the PlayerInput will essentially grab some input devices based on the control schemes and ignore all other devices
hypothetically these devices would be available for other PlayerInputs in a lcoal multiplayer situation
but if you're not doing local multiplayer it just leads to annoying confusion like this
iumagine like - player1 gets a controller, player2 gets keayboard + mouse
aaaah I see, well I am for sure not gona do any muliplayer related anyway so it's good to know that I can just avoid that feature for now
thank you sir
I have an issue where unity stops reading inputs from a control scheme and switches to the other one, I have two control schemes (Keyboard, Gamepad) and they both work on play, but after my death and respawn functions run (Instantiates a new player object, destroys old one) I stop recieving inputs from the most recent one. If my player dies while using keyboard, after the respawn keyboard inputs don't do anything and the active scheme switches to gamepad despite there being no input on that scheme. Does anyone know how to fix this?
actually never mind, I just stopped trying to use control schemes and it works. is there a way to find what the most recent input device is?
nvm found documentation lol
most likely you're using the PlayerInput component and actually instantiating a new one
the new one gets treated as a new human player by the input system and it tries to assign it an unused set of input devices
If you're not doing local multiplayer I recommend not using control schemes at all
a very specfic question , as u see, here is a grid plan with many buttons
because im planning to make smartphone apps, so i had implmented zoom feature for the plan map, however, the only problem is, how to safely detect if two fingers are inside the plan map area only?
currently im implementing my own gestures using enhanced touch
public static float ZoomAction(this InputManager manager)
{
if (Touch.activeTouches.Count < 2)
{
return 0; //single touch , ignore
}
Touch touch0 = Touch.activeTouches[0];
Touch touch1 = Touch.activeTouches[1];
if (touch0.phase != TouchPhase.Moved && touch1.phase != TouchPhase.Moved)
{
return 0;
}
if (touch0.history.Count < 1 || touch1.history.Count < 1)
{
return 0;
}
return <calculated results>
}```
Is it worth to change from "Send Messages" to invoke C# Events?
But I heard that Send messages is just worse Invoke Unity Events
it's alright for fast prototyping
KK Ty
I'm hitting such a wall with splitscreen UI. I'm very close, the mouse and gamepad will both hover their respective UIs correctly, but the "submit" UI action just isn't causing the button to submit for some reason (on both mouse and gamepad).
Is there anyone that has done this before that can help? I'm not even sure what screenshots to drop here because there's a lot of UI going on. I'd be happy to jump on a call or something or provide any screenshots. Thanks!
Have only the button with nothing else under it, if it still doesn't work, trigger the submit via code and see if it still doesn't work.
Turns out I did set everything up correctly and it's working now. For those wondering how to make it work, this is the tutorial I followed:
https://www.youtube.com/watch?v=81GecyuNapg
My issue came from migrating some of my UI, which removed the button listeners, so it was working this whole time just the buttons weren't told to do anything 🤦♂️
In this video we will use the Multiplayer Event System from the new Input System in Unity to separate the UI for local multiplayer games.
ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓
https://sam-yam.itch.io/samyam-full-source-code-to-all-videos
If you want to learn how to set up local multiplayer with the new input system, you...
Thanks for your diagnosis help @neon burrow!
deos someoen know why when i enetr unity project the input system widnow doesn't hswo everything and it is so buggy and i need to run the game while openeing the window to make the bug go ?
the input system widnow doesn't hswo everything
What does it show? What are you expecting it to show?
wait i will shwo you an example cuz i feel the what i said is weird
before running the game
after runnign the game
I want to be able to:
- When there is only one player, switch between gamepad and keyboard/mouse whenever the player wants.
- When there are several players, at specific times, be able to say that a particular controller for a particular player should be activated and not the others.
I already disable the “Joining Enabled By Default” option outside of my hub.
How do I do these two things?
guys i need a bit of help here
so i am using send message
and the action is set to value
but when i click on the button, the event only gets called once
it need it to be called as long as the button is hold
every frame?
well, you can use a press & release interaction and save the state yourself
i don't think value events are called every frame anyways, only when they change, though i might be wrong on that
i know but i prefer if it got called every frame
so this might be the easy option if im remembering correctly
right, i'm saying input system just doesn't do that (if i'm remembering correctly.)
alright thanks though
you can do this instead
Helloooooo. I was having trouble with setting up some controls. I'm using the Input System but I can't get my button input to only return true on the frame I start hitting the button. I've read a lot of documentation, but nothing seems to work.
Same for when I release the button.
I'm trying to figure out 2d platformer movement and most platformers I see have it so holding the button doesn't buffer, only pressing.
started seems to do absolutely nothing.
you should read through https://docs.unity3d.com/Packages/com.unity.inputsystem@1.16/manual/Interactions.html, specifically the default interaction for buttons
I actually have been looking through that and trying a bunch of started, performed, and cancelled for various interaction properties.
It was good information, but it never worked how I thought the documentation said it would work
WasPressedThisFrame also seems to not work
It just activates every frame
you should add some logging in there which should clarify what's happening
Like debug code?
I assume you put WasPressedThisFrame into your jump callback, so it should always be true
you're missing some concepts and not debugging very effectively. If you log the above code, I would expect context.started to always be false because those actions weren't started, they were performed
Got it. I understand.
Am I just misunderstanding how these actions work and in reality I should just write some code that sets a variable to true for only one frame?
I'll start debugging more
well presumably you have something else setting jumpInput false right? If it makes more sense to you to use polling instead of events, that's perfectly fine too
performed should solve your problem as-is though
Fair.
Weird. When I hold down the button with started it is both true and false on the same frame.
I'm not as use to the debugging system for unity since I'm more use to other languages. Thanks for the tips.
the context is first started, and then immediately (because the control has no button press threshold) performed
Okay, I think I'm starting to understand more.
Thank you for the help
I'll just write a bunch of code to do the one frame check for me.
Because as far as I can tell, the input system can't do that.
Or not...
you can poll if you absolutely need to, but most of the time a one frame check isn't useful except to set an enabled flag which you can already do with your existing code like this
jumpInput = jumpInput || context.performed;
Otherwise, if you're consuming input in physics updates, you'll need to change the update mode or risk missing input events
Okay, sorry if my stuff is exhausting. I'm just really confused.
I'm just trying to figure out how to make a button only read true for one action and not repeating the same action over and over again.
is your character physics-based? if yes, use above snippet and consume the jump input during fixed update. If no, why have jumpInput at all? just run logic immediately
By physics-based do you mean do I have a rigidbody component?
are you doing movement in FixedUpdate?
I'm doing movement in Update
does that movement involve physics forces?
I guess that would be yes. I'm using AddForce to do acceleration.
then unless you're using one-time impulses, you should probably move that into FixedUpdate and either use the strategy I mentioned or change the input system update mode
Oh, I didn't realize it'd be useful to update the player on a fixed time interval.
if you don't, then depending on how your movement works, it'll either be unstable (if you're modifying force by delta time) or frame rate dependent
Okay, I just looked up a video to better understand.
I really wanna thank you for your help. This was a good dive into the logic. I really appreciate what you did.
Hello guys, im a learning Game Dev and am currently working on getting Touch inputs for a mobile game. How do I implement a Stick with the legacy input system, that when i move the stick, he rotates?
Anyone know a good tutorial for that? Or have Code snippets to show? Thanks in advance
you dont need he new Input System for on screen joy stick
it works fine with legacy
if you want some tutorial @languid falcon
In this video, you will learn how to add mobile joystick input into your Unity game. The on-screen joystick is useful for mobile games because it can make your player move or jump. It isn't a physical joystick, it is more a simulation of a joystick that works by dragging the solid circle. This asset is super cool for mobile game development!
DO...
Hi! In this video I will show you How to Create Mobile Joystick in Unity 3D. With this joystick we will be able to implement the movement for the 3D character, and of course connect the animations.
Joystick: https://clck.ru/Vs7ik
PlayerController: https://clck.ru/Vs6zs
How to Create Mobile Joystick in Unity 3D | Unity, Joystick, Tutorial, 2021...
Thanks, i found a way to do it with either recttransform or screentoworldpoint
tyty
Hello, I wanted to ask a quick question on input/player movement. I was doing the 2D beginner tutorial (Sprite Flight) where when you click, a little ship accelerates towards where your mouse is by using AddForce on the rigid body.
My question is: how come we don't multiple the force vector by delta time? Won't this mean that if the fps is higher, more force will be applied per second and therefore the acceleration is higher?
Is AddForce happening in Update or FixedUpdate
The correct way to do it would be in FixedUpdate, and then it doesn't matter what the framerate is
how come we don't multiple the force vector by delta time
addforce (if used correctly with Force or Acceleration modes) already accounts for deltaTime, so multiplying it in first would end up applying deltaTime twice
The tutorial places it in Update, I didn't even know there were other update functions haha
was there a forcemode? 🤨
Cool, I haven't heard of force or acceleration modes so I might look that up
you'd probably be able to tell
If I get time later I can link the tutorial
As far as I know, the tutorial just applied AddForce onto a rigid body 2D and called it a day
I'm not at my pc right now but I'll double check when I can
// 3D
AddForce(x); // ForceMode.Force by default
AddForce(x, ForceMode.Force);
AddForce(x, ForceMode.Acceleration);
AddForce(x, ForceMode.Impulse);
AddForce(x, ForceMode.VelocityChange);
// 2D
AddForce(x); // ForceMode2D.Force by default
AddForce(x, ForceMode2D.Force);
AddForce(x, ForceMode2D.Impulse);
Oh okay so it should be on by default
Anyone ? 🥲
the Force or Acceleration modes are "continuous" modes, meant to be called multiple times for a continuous force
the Impulse and VelocityChange modes are "instantaneous" modes, meant to be called once per some action
since Impulse and VelocityChange are instantaneous, deltaTime doesn't matter, they can be used in any cycle
but Force and Acceleration account for deltaTime internally, and they expect to be called in FixedUpdate. calling them on a different cycle (like Update) means you'll get inconsistent results.
-# (Force and Impulse consider mass, Acceleration and VelocityChange don't)
Thank you
That's not correct then
To be strictly correct forces should only ever be added in FixedUpdate and deltaTime should never be multiplied into it
You can get away with one-off forces in Update though.
Unity Learn
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
Sorry I was only able to send this now, this is the tutorial I was referring to
Is it actually not correct?
yeah
So Input.mousePosition and mouse.ReadValue<Vector2>() give the same readings correct?
playerControls.PlayerMovement.Look.performed += i => mousePos = i.ReadValue<Vector2>();
Vector3 look = Camera.main.ScreenToWorldPoint(inputManager.mousePos);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, maxDistance: 500))
{
lookPos = hit.point;
}
Vector3 lookDir = lookPos - transform.position;
lookDir.y = 0;
Quaternion targetRotation = Quaternion.LookRotation(lookDir);
Quaternion playerRotation = Quaternion.Slerp(transform.transform.rotation, targetRotation, playerControlData.rotationSpeed * Time.deltaTime);
transform.rotation = playerRotation;```
The above code works fine. But when i try to use look to control rotation nothing works no matter where i implement "look" . What am i not seeing.
What did you bind the Look action to?
Vector3 lookDir = look - transform.position;
tried replacing the raycast
That isn't what I'm asking for
I mean how did you set up the look action in the actions asset
Not the code
Sorry its 1am and very tired let me read again
Honestly probably should look at a tut instead im working this out kinda with things i know
Ok - for this I do recommend using a Passthrough action but it's otherwise alright
But your code is not using this from what you showed above
And "doesn't work" is pretty vague. What's actually happening? And maybe show the full script
no thats the current working method but not to my liking. when i change to Vector3 lookDir = look - transform.position; the character doesnt even try to look around
Sorry is this an input question or a question about your look logic
thats where im not sure
i wasnt sure if i am doing the input right or if its my logic
ScreenToWorldPoint is not going to be equivalent to that whole screen point to ray and Raycast setup you have
You're not doing a 1-1 comparison here
Ope didnt see i still had that as WorldSpace
Wait yes. I want to be able to look around without the use of ray. So what with the system needs changed to use WorldSpace
Just feed the new mouse position through the same process as the old
Why are you changing the whole process?
That's not an input system issue then, you're changing the code entirely
okay let me try using what i ahve to passing the new mouse pos
so i changed Ray ray = Camera.main.ScreenPointToRay(inputManager.mousePos); now it will not turn at all. Maybe im not understanding you correctly
Start debugging your code
Print out Input.mousrPosition and the mousePos variable
Make sure they are both working as expected
They should print the same value
Where is this code running?
FixedUpdate => ``` private void HandleRotation()
{
Vector3 look = Camera.main.ScreenToWorldPoint(inputManager.mousePos);
print(Input.mousePosition + " " + inputManager.mousePos);
Ray ray = Camera.main.ScreenPointToRay(inputManager.mousePos);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 500))
{
lookPos = hit.point;
}
Vector3 lookDir = lookPos - transform.position;
lookDir.y = 0;
Quaternion targetRotation = Quaternion.LookRotation(lookDir);
Quaternion playerRotation = Quaternion.Slerp(transform.transform.rotation, targetRotation, playerControlData.rotationSpeed * Time.deltaTime);
transform.rotation = playerRotation;
}```
playerControls.PlayerMovement.Look.performed += i => mousePos = i.ReadValue<Vector2>();
Yeah you can't do input handling in FixedUpdate
That's your issue
Still the same issue even when called from Update()
Nothing is now running in fixed everything was moved to Update
also changed to pass through btw
thanks for that
Out of curiosity what do you get with Mouse.current.position.ReadValue()?
Yes
That works
Now to see how i can work with Camera.main.ScreenToWorldPoint
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Camera.ScreenToWorldPoint.html and off i go for no reason at 2 am
If it's a 3D game it's not a promising approach
Either Physics.Raycast or Plane.Raycast are the way to go, with ScreenPointToRay
Really. Is it because converting 2d to 3d or something else?
Because it doesn't make sense for what you're trying to do (from what I can tell)
Is there a reason you want to stop using Raycast?
Mainly just seeing if their is a way to eliminate the use of it.
now i have one last question how would i set up a input in the new system for Mouse.current.position.ReadValue()
Add it to here
My understanding is that Mouse[position] should have done it
weird
they dont read the same when debugging
Mouse.current.position.ReadValue() works perfect and returns the same as Input.mousePos but
playerControls.PlayerMovement.Look.performed += i => mousePos = i.ReadValue<Vector2>();
mosPos reads nothing right
let me try something
nope that didnt work
Well going to sleep. Still havent figured this fully out the way i want it to work
Thank you for the help though
Hi, everyone!, i am having a problem when using gamepad sticks for movement/look, when i constantly hold the stick at a still position the input received is not continous, it's like
(0.5, 0),
(0.5, 0),
(0, 0),
(0.5, 0)
(0.5, 0)
and this loop keeps going on the bad frame (0,0) doesn't always come only once, it sometimes comes 2-3 times, my question is why is this happening, it happens in the starter assets third person controller as well (i checked it to be sure), this causes a very bad effect, it rotates the cam then stops for a few ms then rotates then stops...... and on and on,
i am using a PS4 controller connected to my mac using bluetooth,
this is very annoying, as it causes a start stop effect instead of continous movement/look
have you tried a gamepad test website to check if it's an issue outside or inside unity?
also check the input debugger perhaps
also make sure you aren't polling in a fixed time step
hm, no
will do
i have a ps4 controller that isn't like the original ps4 controllers, it seems to be a modified one, it has USB-C instead of the USB which was the default for PS4 controllers i originally had, so the original one seems to be better for some reason so i was using that now, but let's see what the gamepad tester says for the modified controller etc, also couldn't get it to connect wired to my mac, the original one allows both wired/wireless while the other one doesn't (only wireless)
for some reason
well turns out the modified controller is very flickery in it's joystick inputs, so can't do anything i guess
funny, it's soo bad,
while the original one is super stable
ok so i guess we can't do anything to fix this
though it seems to work fine with PS4 games e.g. over cooked 2
doesn't show any jitter there in the game
btw ty @fierce compass
from having this code:
public class Player : NPC
{
bool PressedJump = false;
Vector2 MovementInput;
NPC NPC;
NPC NPC2;
void Awake()
{
NPC = this;
}
void FixedUpdate()
{
Debug.Log(NPC2 == NPC); // false, NPC2 stays null
}
public void Move(InputAction.CallbackContext context)
{
NPC2 = this;
MovementInput = context.action.ReadValue<Vector2>();
}
}
im noticing that the function Move is not referring to the same living instance in the scene (there is only 1 Player). yet there is nothing else to reference (shown in the image). am I missing something? I've looked all around, all tutorials do not use prefabs, and I've been having issues with both methods (even with just setting a public InputActionReference). would like advice.
this shouldn't be the case, just not how c# works.
functions.. don't really "refer" to anything inherently, this isn't js where this is bound to a call
have you confirmed that Move is even being called?
oh, are you assigning the prefab in the callback..
it's not that Move is referring to a different instance, it's that you're referring to Move of a different instance
don't use that selection menu
drag the player in the hierarchy (or even one of the components in the inspector) into that slot
the selection menu will show assets, that's probably not what you want
ya Moved worked, this was referring to a game object, logging it's MovementInput showed an updated number, but when i set a breakpoint for the FixedUpdate, it never showed the updated number (likely never changed, hence potentially referring to the prefab itself somehow...)
got it working with Send Messages and Invoke C Sharp Events
not sure what exactly you're trying to show here
once FixedUpdate rolls around, the MovementInput is 0, 0, 0, when it was 1, 0, 0 before inside of OnMove
i can grab the hash maybe if that makes it more clear
or just the actual reference
it seems like you're grabbing the wrong object here. not sure why
oh wait hold on
yeah grabbing the prefab asset and the prefab root in the scene are different
so what you did there should work
have you tried just logging Debug.Log("Awake/Move", this) etc in Awake and Move, and see what objects those point to
i mean, it seems to me that the debugger was also showing it working fine
NPC was set when you broke in OnMove. Awake wouldntve been called if it were in the prefab
then in FixedUpdate, NPC2 was set as well
the MovementInput was set to 0 for both, probably because another OnMove was called before the FixedUpdate
though, btw, fields should generally be in camelCase, not PascalCase
you probably shouldn't have a field Rigidbody or Camera shadowing the type names.
ehh, i guess its fine, renamed it
though, btw, fields should generally be in camelCase, not PascalCase
not a field, i usually just pascalcase out of habit. i dont like thinking too much about style conventions
(fwiw this could be an autoproperty)
ya i didnt realize that this coulda been a thing. i just checked real quick and there is a .canceled so i guess i need to check only for performed
you do need to check canceled as well
cant, cuz of the decorator
that's what happens when the input is released
you can
[field: SerializeField] lets the attribute target the backing field
oh wtf
so you could have something like [field: SerializeField] public Rigidbody _Rigidbody { get; protected set; }
wait
what c# version can u go up to with Unity
Mar 18, 2025 — Officially Unity only supports up to C# language version 9.0. Sure you can force it up to 10.0 or whatnot, and some things may work. But if they
i think that's not about the attribute
you have get as autoimplemented but set as not
okay ima just do it the other way since i usually like to have getter/setter logic eventually
for example, CurrentHealth
this is a feature that unity's version of c# doesn't have
public float prop {
get => field * 2;
set => field = value / 2;
}
```using the `field` keyword in accessors to refer to the automatic backing field
just ask instead of pinging me and making me wait lol
no need to ping me for a new question in the first place lol
how do u make it so that the player script is actually following the NPC script?
these arent the default values
from NPC Script
not sure what you mean by "follow"
you still haven't said what you mean by "follow"
is Player inheriting NPC or something?
ya
well, that'd mean you'd have to remove the NPC component and replace it with the Player component
unfortunately unity doesn't really do inheritance with components well
usually i just use composition in this sort of situation instead
okay should i keep inherited items in code then
i planned to do that too, but woulda liked some defaults
to have just as a baseline for stats
wanted to just do them in the editor
you can use the Reset message to grab the values i guess
so if any inherited scripts never changed a field, they get updated as well
keep in mind that the inherited script isn't inheriting the specific npc component
using composition instead fits more into unity's model
the defaults would be in NPC, Player wouldn't specify any of these values, it'd grab them from NPC
ahh ur right
okay i should def. move this off, this wont work like this
im not even sure why they showed up since it only shows up in NPC
i mean ya there isnt much here
i didnt think much of it tho
k im guessing you cant tbh
okay ik what to do now
im removing the script from NPC prefab. thanks.
I need a medic!!!
I am physically unable to disable my action input . no matter what I try .. This is what I have tried
public void DisableInput()
{
if (_playerInput != null)
_playerInput.currentActionMap?.Disable();
}
public void DisableInput()
{
if (_playerInput != null)
_playerInput.DeactivateInput();
}
public void DisableInput()
{
if (_playerInput != null)
_playerInput.enabled = false;
}
None of them work
I can still move my character about during a cutscene
This a tiny snippet of my input class
public class PlayerInputV2 : MonoBehaviour
{
#region Inspector
[Header("Action Map Names")]
[SerializeField] private string playerMap = "Player";
[SerializeField] private string uiMap = "UI";
#endregion
#region Runtime
private PlayerInput _playerInput;
private readonly Dictionary<InputAction, bool> _toggleStates = new();
// continuous
public Vector2 MoveInput { get; private set; }
public Vector2 LookInput { get; private set; }
public Vector2 DPadInput { get; private set; }
public float AimInput { get; private set; }
public float AttackValue { get; private set; }
public string UiActionMapName => uiMap;
public string PlayerActionMapName => playerMap;
#endregion
#region Unity
void Awake()
{
_playerInput = GetComponent<PlayerInput>();
ValidationUtils.CheckNull(_playerInput, this, "Player Input");
}
void OnEnable()
{
PlayerEvents.PlayerStateChanged += SwitchActionMap;
UiSignals.OnUiStateChanged += OnUiStateChangedMap;
// cutscene input handling
UiSignals.OnEnterCutscene += HandleCutsceneStart;
UiSignals.OnExitCutscene += HandleCutsceneEnd;
}
how are you recieving input?
Not sure I understand ? Keybaord/Gamepad ? And behavior is set to Send Messages
so you're receiving messages on PlayerInputV2?
and _playerInput is the built-in Player Input component, right?
well, the disablings you sent above seem correct. have you tried debugging them to make sure they're being called, at least?
i'd remove the null checks so you get an error message if it's the issue
it's 100% being called
But for some reason I am still able to control my player duringa cutscene .
odd, ive used PlayerInput with SendMessages and ive used .enabled = false;, and that worked fine
Ya, I have disabled my input begore. This is the first time doing it via the timeline and events, but for the life of me I am unable to turn it off.. I can see it turn off in code, but I can still move my player about
make sure you're targetting the right object
try adding a context this to your logs and see what object it points to
Sure lei do that
My bet is that your code is not actually using that PlayerInput component to move
we need more context
Hmmm I thought so as well , but It is.
Also it looks like you have this Middleman component called PlayerInputV2
with stuff like:
public Vector2 MoveInput { get; private set; }
public Vector2 LookInput { get; private set; }
public Vector2 DPadInput { get; private set; }
public float AimInput { get; private set; }
public float AttackValue { get; private set; }```
Disabling your PlayerInput component is not going to magically make those values all become 0 or whatever
this is reading your field from the PlayerInputV2 middleman
Let me just dump the pastebin here
Pastebin
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.
this code is going to keep running, no matter what happens to the PlayerInput.
The PlayerInputV2 manages ALL input for the project
you aren't using sendmessages
ah whoops i'll continue in the thread
Is the generated c# class from the action asset only for Quality of Life?
I'm asking this because I'm planning to stop using this generated class. So I don't need to use this stupid Singleton to house this generated c# class and use it throught my project. Also, while working with the InputSystemUIInputModule component in EventSystem, it seems to introduce too many unintutive practises.
I'm planning to completely shift to using only the Actionasset. I think the only downside is -- using Find() to get actionmaps, actions and that being verbose. Are there any other downsides?
Is the generated c# class from the action asset only for Quality of Life?
i mean, you could argue that the entire inputsystem is QoL
there are several ways to use the input system, and using the generated class is just one of them, it's not specifically more QoL than the others
imo needing magic strings is a pretty heavy downside
I'm fine with magic strings. I can implement custom validators for that. The generated c# class~~ is a mess~~ is too much maintenance
there are several other methods that don't require magic strings
InputActionReferences, for example
Yes that's what I'm reffering to -- just using the inputaction asset plainly.
oh
This seems sweet!
Thanks for letting me know
Hello, Can someone help me On my right button it is detected twice, on press and on release, can someone tell me how to do to just have one ( its cuz it spawn twice my vfx on ground to show where i'll go with navmesh)
i tried that but it still doesnt work
you need to show your code, and I'll show you how to fix it
Also the "Press Only" interaction is definitely not necessary
I'm using playmaker
So when i clic right button it send "clic movement" to my FSM and my fsm get the position on the ground and spawn fx on this position
this abstraction is hiding the data you need to handle it properly
the Clic event passes a CallbackContext parameter which has the data you need to determine if it's the click or the release
but you're not passing that through to playmaker
you're just raising your event no matter what
and ignoring the parameter
I've never used playmaker, so this is based on a quick google search, but this thread should point you in the right direction:
https://hutonggames.com/playmakerforum/index.php?topic=20498.0 and https://hutonggames.com/playmakerforum/index.php?PHPSESSID=af76b4d440650b72b3dc344c7e5e2d92&topic=21797.msg95729#msg95729
Oh ok, i just need to tell to PM if its release or press and thats all, i'll try to search it with your link, thank you !
With a input action pressed it finaly work, thanks for your help ! have a nice day
Can someone please explain to me if IPointerHandlers are good? I'm currently using an InputReaderSO but I dont know if I should raycast or use them!
In my game there is a cursor (even with controllers) and you can select non ui objects in the scene. I cant wrap my head around
Are they good? Wdym by "good"?
and what is an "InputReaderSO"?
So are you asking if they're "good" or are you asking for help getting it to work?
Input reader scriptable object
Like (sorry Im on phone)
InputReader : ScriptableObject, IPlayerActions
{
public Action OnMove;
public void Move(Input..) => OnMove?.Invoke()
}
And I pass it down on classes that need input like an SO
This sounds completely unrelated to "IPointerHandlers"
This is what I think you mean when you say that:
https://docs.unity3d.com/Packages/com.unity.ugui@2.0/manual/SupportedEvents.html
Good the sense if I should prefer raycast om the gameobject over PointerHandlers with the controller in mind (idk honestly if they are the same)
I don't think your input handling is relevant at all to whether you should use event system event handlers
For the record yes, you should almost definitely use the event system event handlers instead of manual raycasting
It operates seamlessly with your UI and gives you behavior like the UI blocking game world interactions for free
Thank you!
Is there a way to stop Unity showing this message everytime it starts up?
I can't uninstall the package itself because one of the GoogleXR packages we're using keeps it as a dependency, but I was hoping we could at least suppress the prompt
I have ActiveInputHandling set to Old in Player settings
set active input handling to both. Something in your project is using the new system
ok ty, I was just worried it'd cause oddities, if not, then, meh
some platforms don't support "Both", so keep that in mind
this is the input system channel, #💻┃unity-talk
editor > shortcuts
Sounds good, was unsere where to place my question since it was sort of input will move it there ty!
input system is a specific thing for dealing with input in game, this channel isn't for input in general, yeah
there's some stuff pinned if you'd like to learn more
oh, ours is a cross-platform enterprise project, maybe I'm better off just having Unity prompt
im in bad need of help with the input system dude. i just cant get the mouse to work
You need to share more details
hey do you know if there is a discord channel or server where i can get some help and guidance? as a newbie?
@vale rune You need to say what you've tried, and what specifically is not doing what it should. Otherwise it could just be that your mouse isn't plugged in.
I'm using the old input system (I think) and am trying to set up more than one controller (so I can have 3+ players) but the controllers are only taking joystick input when the joynum is set to "Get motion from all joysticks" which obviously wont work when theres more than 1 controller
how does unity determine which controller is Joystick 1/Joystick 2 etc etc
for the buttons it seems to maybe work? theres at least response there instead of there just being nothing
My game worked perfectly last night. I saved, closed the project, opened project today, raycasts not working. Cannot find a reason in the code or anything. What's going on?
- What does this have to do with the input system?
- You'd have to share your code, details about the scene, and any debugging steps you've taken so far
Phys was off for some reason. Raycast was the issue.
I having a build only issue on the newest version of 6000.3.f1, and one of the older 6000.1 versions. Whenever a new controller (xbox series x) connects, the game recognizes the controller (according to the logs) but the event system will not respond to any input. Upon a game restart, the controller will work properly. Any ideas?
Are you using the PlayerInput component? Are you using control schemes?
After a lot more debugging it seems to be issue specifically with steam input. Perhaps when connecting a controller while the game is launched steam input overrides in some way? Not sure but I'll be moving this to a steam related forum for help. Thank you!
I am very much struggling to find a good tutorial for InputSystem. There seems to be many ways to go about using it, and pros/cons per method. There doesn't seem to be a good place to see each method for what it is and how it compares to the others.
yeah, with flexibility comes complexity, unfortunately
i think good tutorials would just be choosing one way to use the input system and going with that
if you want to compare the various methods you'd probably need a deeper understanding than what a tutorial might give
Maybe tutorial was the wrong word
I more meant a deep dive comparison in each method
I seem to pick up a lot of distaste towards the SendMessages method since it apparently isn't performant
Invoking C# events seems a little bit overly verbose for such simple things, and not being a huge fan of redudant verbosity myself, I think that Invoke Unity Events might be a happy medium
messages are inherently less performant due to the reflection, sure, but is it really on a scale that's significant
it's definitely something to consider but i don't think it's an outright problem
though, there is a real downside in it being by name rather than by reference
It seems to just be you handle everything yourself in scripting rather than a playerinput body doing anything for you
that's still through PlayerInput, it'd still be the thing invoking the events, no?
I haven't seen anyone do it that way
there are other methods that don't involve a PlayerInput at all
https://www.youtube.com/watch?v=JLr54sMGlPc
This is actually pretty good at showing a comparison between each method
Chapters:
0:00 Intro & Install
1:26 Basic Platformer Script (skip this part)
6:11 Input System Introduction
9:25 Send Messages
14:00 Broadcast Messages
16:19 Invoke Unity Events
21:23 Invoke C# Events
30:16 Brief Recap
I needed the extra information you get from a CallbackContext, but I don't really want to handle enabling listeners myself, so Unity Events seems like a semi-performant method for me.
Something I am super confused about is look sensitivity. If I don't multiple by Time.deltatime, it seems to work perfectly and not scale with framerate on a mouse. However, on a gamepad, it DOES scale with framerate somehow. It's really odd. I don't know if i should or shouldnt be multiplying by it, if i multiply by it then mouse sensitivity scales with framerate. I'm highly confused at the play here
Mouse input should not be multiplied by deltaTime because it's already a framerate independent value (amount the mouse moved this frame)
Joystick needs to be multiplied by deltaTime
How can you fetch the device being used
Honestly I just usually use two different input actions for this
Isn’t that input manager like
I thought the whole point of input system was unify it
Also is the fact that direction on left stic is inverse to what it should be normal
Doing this makes moving incredibly slow
Fix the constant you multiply by
It's necessary
Is it normal for that constant to be about 120
Could be
Hey so no matter what I try my sprint won't work. I only want it to print out a true and false rn so I can tell why it won't revert back to false after releasing the button. My current code looks roughly like this and it is set to press and release
private bool sprintInput;
void OnSprint(InputValue value)
{
sprintInput = value.isPressed;
}
void Update()
{
Debug.Log("Sprint is" + sprintInput)
}
It prints true then never reverts to false
could you try adding a log to OnSprint, see if you're getting the event when releasing to begin with
Uhhh... somehow it's suddenly working perfectly fine. Idek what I did wrong
Or right to be completely honest
mightve just needed a reload or something to trigger saving
@brickwall0004 muted
Reason: Too many messages in multiple channels
Duration: 29 minutes and 45 seconds
Hi, so whenever I make a prefab of my player, it loses all the references to the input action references
Why is this?
could you be more specific about what you mean by "make a prefab of the player"
Dragging the player empty and it's children into the project screen area
(it's not an empty, it's a gameobject)
Yes sorry, the gameobject
it was just assigned to input action references from an input action asset in projects, right?
(not sure how it could be otherwise, just making sure)
Yes, the player object in the scene, was given references from this
is it already a prefab instance where this would be creating a prefab variant?
No
not sure if this matters, but try saving the scene if it isn't already
This is when it's in the scene, not as a prefab
After being dragged into the project area and made to a prefab
are the fields being changed in OnValidate or Reset?
or in anything else that might be running in the editor
I'm not sure what would be running in the editor other than the standard stuff that comes with unity
I at least haven't changed anything
after android build the touch system doesnot work
there is no respose to touch , i think touch is not being recorded in android
but when using unity remote it works
Please don't ping usergroups for help, unless it's server related. Thanks.
do you have input handling set to both, perhaps?
im not sure this channel is for the old input system
can u help still tho
is it just on android that you're having these issues, or do they happen in the editor too
i am stuck from hours
no just on android
it works with remote on android too
make sure you have an eventsystem i guess? in case your scene loading workflow in the editor is different from a build
i searched web and found many faced same issue but no solution
yes i have eventsystem
It's for both, it's just there's little point in learning the old one as new one supersedes it in every way.
why do you have the new input system ui component on there if you're using the old input system? not sure that'd work, i don't really know how the eventsystem (or the inputsystem adapter) work internally
the event system came automatically with the canvas
maybe i should change to input system "both" ??
no, android doesn't support it
you'd need the "Standalone Input Module" component afaict
where shall I put this ?
replacing the "input system ui input module" component on the same gameobject as the event system
you have one right there
also consider removing the input system package if you aren't using it (though, eventually you should learn to use it)
yeah but in this project there was no use for other input rather than touch so claude suggested to use old system
sooo have you replaced that component
@fierce compass So what's even weirder is when open the player prefab, and place the input references. Then press the arrow back to get back to my scene, then click on the prefab in the project window, they're gone
replace it with the standalone input module, like mentioned before
could you try checking in debug mode
didn;t worked
I've now given it all the inputs
And when I go back it seems to stay?
oh huh, i thought input action references used GUIDs, nvm on that point then
make sure to switch back to the normal inspector
Right, but why does it remember the referneces now?
Omg it works... but I have no idea why
Maybe I just had to restart the editor?
Lmao
Implying I want to spend an extra 10 seconds setting up the input map
old input system will always be best for prototyping for me
...you don't need to?
Can you still listen to any input and polling it with the 'new' system? Thought it was only mouse input at most
yes
Ok yeah I see it. Well, guess I've just been lazy
Pre Unity 2022.3.43f1 I was able to have a Input Action Reference, which I could call.
public InputActionReference aimAction;
aimAction.action.Disable();
And then make the link in editor to the Input Action Asset, and it would disable the aim.
Now on Unity 2022.3.62f3 this doesn't work. Not only that, if I disable all Input Actions, UI Navigation still works. Why?
I didn't even go up a Unity Version, I moved up for the security reason.
(to be pedantic, you did go up several patch versions)
I went up in patches, and, the functions I'm referencing were not marked as obsolete.
Now on Unity 2022.3.62f3 this doesn't work
What does "doesn't work" mean? Is there an error? What happens when you try?
if I disable all Input Actions, UI Navigation still works
Your UI input module is using a different instance of the actions asset than the one you are disabling, likely.
It doesn't disable the input actions/the input actions are still allowed.
The UI Input Module is using the same action asset that it has been using for nearly 2~ years, and I have double checked that it is pointing towards the same asset.
Same asset but maybe not the same instance
Again... This wasn't a problem previously...
But where did you get the reference to the asset instance from
PlayerInput often muddies the water
PlayerInput likes to make its own copy of the asset sometimes
wait, sometimes?
Both are just directly referencing the generated PlayerINputControls
Wait those components are both on the same object?
Yes.
That's pretty weird
Both are also pointing to the same object.
PlayerInput does weird stuff - and can be affected by the existence or nonexistence of other PlayerInputs in the scene
as well as whether they're instantiated at runtime or not
Theres one single PlayerInput, always. No additional ones are created.
especially by PlayerInputManager (if being used)
Do some debugging
check if myPlayerInput.actions is the same instance as myUIInputModule.actionsAsset
I mean, sure.
However that doesn't explain why I can no longer call
public InputActionReference aimAction;
aimAction.action.Disable();
It doesn't disable it.
that would be explained by the PlayerINput component operating on its own cloned instance of the asset
It used to disable said action. It no longer disables said action.
the InputActionReference would be pointing to the "original" in the asset, and the PI would be using the clone, unaware of anything you did with the IAR
Again start debugging it - you can even print whether the individual actions in question are enabled or disabled
I understand it worked before
Something changed, possibly in a subtle way. So now we have to find out what
So then why the hell is PlayerInput creating a clone of the objec then? Whats the point of even pointing it towards something?
oh, the step that clones the asset is conditional.
for (int i = 0; i < s_AllActivePlayersCount; i++)
{
if (s_AllActivePlayers[i].m_Actions == m_Actions && s_AllActivePlayers[i] != this)
{
CopyActionAssetAndApplyBindingOverrides();
break;
}
}
To be honest I avoid PlayerInput unless I'm specifically implementing local multiplayer
largely due to this kind of mysticism
So your recommendation would be to move away from it?
Sidenote: It does show as "Cloned" in editor on Runtime.
I still dont know why its cloning it when I have 1 player only.
yep that's a sure sign it's a cloned instance
yes if you want to be doing things like universally managing the state of your input actions and action maps, you'd be much better off managing your own actions asset instance.
Then you're in full control of it and can do whatever you want and not run into weird ephemeral issues like this
you can also keep using playerinput but just do myPlayerInput.actions = myManagedInstance;
either way - managing your own instance is key
Setting it at runtime via
playerInput.actions = inputActionAsset;
Doesn't seem to work. I can manually drag the asset myself onto the object and it works fine, however, setting it via Start or even delaying it by a few seconds still doesn't like that.
to be clear it's not someting I've tried. Just something I noticed should be possible based on the api
Typically I just avoid PlayerInput entirely.
If I can set it via runtime, everything would be fixed. Based on manually doing it, everything that previously worked, works again.
it seems like that might also create a clone
But, I guess I'm going to have to write my own PlayerInput, which, is not something I'd like to do but I guess will have to happen at this rate.
you could just use any of the many other ways to receive input from the input system without replicating the interface PlayerInput provides
Its more so the project has been ongoing for long enough that, if I were to move over to any other ways to receive input, it would require a fairly large re-write of everything else.
yeah, fair enough
Its less about having the UI/interface, I still need to handle what it was handling for me, in my own script.
A short term band-aid here is just make sure you disable the action in both places everywhere you do it.
by "interface" there i just mean how it interacts with other stuff
you could make a helper function that passes in both asset references and applies it to both
I assume you mean in both the Cloned instance and non-cloned instance?
At that point I think it'll just be as easy as re-writing the PlayerInput sadly. The main thing I was using it for at the end of the day is: Passing Player Input to another scriptable object. (Long story on that one. Not going to get into it but easy enough to handle...) and automatic control swapping. (Between KB+M and Controller.)
how would it be just as easy as rewriting? It's like an extra couple of lines of code at worst.
Is there something that I might be missing that would allow it to be easier?
-# I haven't had time to actually start fixing this as of yet.
Easier than what?
How many places in your code are you disabling and enabling action maps?
Action Maps? Rarely if ever.
Actions? A fair bit/more then I should be.
Make a wrapper method that disables both actions, then, using IDE refactoring tools or LLM tools, replace all your calls to enable or disable actions with calls to the wrapper.
Because that's not a serializable class
so i have a question. I have several unity projects. One of them as of 3 days ago was working fine. I even made a game build and worked fine no issues and had not make any changes to the project or build. Today I am working on another project and the input system is acting strange like I have to keep tapping w to get it to sort of move forward and such and it barely moves with tapping and does not move at all holding it down. Now when I go to my other project same issue and including the build that both of those i never touched since it last worked. The version from my other project is using unity 6.2 and this newer project is using unity 6.3. both using the new input system
and i wanted to make sure it was not something with my pc or keyboard so i fired up a game i know for a fact was made in unity that i had purchased on steam and that works fine
perhaps check the input debugger to see if it's receiving input correctly
yea the debugger shows it fine
and holding down the key it is spamming like i would expect so technically this should be working fine
ok i think i found the issue but not sure how to block it from messing with it. I have a PXN CB1 button box for when i play a truck game but i am not using it for my unity projects so for some reason unity is trying to read from that even tho nothing is being pressed from it
i noticed the debugger showed the box on the list which gave me the light buld of that could be the issue and i unplugged the thing and it worked
because eventually there will be game options to allow for this control or that control how do i prevent a controller like that not mess up another. I am confused of why that conflicted when my xbox controller does not conflict and it works as well as the keyboard and they do not fight each other like that
I'm making a dialogue system and was thinking about how I want to handle options in dialogue.
my idea was to have a Choice action where each binding would pass in an int value.
so binding 1 passes along 0, binding 2 passes along 1, etc.
not sure if it's possible nor am I sure how to do it. anyone know?
if it's not possible I could make 9 actions and subscribe to all of them but I feel like that's a waste
It's been a minute, but when you generate a c# class from an input asset I notice that you don't need to do a Find anymore when binding maps, but it still seems like I need to do Find for each individual action, is that correct?
Unless my IDE is being funky because I would assume these actions would become accessible
Ah, ok I see what I'm doing. I was thinking that the InputActionMap would been modified to provide these accessors, but there's a specific struct instead that's generated.
making 9 (or 10) actions is by far the simplest way in the long run
the 1 minute it will take you to actually create them is worth it.
a dialogue system probably isn't displaying dozens of prompts per frame
so you can do basically whatever you want with no performance impact
Calculate the 99832958337252975th digit of pi each time
just so the computer is having some fun
What is the new keyboard input system for unity 6.2?
input system isn't new for 6.2, and it's not specific to keyboards
can you link to what you're talking about?
hey guys, is the old input system due for deprecation?
I have this message in latest Unity
is it talking about the old GetAxis(), GetButton(), etc?
yes, that's part of Input Manager
it's probably not going to be removed for a long while, and i haven't heard news about it actually being planned for deprecation
but all that isn't super relevant to using it currently, you can just pin a version for your project where Input Manager hasn't been deprecated yet and use that forever
you generally want to pin an LTS minor version for long-running projects anyways
(but you should still learn the new input system, it's pretty good)
ah yeah, ive been making a point for my time-waste hobby project to always update it and work through any pains that come as a result
normally i do as you said, just not for this particular prj
deprecating it will force me to finally look at the new input system lol
actually it might not be so bad. All my inputs are custom handlers that only ever used unity's input from a single class, so i probably only have to update in that one place
You definitely only need to update that one file then yes.
How do I detect when the player moves his mouse while holding right click?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
//--Writing space--//
public class CameraRotation : MonoBehaviour
{
//--Public Variables--//
public GameObject Player;
public InputActionAsset PlayerInput;
[Space]
public float ZoomMax = 10;
//--Private Variables--//
private float ZoomMin = 0;
private void OnEnable()
{
PlayerInput.Enable();
}
private void OnDisable()
{
PlayerInput.Disable();
}
//I want to detect the inputs when they are pressed
}```
I dont know how to detect inputs
Do I also add a right button + dragging combination sort of thing?
I followed this tutorial https://youtu.be/cSkOx35Khlw?si=uMFNId1C7ip_Q9Rj
How do you check if the button is pressed in Unity, if your project uses New Input System?
That's very simple! First of all, the New Input System doesn't have the same if statement to detect if a button is pressed, as it was the case with the old input system. Instead, you should add an input actions asset and make a set of actions that can be ...
And I got this error ```Cannot declare a variable of static type "InputSystem"
And I dont know what it means
And how am I supposed to connect this #🖱️┃input-system message to the script?
I watched that tutorial 5 times
I am not able to comprehend why that error keeps happening and how would the script work without a reference to my InputThingy
I'm really trying hard to like the new input system but its very hard to adjust to it. I've created a separate Dash action with Multi-Tap interactions and linked it to a dash method without movement script. Added a basic Debug.Log("Dash input received");, but for some reason it gets triggered twice every time. Any ideas anyone, what am I doing wrong here?
not checking the phase
check the phase too
hmm, actually not sure that's it, but you should still do it
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.17/manual/Interactions.html#predefined-interactions
yeah you definitely need to be checking the phase
Just got back, I've had a skim on the docs nothing said about the phase. Any recommendations on how thats done?
Right I see what happened here. When you said check the phase I was slightly confused but I was doing that all along with everything else aka context.perfomed in an if statement. I only call it once now. Honestly didnt think that would be such a huge thing about phases but here we are.
Thanks
im using this configuration for an orbital camera which only moves if i click and drag the screen, but i want the camera to permanently move with the mouse, i was told to rebind to mouse delta but that doesent seem to work or register
on top of that unity doesent seem to recieve my mouse inputs
Whats with the input manager error, how do i get rid of it. Using 6.3
It just means you're using the old input system which if you go Window>project manager (or whatever it's called)> player. You should be able to find it
yeah no success thats why im asking about it
ive checked at two different areas that it should have been
I promise it's somewhere in there i just did that last night
But I'm not home so I can't help find it
ive installed the updated Input system and still have the error
you can ignore that warning if you intend to use input manager/Input
it's not an error
what if i dont wanna use input manager?
then don't, and use input system instead, and configure your project to use input system
!input
How to Set Input
To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling
• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.
input manager is fine to use btw - it's the old system, it still works
input system is the newer system, it's more flexible but also somewhat more complex
i'd recommend the new input system, but more of a "learn this eventually"
ok
I like the old one better tbh
I don't mess with the new one 🤣 and it'll probably stay that way until it makes more sense to change over
what the equivalent of Input.GetKeyDown(Keycode) and Input.GetKey(Keycode) in the new input system?
suppose i want getkeydown for attack input
the direct equivalents would be Keyboard.[key]Key .wasPressedThisFrame/.isPressed, respectively, but there are other options depending on how you're receiving input in general
for events, you'd generally keep a state, and modify it according to performed and canceled events, or from those fields in a CallbackContext, or from isPressed in an InputValue
i cant get it through a input action variable?
i thought i was replying to you. didnt check.
did you try reading the docs? they show what props and methods are available
in this case they're methods named similarly to the props on the InputControls i mentioned above
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.17/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_IsPressed
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.17/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_WasPressedThisFrame
with inputsystem, you gotta say what you're coming with
there's a lot of ways to do any given thing, to list them all would be a ton of work lol
opening unity and chrome together crashes both of them. spotify and discord work fine though
well, that's terrifying
It may not be common issue at all, i don't have any Unity crashes and Chrome is my main browser. You might search the web
are you on linux
no i am on windows
has it always done that?
is 16 gb ram enough to use chrome and hdrp projects+visual studio at same time
idk i havent used hdrp before this project.
has it been consistent with this project?
and does it happen with other browsers? you're definitely going to have to research stuff online eventually
yes almost either unity crashes or the web page gives a error
with the error being about memory?
Try chrome without hardware acceleration? (Probably VRAM issues)
ahh this is way off topic of the channel lol, you should probably ask about this in #💻┃unity-talk
i assumed its because of ram filling up cause both chrome and unity use lot of ram
I know this isn’t insanely relevant, but I find it really funny that there is a whole channel just for the input system
well, it is quite extensive
Can input system be set to receive keyboard and mouse inputs when the application is minimized?
I think "ignore focus" with run in background would to do it, but doesn't seem to with mkb
Confirmed it works with gamepads, the application can get their input even when fully in the background
how do i fix this error?
What error?
It seems self explanatory, no?
Either do what it says or switch to an asset that isn't the project wide asset
Or remove this asset as the project wide one
oky
so i decied to learn from the youtube video https://www.youtube.com/watch?v=Cd2Erk_bsRY&t=40s where do i find the animator thing?
This is the second video in the Input System series, where we dive into scripting with the Input System to control a third-person character.
You'll learn how to write code to move and jump the third-person character using an Input System Asset, with support for both gamepad and mouse-and-keyboard inputs.
We’ll also add a simple pause menu to...
wdym by "the animator thing"?
The video shows there’s animator tab but I don’t see it
menu bar > window > animation > animator
Thanks I’ll take care
Hello everyone! I don't know where to include this but I'm trying to make a simple game in Unity, but for mobile. I have used the new Input System and through the PC, I bind the joystick and some buttons from a VR controller that are dedicated for mobile. It works fine on PC, but when building the APK, the controller doesn't want to work.
This is how I get the input. private void Awake()
controls = new PlayerControls();
controls.Gameplay.Move.performed += ctx => moveInput = ctx.ReadValue<Vector2>();
controls.Gameplay.Move.canceled += _ => moveInput = Vector2.zero;
controls.Gameplay.Select.performed += ctx =>
{
debugText.text = "Trigger Pressed!";
Debug.Log("Trigger Pressed!");
};
controls.Gameplay.Select.canceled += ctx =>
{
debugText.text = "Trigger Released!";
Debug.Log("Trigger Released!");
};
}```
Nvm. I used the old input system and worked fine. The new input system is bugged for what I want to do.
public void OnShoot(InputAction.CallbackContext val)
{
if (val.performed)
{
Debug.Log("idk");
}
}
The could should print idk when i hold the shoot and stops when i stop holding
if you want to do something every frame you need to use Update.
Why does the input actions settings tab do this?
when clicking on the Path field for the first time, I'm suddenly instantly redirected to the first item of the first tab (Player/Move)
probably because you need to name it first so it can exist in the json data that this UI is a viewer for. When you assign the binding, the UI tries to set a binding for a non-existing field, so it falls back to some sort of default state.
Hey I could use some help, in my game I have splitscreen with the input system but when I have 2 players the UI doesn't shrink down to show everything so the score at top right corner and the ability icons in the left corner can't be seen. How could I make it work?
Looks like a #📲┃ui-ux question
ahh okay thank you
Genuinely how do you remove a binding from the new input manager?
you mean in an input actions asset? you select it and delete it?
delete == press the delete button on your keyboard
Hello everyone. I'm learning how to do AR right now. The tutorial I am following, for setup, says to set "Active Input Handling" to "Both" within Player settings because it avoids error messages from plugins/assets. Can I get peoples opinion on this? I was thinking, not to do it, and wait and see if any errors appear/deal with them at that time. Is there a downside to using both?
There's a slight performance penalty but probably not a huge deal
!Turtorial
<:error:1413114584763596884> Command not found
There's no command called
turtorial.
!tutorial
<:error:1413114584763596884> Command not found
There's no command called
tutorial.
hello, I'm starting a new project. is this InputSystem_Actions file part of the new input system?
I heard about the new vs. old input system but I'm not sure which one is which
Yes
thanks
I'm brand new to DOTS so I'm also a bit confused on how this system integrates with that
specifically because DOTS wants to work with unmanaged types
is there a place I can learn more about that integration process?
Im trying to add my input reference actions from the unity input system onto a scriptable object this used to work a few months ago but now it doesnt work it just says none even tho its showing the inputs and letting me drag them in and my old inputs arent gone but if i try to change their input action it doesnt let me
using UnityEngine;
using UnityEngine.InputSystem;
[System.Serializable]
public struct InputEntry
{
public string Name;
public InputActionReference Action;
}
[CreateAssetMenu(menuName = "Scriptable Objects/Input Data")]
public class InputData : ScriptableObject
{
public InputEntry[] Inputs;
public InputEntry Get(string Name)
{
for (int i = 0; i < Inputs.Length; i++)
if (Inputs[i].Name == Name)
return Inputs[i];
Debug.LogWarning($"[InputData] No entry for '{Name}'");
return default;
}
}
my simulated touch not working in the device simulator. ( specifically its not registering hold and drag ). I have enabled simulated touch in input debugger. i am using the new input system (1 press[touchscreen] 1 position[touchscreen])
Is there a way to check what the most recently used input device was?
Trying to change some UI to match the icons on the most recently used device, but I can't seem to find an option to do that, outside of making an instance of PlayerInput just for that.
Is there a more elegant solution I am missing?
PlayerInput has the most robust implementation that is easily available (and its the one of the few things that PlayerInput is good for 😄)
After posting that I talked with one friend who worked on a game that just shipped (Pathologic 3), he said they arrived at the same conclusion as you, so went with that solution.
tell your friend: "nice game!"
Will do!
most coherent game design ever.
And thank you for taking your time to help me
I still gotta play the previous two lol
Will do!
Checked with some other friends who played it already and they seem to be annoyed by that too lol
Howdy, what troubles you?
hi. can someone help me with input for an rts? i want to move around with wasd, but also type into input fields. is there a sane way to handle that? not sure why the ui doesn't just automatically eat inputs and block trickling them down.
public void OnNavigate(InputValue value)
{
if (_eventSystem.currentSelectedGameObject == null)
{
_cameraMoveDirection = value.Get<Vector2>();
}
}
maybe like this?
Why does when I try to edit inputsystems actions, unity just keeps trying to compile it (and failing, I think? Since it's been trying to do it for quite a long time)?
Uh guys
So apparently i was using getaxisraw for 3d movement in previous version
And now in unity 6 i found out it didnt work anymore
I did switch input to both but the problem wasnt solved
So how do i use the new input system
it should work still, or you might have to use Old if you're building for platforms that don't support Both
if you do want to switch over to the new system, there should be plenty of tutorials
Okay tks
hello, can anyone explain to me why my code isn't working as intended?
xRotation -= mouseY * mouseSensitivity;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
cam.transform.localRotation = quaternion.Euler(xRotation, 0f, 0f);```
the problem I have is that I can make about 20 full 360 rotations on the x rotation before the clamping sets in, I've looked at what went on with the variable values and found that when the actual rotation is at 90/-90 the xRotation variable is only at 1/-1
what's quaternion there?
that's not a UnityEngine thing
are you perhaps using one from Unity.Mathematics
that line is something I got from a tutorial from brackeys
from what I understood it should give the rotation, found some more about it also on docs.unity, but nothing adresses this specific problem
quaternion.Euler is in radians
Quaternion.Euler is in degrees
you did not accurately follow the tutorial
hover over quaternion and see what it says, it'll probably be Unity.Mathematics.quaternion
hi, i have to use my side mouse buttons on old input system, can anyone help
for an additional mouse button, unity has Mouse 0,1,2 for left, right, middle buttons, and then Mouse 3, 4, 5 for additional mouse buttons
you can do if(GetKeyDown(Keycode.Mouse(your selected number))) to check for it being clciked
I have this mouse and that's not a real mouse button
That button toggles between three different computer/bluetooth connections for the mouse
It doesn't actually send any input to the computer
i mean forward and back button don't work in unity not the third one
You have them bound to "forward and back" instead of regular mouse buttons
aren't those regular mouse buttons
(not unity resource, but afaik should apply the same?) https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value
inputsystem docs also mention them, but not input manager
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Mouse.html#controls
our project is using old input system :/
this isn't specific to the input system, it's just how mouse input is treated afaik. i'm just mentioning that inputsystem explicitly calls that out
I tried GetMouseButton(3, 4, and 5), but none of them work for me. Do you think this can be solved by changing mouse/driver settings, or is there something else I should check?
i'm not sure
i don't have the special mouse app thing, and getting buttons 4/5 (index 3/4) work fine for me
so maybe it's your mouse settings, making them send different events?
I am developing a tool for my company, and at least 50 people will be using it. Therefore, I can’t ask everyone to change their mouse settings :/
in your case specifically, my best guess is that your mouse settings mean your side buttons are acting as macros, not actual side buttons. you could probably confirm or deny that by checking browser events maybe?
When i click forward or back mouse button on browser it works I can go to previous page
right, but it could be other events that input manager isn't picking up. i'm not sure what they'd be though...
maybe try checking with the input system debugger to see if events are firing?
control schemes are kinda exclusive with each other, if you want to use the mouse and keyboard together then they'd have to be in the same control scheme
though, you could also just not deal with control schemes in general
theyre currently on the same control scheme but the mouse just doesnt work
have you tried the input debugger to make sure your input is going through to the input system?
idk how...
there's a button at the bottom of your player input that says input debugger
ye but how do i see if things are being read, i opened it and played the game but it didnt do anything, however, the keyboard input that do work didnt make any visual change either. i did see that my mouse was under unsupported devices but so was my keyboard and that works fine
double click a device and see if the events are registering as they should
debuggers don't fix things
they give more info so you can fix them
it is registering the event, when i click the event id goes up
How hard is switching from the old input system to the new one?
depends on how familiar you are with the new one, and depends on how much you're using input
I followed a tutorial for movement and it used the old one, I know nothing abt the new one
for some things in the old input system, you could just do a find & replace and it'd be pretty easy (though, that's not really the intended usage of the input system)
you will need to learn and get comfortable with the new system. Once you have done so, transitioning is not hard.
Obviously if you have no idea how the new system works it won't be easy
How fun...
i mean, that's kinda.. everything
Like "how hard is it to make a clay bowl". Well it depends on how good you are at pottery
I meant like will I have to rewrite half the code or is it just changing a few lines
you will have to rewrite the code that handles reading input
i don't know how many lines of code that is in your project
which might be a lot or a little, depending on your target. there's a lot of ways to use the input system
Like 40, im new to unity
then you will have to rewrite about 40 lines of code
I just have movement and rotation so far
not the movement code. Just the input reading code
input system usage options:
InputActionReferenceas a serialized field, poll thatInputActionReferenceas a serialized field, subscribe to thatPlayerInputcomponent with messagesPlayerInputcomponent withUnityEventsPlayerInputcomponent with C# Events (not sure what that entails)- Generated class, poll that
- Generated class, subscribe to that
- Get hardware
InputControl, poll that
i don't necessarily recommend any specific one, and i haven't included options that involve magic strings
I'm trying to place my Actions Keybind for my InputAction Map and I have really problems with my Steam Deck. Its super weird, touch screen != Touchscreen and the Gamepad South button is Spacebar?
I am trying now since 2 days to make my submit button and touchscreen work and the submit button was working if I say its a Keyboard Spacebar. but Touch still doesn't work, I heard that it is managed like a mouse input but saying its a mouse still doesn't make it work. I can use a mouse with the right Dragpad and click my Unity UI buttons with that but I want to click it with either Submit and by pressing your finger on the button on the Steam Deck Touchscreen.
would it be possible to hook up your steam deck to the input system debugger somehow? that could probably help get a better picture
I make a change, compile for Linux and upload it to Steam and turn it live the receive the Update on my Deck.
it also seems that inputsystem doesn't specifically support the steam deck, so maybe there's just some disconnect there
I use Unity 6000.3.4 by the way.
i don't think that should matter too much - the input system package version might though
but the multi touch support for linux I guess? even if I dont need 2 fingers at once but it was part of those reddit posts so I guess its worth to mention.
also perhaps check if there are any packages for steam deck support
I guess Steam Deck is just Linux PC as build if you dont want to need Proton and I just saw the last post from your reddit link and I I took a look in my own Steamworks page instead of Unity. I was not even thinging about that also can play a impact. now I have set it to this. (Do I need "Generic (Direct Input)? My game will be for PC, Steam Deck and (maybe for Android) so I keep in mind that I am trying to maybe make the Steam Deck use the same kind of Touch screen logic like Android? thats why I selected "Direkter Zugriff auf die Touch-API"
i'm not familiar with this at all, i have absolutely no clue what any of that is lmao
i guess 
right now my game is on steam but not realesed and I am uploading my unity made build with a SteamSDK Tool to Steamworks and press make it live. Just with your reddit link I also noticed that Steamworks also have some settings that can have a impact of how the InputSystem will behave to the hardware of the Steam User.
what is the best way to fix my character not moving when I am holding both left and right with a keyboard? using a vector2 for movement
What would you like the behavior to be instead?
for example if I am holding D (right) and then start holding A (left) it would go left, and vice versa
I found an answer on the forums, but I have no idea how this would work for a vector 2
https://discussions.unity.com/t/character-not-moving-when-move-left-and-right-keys-pressed-simultaneously/1691241/10
Basically you wouldn't keep it as a composite like this
You would need to break it up into separate actions for each direction, and then you would write the logic yourself for the deconfliction
There is no support for "last key wins" for axes and composites by default
thanks, I could solved it because of that steamworks information from your reddit link.
In the end it was nothing unity realated.
I just had to enable "Generisches Gamepad" and "Emulation linker Mausklick" inside of Steamworks.
old input system doesn't have this feature
right, i'm referring to the new input system. see if that's picking up your mouse input, to narrow down whether the issue is with the input manager's handling, or with how the mouse is giving events
you could also try a mouse testing site to see if the buttons are picked up as mouse buttons (as opposed to being keyboard macros or something)
It's recognising the input but not running the code. Is there a change I have to make in the code if its a mouse based action instead of a keyboard based action?
no, there might be some difference in how you'd handle button types vs value types in general but that doesn't sound like the difference you have
have you tried an unconditional log in the receiver, above/outside any flow control?
Idk this vocab sorry, do you mean a debug line of code in my script to see if it's running?
sure, that'd work
But what do I do if the code is running but not working or it isn't running even though the action think is registering the input
Thank you Mr Pekora
I hope that what I'm about to ask makes sense, but I'm trying to build a system that takes in an input action reference. Is there a way to get the returned type from an input action?
Im trying to avoid hardcoding my entire input system but I think I might have to, since it doesn't seem like there's a way to get the type unless its at runtime, when the event is triggered
wdym by "the returned type from an input action"?
it doesn't really matter anymore, i've moved on from that
I have the new issue of performed and cancelled callbacks seemingly not working
i've confirmed that the method that subscribes stuff to the delegates is called
but the delegates aren't being raised
yeah the delegates just straight up aren't doing anything
do I have to do anything more with an input action asset than call Enable on it?
Show how you set everything up
it is now fixed, but i literally just did the += thing on the performed and cancelled events
and had actions.enable() after
I regenerates project files and it works
regenerating project files just makes sure your code editor is working right
If you have Domain Reload upon entering playmode disabled, you could have behaviors that depend on whether or not you just recompiled
I’m currently having an issue with the jump function in my game. When I inputted the system and got the jump key, I had tried to change the controller input on the quest 3 controllers to the left stick button for jump (because that was something used in a reference game) but that didn’t function no matter how I fixed it. Somewhere in the chaos, I accidentally deleted the function state of jump off of my right controller. I am now realizing that I need the jump mechanic on the right controller, so I copied the function off of the left controller and tried to do the input as secondary, aka the top most button of the controller, but nothing seems to work. What should I do to either remake the jump button, re install the jump button, or get some sort of alternative?
Any help would be appreciated in this area 😭
You'd need to share details of how you have your code and components set up
Okay, would it be fine if I like dmd them to you later? I’m also not sure how much that would matter as this is based f of the XRI input system and nothing that I specifically coded, and also for the fact that the code to the jump function doesn’t currently exist which is the whole problem
See I don't even know what you mean by "jump function", so it's hard to understand what you're saying
If you could use the terminology of the input system that would help
and no, don't DM them to me
you can post them in the channel or make a thread
Okay, when I’m off work I’ll do just that. Thank you!
This is what im looking at. I copied over the jump from right to left and tried using the xr controllers to set up the secondary button but to no avail\
You're saying you had trouble assigning the binding, or something else?
also it would help if you actually selected the Jump actions so we can see their configuration
Both that and the fact that the effect isn't apparent by how i had it done earlier, i literally just binded the jump button first thing and i could immediately start jumping, but then i messed with what button was binded and it all went to the ducks
one moment i may have found a solution (idk how i didnt find this before)
I have a problem with the On-Screen Buttons, they only respond to the arrow keys, but not to the space or the WASD. The regular bindings still work with the keyboard
can you show how you actually hooked the actions up to your code