#🖱️┃input-system
1 messages · Page 9 of 1
Smart. Thanks again
Just dived into the InputSystem code, found the file the handles generating the C# script files.
Right at the top of the file is:
////TODO: option to allow referencing the original asset rather than embedding it
This is exactly what I need! Anyone know when this is going to be implemented?
This would be the code for it,:
// Original Asset Constructor
writer.WriteLine($"public @{options.className}(InputActionAsset referenceAsset)");
writer.BeginBlock();
writer.WriteLine($"asset = referenceAsset;");
foreach (var map in maps)
{
var mapName = CSharpCodeHelpers.MakeIdentifier(map.name);
writer.WriteLine($"// {map.name}");
writer.WriteLine($"m_{mapName} = asset.FindActionMap(\"{map.name}\", throwIfNotFound: true);");
foreach (var action in map.actions)
{
var actionName = CSharpCodeHelpers.MakeIdentifier(action.name);
writer.WriteLine($"m_{mapName}_{actionName} = m_{mapName}.FindAction(\"{action.name}\", throwIfNotFound: true);");
}
}
writer.EndBlock();
writer.WriteLine();
I cant inject it myself and if I modify the asset in the Library folder the package manager notices the discrepancy and restores the original.
Hmmmm
Have a question about mobile inputs for a rhythm game. I have a few fixed position, which is a game object that reads input, but touch positions are counted in pixels and game objects are counted in units, how do i convert it?
What are you trying to accomplish
@thick bay I found the problem
Idk why but like I thought, didn't it react to the y-axis. I changed the y-axis to the one beneth it (3rd axis)
Now it works, but reversed, so when I move down, I go up, if I move up with the joystick, I move down
3rd axis? that's odd-well glad ya got it going. Click the invert checkbox to switch up<->down
ah yes with the invert enables, does it works perfectly
never thought it would come out
I was wondering if there's a sort of customable mouse. I'm letting my character move towards my mouse's position, but on ps4, there is no mouse, so maybe I could create a "custom" mouse that could be moved with the right stick?
as long as you configure and get the vaules the same way you do the axis, and access the input values via their "input name" (as opposed to using say... Input.mousePostion), yes that should be doable.
Found a video that'll explain. Hope's it works, so I can play it with my controller.https://www.youtube.com/watch?v=Y3WNwl1ObC8
Make a custom gamepad cursor using Unity's New Input System. This way you can navigate UI using a controller similar to a mouse.
📥 Get the Source Code 📥
https://www.patreon.com/posts/57282387
🤝 Support Me 🤝
Patreon: https://www.patreon.com/samyg
Donate: https://ko-fi.com/samyam
Thanks GeekZebra for helping make this video possible!
*Sorry for...
^ watch out ... this video is using the new InputSystem. so far, you are not. @versed venture
yeah, I'm using the old one currently for ingame and the new one for menu. Very strange, but I'll change it later
That actually works?! I thought I got a message saying the old one won't work when I installed the new InputSystem package. perhaps I misread.
You have to select "both" in the project settings at Input settings using.
it detects both.
deam. I think i typed smt wrong and got like 5 errors from the vid
I was wondering if someone can help me with my movement controls. it's set to just tap, and i want to hold w to move and a and d to rotate using a playership
Which part do you need help with ?
Yeah it does work. It’s a good way to do a transition between old and new input system.
For big existing project it can be useful
https://codeshare.io/lorqrm i want to make my character move when i hold w and not just press w using unitys input system, their new one
ty for the respond back @trim hollow
Hi folks! Trying to understanding why my OnUpdate callback (implemented with IInputUpdateCallbackReceiver) is working in one script and not another. Working script is a custom input device derived from InputControl, non-working case is a MonoBehaviour. No errors in either script, but my Debug.Log statement in the MonoBehaviour's OnUpdate doesn't fire at all, whereas the OnUpdate on the input device class fires as expected. Everything else is working just fine in my MonoBehaviour (i.e. Update, Start, custom methods). Any idea what could be causing this issue?
I'm trying to make an input system for a rhythm game, I'm currently using a raycast to detect inputs
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
RaycastHit hit;
if(Physics.Raycast(ray, out hit))
{
if(hit.collider != null)
{
Color newColor = new Color(255,0,0,0);
hit.collider.GetComponent<MeshRenderer>().material.color = newColor;
}
}
}
The thing that i am curious is, even I only attach this script in one game object, the other game object will still affected by the touch
How can I get a correct value from parameter of function SendValueToControl?
I want to read a non-normalize Vector2 in CallbackContext
I use CallbackContext.ReadValue<Vector2> but I just receive normalized vector2
Why wouldn't it be? You're not checking what your raycast hit at all. Just if the raycast hit anything.
Why not just use IPointerDownHandler?
as long as you set up the input action and binding normally you won't get normalized data from the CallbackContext
Can you guide me how to do that?
just set up the action as Value/Vector2 and don't add any other stuff to it (processors, interactions, etc)
I didn't add anything like this but I still received normalized vector2
what kind of input devicce are you using
^
I use Desktop and Phone
Input device
not the computer
I'm asking if you're using a keyboard
joystick
or what
Joystick
ok and how are you seeing that your input data is normalized?
Can you show the code where you read the input data
and how you are checking if it's normalized
The parameter value has magnitude more than 1
This is how to I receive value callback
Well first off I don't really understand what you're doing here but it seems to have little to do with the input system itself.
Second, you're manually normalizing that vector yourself right on the last line
Debug.Log here. This data will not be normalized
also it seems completely unrelated to the above screenshot
so I'm not sure what the connection is
Ok, wait
I Debug.Log when I send the value to control and then I received it. And this is result
what is SendValueToControl doing
I just follow the function in On-ScreenControl script
what do you have for this
[InputControl(layout = "Button")]
[SerializeField]
private string m_ControlPath;```
and what is it set to in the inspector
and what does the given binding in your action look like in the input action asset
I dont understand what do you mean
which part
you said you copied the custom onscreen control script, right? Share all your code for that.
And show what you have set in the inspector for the control path
and show how the binding for that control path was set up here
First, this is control path of my joystick
I did want to use the joystick script of Input system, so I add this by myself
yes
@austere grotto Are you being here?
hi, for some reason when i change the character on my game the input system detects i'm on a gamepad even tho i'm not
does anyone know what may be the reason ?
default scheme set to keyboard/mouse
even without a controller plugged in it gives me this problem
the playerinput from the character that works
the playerinput from the character that doesn't
for some reason it's not recognizing the keyboard/mouse... wtf ?
New to input system but I've looked everywhere on google but I don't think I've found anything that can apply to me.
essentially I want to use one gameobject to instantiate another gameobject with the same device.
I have a PlayerInputManager create "Object A" when a player joins
I want Object A to create another object "Object B" on a seperate trigger,
I want Object B to have use the same device that Object A uses
What exactly are you struggling with? The instantiation or just the input? Basically you can hold a reference to object B from object A and call your stuff from object A with the correct input to trigger a function on B. Or just hook object Bs functinos into your performed event or whatever you need there
My issue is i dont know how to connect Object B's input device to be Object A's input device
Object A is a used as a character selection object, and Object B is the actual character played
Ah, so they actually do not exist at the same time. You can still have a Player Class that is held active just as a class above the visual representation. So you just spawn your objects with a reference to your player class that is holding the input
It does not matter
You question was about how to get the input device to another script. Or are you asking, how to get different inputs to a specific player?
yea I wanna get the input device to another script
Let me lay it out for you
When the scene runs it pulls up a character selection window
When a player touches any button on their device(Gamepad/Keyboard) it will spawn in a "Cursor" Object
When the player selects a character the Cursor object will run a method that spawns the actual character in,
the problem I have is I don't know how to assign the same device to the character.```
Do you have the function already to trigger something, when a device is being detected (by button push)
What does that functino look like
{
skinIndex = rows[rIndex, cIndex].index;
print(skinIndex);
PlayerInput p = PlayerInput.Instantiate(manager.playerPrefab, playerIndex: input.playerIndex);
}```
I was playing with the playerinput instantiation
skinIndex, is that relevant to the input or just part of your code?
so charSelect is triggered by what?
I would love to see the code for "When player touches any button [...]"
the "when player touches any button" was automatically created with the PlayerInputManager component.
Ohhh, that class again. yeah I never worked with it, but I am sure, it has some function to hook into. Is there any docs about it?
If I get this correct, you should be able to get the player input with this event and others among the manager: https://docs.unity3d.com/Packages/com.unity.inputsystem@0.2/api/UnityEngine.InputSystem.Plugins.PlayerInput.PlayerInputManager.PlayerJoinedEvent.html
do you know how to get the device a player input is using?
looking at the debugs and thats all i need now, got it to instantiate with the control scheme and playerIndex, just need to get device
Did you read the docs? This event will callback a playerinput, which is this: https://docs.unity3d.com/Packages/com.unity.inputsystem@0.2/api/UnityEngine.InputSystem.Plugins.PlayerInput.html
Yea I think i got it
Yea i went exploring manually in the playerinputmanager class and i got it
thanks man
Cool, hope you get along with those events, tell me, if it worked 🙂 Wanted to test out local multiplayer myself soon or later
ye
Hiya! I'm having this really, really, really weird issue, where you can't use the wasd keys and the mouse at the same time, but you can use the arrow keys and the mouse at the same time. The "nipple" mouse on lenovo thinkpads also works while using wasd aswell as arrow keys. If it matter,s when I refer to mouse I mean touchpad as I'm programming on a laptop, and haven't tested it with an actual mouse yet. It occurs on windows, linux and webgl builds. Anyone have any idea what could cause this?
That sounds weird, yes. Did yout ry update your drivers first? And maybe name the model you are using, like what laptop
Sorry for late response, I'm at school right now. I have not tried updating drivers, but they should be fairly recent. I do not believe that to be the issue though, as it occurs on multiple chromebooks playing the webgl version aswell. I am using a Lenovo Thinkpad T430S. The chromebooks are school issued so I don't know their make/model.
Oh alright, so trackpad disables WASD, are you sure do did not setup something weird in the input settings?
I am completely sure. The code I am using to get inputs is
Input.GetAxis("Axis)
I have not messed with anything other than that
Ohh, well, GetAxis needs to be setup somewhere in your Input settings. If you setup your axis (or unity things) would be the mouse /trackpad position AND WASD, it will disable the other or override it maybe.
Ah, ty! So where can I change that?
I am not using the old system anymore, but I think its in player settings => Input something
Input manager?
Maybe 😄 cant check it here
Ah, I think I found the issue. The Horizontal and Vertical axes are setup as type "Key or mouse button". But there is no key only option?
If I may suggest, you might wanna look into the new input system, if you are not in a hurry with that project
Ah, I'll look into that then. I'm not in a hurry no, its a school project that I got 2 months for.
If you want to conitnue to learn unity after that too, you might wanna jump on the new input system for sure. The old is quite weirdly to be handled
I made portals so when the player collide with the 1st he transport to the 2nd
I made dissolve shader starts when the player collides
(I’m using the new input system)
when I put the player besides the portal then start the game.. press D to move and collide with the portal .. the dissolve does not happen
But when I put the player above the portal and start the game he falls by gravity on portal and the dissolve is running ok
I disabled the new input system and used the old one
everything worked!
can anyone tell me why this is happening?
Have this really weird issue with my inputs. For some reason I can get Vector2 inputs from my wireless switch controller and mouse, but I can't get button inputs from the controller or my keyboard.
never mind
I'm dumb as hell
the triggered functions for those actions aren't capitalized

you'd think after 8 years of experience programming in university and work you'd be immune to these kinds of mistakes
Must have been doing Java for some of that time
Are the PlayerInput components really necessary for local multiplayer?
Is there no alternative for this?
not necessary, simply the easiest way by far
you can certainly do all of your own input device mapping to actions yourself, but it'd be annoying
Hiya! Theres a LOT about this new input system that wasn't covered by the quick guide. For example, when I've created a mouse action as a vector2 value, how do I store that as a variable in my script? Do I need to reference the input manager?
Covered in pinned tutorials:
https://learn.unity.com/project/using-the-input-system-in-unity
ah, ty!
How can I get correct value of parameter of function SendValueToControl?
hi there
quick question, how do you guys structure your action maps?
or are there some articles that give some tips to that?
Hello !
Do you guys know the path for PlayStation and Switch controllers ?
I know that for Xbox it's /XInputControllerWindows but I can't find the others :/
Per "gameplay" styles and UI, I'd say
If you have a menu, a fighting gameplay and a boat navigation gameplay, you'll have 3 action maps ; they won't override each others
whats the right way to link ui buttons to the input system for mobile controls, i saw tutorials online and they usually put a on-screen button script and link a gamepad to it, but isnt the gamepad for controllers?
How to get touch id from IPointerDownHandler ? In standalone event.pointerId is actually left, right, center mouse click
Is migration from local multiplier to online problematic with input system? Or does it require little adjustment?
that question has very little to do with the input system and a lot to do with your multiplayer framework
The case where the input system would differ a lot is if it's a couch co-op local MP game, then switching to online. Still, it mostly has to do with how your MP framework handles multiple players
The on screen joystick doesn't appear to work in my project. I can move it but no input is being received by the PlayerInput component, any idea what could cause this?
it works fine if i remove the PlayerInput component tho
What's the best way of replicating the GetButtonDown/GetButton/GetButtonUp workflow in the new input system? I'm trying to get separate actions to fire on click (function call to queue an item), hold (set bool holding to isPressed), and release (function call to release item).
Am I on the right track in using a Pass-Through action for this?
no don't use pass through
for the moment, assuming you have a Button action, you can get the same exact behavior like this:
InputAction myAction;
void Update() {
if (myAction.WasPressedThisFrame()) {
// this is like GetButtonDown
}
if (myAction.IsPressed()) {
// this is like GetButton
}
if (myAction.WasReleasedThisFrame()) {
// this is like GetButtonUp
}
}```
this is with a basic "Button" action
Ah, I see. Is there a way to leverage events such that instead of checking for WasPressed/Released on each update you can set up something that is essentially like "do x when the button is pressed or released"?
ah yeah you said you wanted the same workflow so I assumed Update polling
you can do it with events, yes. It depends on which event we're talking about. Are you manually subscribing to events, or using something like PlayerInput UnityEvents?
I currently just started working off the Starter Asset examples.
I don't know how thaose work. Is it using the PLayerInput component?
Yes, it is. Kinda hard to explain but there's also a iseparate, state manager-esque script that just sets and unsets bools.
Using onX.
I'm not sure if it really fits in my use case since I need to trigger stuff on press and release instead of just setting bools.
Assuming it's using PlayerInput you can set up a function and do this:
bool isPressed = false;
public void OnGrab(InputAction.CallbackContext ctx) {
if (ctx.performed) {
// this is like GetButtonDown
isPressed = true;
}
else if (ctx.canceled) {
// this is like GetButtonUp
isPressed = false;
}
}
void Update() {
if (isPressed) {
// this is like GetButton()
}
}```
if they're using the version that looks like this:
void OnGrab(InputValue val) {
}``` it's a little tricker and I recommend switching the PlayerInput component from SendMessages mode to UNityEvents mode
It's definitely the second version.
I'd recommend switching but it's definitely possible in that version
you'd have to do something like this:
bool isPressed = false;
void OnGrab(InputValue val) {
bool newValue = val.isPressed;
if (newValue != isPressed) {
if (newValue) {
// this is like GetButtonDown here
}
else {
// this is like GetButtonUp here
}
}
isPressed = newValue;
}
void Update() {
if (isPressed) // this is like GetButton here
}```
Gotcha, that makes sense. Part of the issue is that Starter Assets separate the PlayerController from the script that handles "OnGrab".
so in the nested if else I'd need to call something in the separate Controller script, which feels kinda gross.
Alright, I'll give that a go, thanks for the help.
guys how do i make shortcut keys?
for what
i was wondering if anyone can help me with using the new input so I can hold W to move, it's only set to tap and it's kind of a braintwister.
please
i will literally pay you to sit down and help me with this. im pulling out my hair smh lmao, i've looked over so much yt and google tutorials
XD NVM
fucking finally got it. just had to turn on my fucking brain
but i love it tho ;')
So I went ahead and converted from SendMessages mode to UnityEvents, and the ability to consume an InputAction.CallbackContext over an InputValue is definitely more expressive for my use case. That said, are there any differences between subscribing via lambda like:
_playerInput.actions["Grab"].started += _ => Something();
_playerInput.actions["Grab"].performed += _ => SomethingElse();
_playerInput.actions["Grab"].canceled += _ => AnotherThing();
and handling the logic within OnGrab? Are they functionally identical?
public void OnRotate() //Action Command Rotate whenever i press A or D.
{
transform.Rotate(0,0, rotationSpeed * Time.deltaTime);
}
does anyone know how to make it so it rotates to left and rotate using the new action input
sorry for my late
its for my game i want to use shortcut keys for easier to press
like ctrl rmouse
Sounds like just a secondary binding?
Bumping this—are there any performance or non-syntax/structural differences between subscribing via lambda and using OnAction handlers?
How can I convert 2 axis as different values into 1 vector2 input?
You won't be able to unsubscribe properly if you use lambdas
Adding to what PraetorBlue said, _ => Something() isn't stored anywhere, so writing an equivalent -= would be impossible. You could unsubscribe by nulling out the event like _playerInput.actions["Grab"].started = null, but that's getting messy and might cause some problem I can't think of.
Something like new Vector2(axis1.ReadValue<float>(), axis2.ReadValue<float>()), if I understand your question.
Is there a way to emulate the old "OnKeyDown" with a PlayerInput component on the new system?
"Press" require releasing the key, "Tap" for some reason re-fire the event if held too long, etc.
You need to check if the context is performed
You don't need any interaction
I see, does this make it a no go in general for input, or are there relevant use cases? Could one += a named function directly to store a non-anonymous reference to unsubscribe from?
yes you can do that, and I'd say that's the recommended approach
And one could use that in place of OnAction handlers with no major difference in functionality and performance? Is it good practice to use both or one or the other?
I think generally if you're using the PlayerInput component you should be using one of its tools:
- UnityEvents
- SendMessages
If you're not using one of these then you might want to explore dopping the PlayerInput component entirely. The only exception to that might be if you are doing local couch multiplayer so want to take advantage of PlayerInputManager but also really want to use the manual event subscription style
otherwise there are cleaner approaches than reaching into _playerInput.actions such as InputActionReference, a direct InputActionAsset reference, or use of the generated C# code class.
Alright that makes sense, no point in player input sending messages or invoking events if you're hooking directly into actions.
@austere grotto
I can get it to work via script, yeah.
What I'm wondering is if you can do it via the PlayerInput component, or if I shouldn't bother with it outside of prototyping.
The PlayerInput component must be combined with a script
in the script you can check which phase of the interaction you're in
Yeah, but its Editor has a panel to bind directly gameobject's function to actions.
That's what I'm trying to use.
Guess I should just not bother with that option and do it the usual way.
Yes this binds actions to your functions in code
in those functions you can check which phase of the interaction you're in
e.g.
public void MyFunction(InputAction.CallbackContext ctx) {
if (ctx.performed) {
// stuff to do when the action is performed.
}
}```
How can I input that with cinemachines input provider as I have a problem
Or wait couldn’t I just set another random bond value to the vector2 value and use that in cinemachine?
For question which update function would I use for that instance
Also another question what are all the sub commands for a bind for example axis1.ReadValue but what are the others
please help
I'm using the new Unity Input System and I think I'm approaching handling events wrong.
I have the example set up where you establish an interface for the Input Map and all of the associated functions. My 'problem' is...well, from there, I'm just using the UnityEvent/UnityAction system and event listeners to say "Hey, a callback exists and here was the data for it."
Should I just be checking the Input uh...InputActions I think directly in those classes that are now listening for the events to just get the data directly and do what I need with it?
Hey all, I'm trying to add a new input to the first person starter assets, but even after updating the input actions to contain a new shoot function, updating the starter assets inputs, and adding a debug line to the first person controller nothing is happening. Am I missing a step in creating a new input?
It broke because I wrote it as onShoot instead of OnShoot
no error anywhere btw, cool system
Can you show an example? Not sure what you're referring to in your first half
There's nothing erroneous about creating a method called onShoot, though it does go against convention
no I mean thats literally what solved my problem. Changing it to OnShoot. The input wasn't registering in game but now it is after that change
That is bc you are probably using Send/Broadcast Messages. That is not a requirement that you preface it with "On" if you use "Invoke Unity Events" (which I find to be an easier workflow)
This is the entirety of my InputHandler (bar the initial setup). This FEELS like the wrong way to do it, where I just use my EventManager to make async function calls to the various Components that actually handle the different inputs.
Or maybe it's perfect and this is exactly what I should be doing. I have like a 'GameManager' of sorts that listens for the EventManager calls and does what it needs to do with MousePrimaryClick/ActionBarShortcut, etc.
I just don't know if I should be bothering with all of this and just have direct references to My InputManager so I can check ReadValues and stuff directly.
I think I understand the system, but I don't know if I'm butting heads with how it 'should' be used.
As you know, there are a bazillion ways to do it. Check out this script I did a while back(not finished) but maybe you can see how I implemented mine. https://pastebin.com/S5dTWHnD
I don't understand the complexity of your "EventManager" but it may be overkill. I don't know what your requirements are.
Are all of those ####.Instance references singletons like how you define Instance on line 6/12?
Correct. My game will only have one player and on the player are individual scripts for each ability that are also singletons. I only ever read input in the Input Manager and just call what I need to.
If so, I MIGHT have complicated things by writing my code in a way that suggests there might be multiple player controllers and such...but that's 100% not going to be the case since I'm developing a turn based game meant for single player sooo. Hmmm
It may not be feasible for you. There are a lot of factors that can prevent you from using singletons. Mine is a single player game.
Yeah, I don't think it's unfeasible but also might not be worth refactoring. I basically have a second layer of processing between say...Getting your Fire input and calling for the PaintGun to shoot. It might be unnecessary, but I guess it isn't hurting anything, and otherwise behaves extremely similarly
What I don't like about your script is your strings being passed into your TriggerEvent function
It's good to see an example of actual use though besides the mess I'm putting together
Yeah the usage of strings isn't great. I should convert all that to an Enum.
It's basically saying 'Call all of the functions currently listening for this event (the string)'
If that Input logic is living on a Player Controller script, I would move it to an Input Manager script just to keep things tidy. Other than that, I can't speak on your Event Manager class. There's nothing really wrong with your code that's poo poo.
Nah, the image was from the InputManager that's just tied to the interface. All of the handling of what to do with those inputs are shuffled through the EventManager and to a Player Handler
Please help
Currently trying to call JoinPlayer from PlayerInputManager with OpenXR InputDevices.... but it returns null because playerInput.user.valid is false, What can cause this to be false?
I looked around the internet and couldn’t find a solution to this problem.
Code
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Combat : MonoBehaviour
{
private Animator animator;
private Vector2 kickValue;
private Vector2 punchValue;
private void Awake()
{
animator = GetComponent<Animator>();
}
private void OnPunch(InputValue value)
{
punchValue = value.Get<Vector2>();
if (punchValue.x != 0 || punchValue.y != 0)
{
animator.SetFloat("X", punchValue.x);
animator.SetFloat("Y", punchValue.y);
animator.SetBool("isPunching", true);
}
else
{
animator.SetBool("isPunching", false);
}
Debug.Log("Punched");
}
private void OnKick(InputValue value)
{
kickValue = value.Get<Vector2>();
if (kickValue.x != 0 || kickValue.y != 0)
{
animator.SetFloat("X", kickValue.x);
animator.SetFloat("Y", kickValue.y);
animator.SetBool("isKicking", true);
}
else
{
animator.SetBool("isKicking", false);
}
Debug.Log("Kicked");
}
}
Error Message
InvalidOperationException: Cannot read value of type 'Vector2' from control '/Keyboard/z' bound to action 'InGame/Punch[/Keyboard/z]' (control is a 'KeyControl' with value type 'float')
UnityEngine.InputSystem.InputActionState.ReadValue[TValue] (System.Int32 bindingIndex, System.Int32 controlIndex, System.Boolean ignoreComposites) (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Actions/InputActionState.cs:2800)
UnityEngine.InputSystem.InputAction+CallbackContext.ReadValue[TValue] () (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Actions/InputAction.cs:1939)
UnityEngine.InputSystem.InputValue.Get[TValue] () (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Plugins/PlayerInput/InputValue.cs:44)
Combat.OnPunch (UnityEngine.InputSystem.InputValue value) (at Assets/Scripts/Combat.cs:21)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
hi there
how would you guys make a kind of "tab switch" control in the UI?
Like using the shoulder buttons for switching inventory tabs
hi, i'm using the PlayerInput to handle input and Unity Events, however when i change my character on the selection screen for some reason my input does not work anymore... any ideas why?
The character selection screen is something you made so none of us know the details of how it works
the problem is not on my character selection screen, but something on the unity input system itself
the only thing i'm doing on the character selection screen is changing the player model, they are all the same with different sprites
looks like when i add some object with playerinput at runtime the input would not work or something like that
The problem is how your code interacts with the system.
Presumably you are not ending up with a valid configuration when you choose a character
Creating new PlayerInput shouldn't be done when choosing a character generally
That's only something you would do when a new player joins
E.g. by connecting a device or something
so i can't change my player prefab at runtime using the new input system ?
You can change your player prefab all you want
Don't make PlayerInput part of the prefab if that's what you're doing
Again, the analogy for PlayerInput being created is a new device being connected
It's one PlayerInput per physical human person
Not for an in game character
Hey guys, I just updated my input systems to 1.5.0, and everything works as before. But when I went to my Input Actions asset, it showing me this in inspector:
I tried adding a new one, and it gives me the same error. Has something changed in 1.5.0 where now it has a different workflow?
I read the change log and the docs and didn't find anything about this.
What's going on?
do you ahve any compile errors
(even unrelated to this)
No
No
Like I said, it worked properly and continues to do so, the issue is that I can't add/modify the input actions via editor UI, I would have to do it manually via text editor.
I downgraded to 1.4.4 and reimported the file and now it works. I upgrade to 1.5.0 and it gives me the same crap.
That's what I reckon...
Just wanted to see if anyone else had this issue? If not, then maybe it's something else I have that would, for some reason, interfere with this...
Is it possible to get track/touchpad input?
I need my camera controls to behave differently depending on if input is coming from a mouse or trackpad.
For example a mouse should zoom when scrolling and pan when middle-mouse dragging,
but a trackpad should zoom when pinching and pan when two-finger dragging.
I did this in a game before, I ended up making an input action that included both mouse and touch input
and just handled them in their .performed callbacks
My functionality had the middle mouse zoom in/out and I wanted to duplicate that functionality with 2 finger zooming. To do this I subscribed to these events from the input actions cs controls.Touch.SecondaryTouchContact.performed += _ => ZoomStart(); controls.Touch.SecondaryTouchContact.canceled += _ => ZoomEnd(); controls.Touch.ScrollY.performed += context => HandleYAxisMovement(context);
Thanks for the suggestion. Unfortunately I specifically need trackpad input so the issue is not so much figuring out what to do with the input, rather, it's getting detecting the input in the first place
It seems two-finger drag and pinching is translated into scroll delta so I cannot handle them separately.
Pinching aside, I cannot even distinguish from a normal mouse and a trackpad.
I looked for differences in Mouse.current properties when using a mouse vs trackpad and every single property was identical.
if I intend for my game to be only on 1 platform, is there any point in using the new input system
Being cross platform isn't really a primary selling point of the new input system anyway. Both input systems are
I'm trying to understand the unity input system here. I am using the JoinPlayer method for manually adding a player to the Player Input Manager within Unity. I am also using the OpenXR Toolkit with this all within a VR game. I first retrieve the 2 VR controllers for the left and right hand with the following code.
ReadOnlyArray<UnityEngine.InputSystem.InputDevice> inputDevices = InputSystem.devices;
List<UnityEngine.InputSystem.InputDevice> selectedInputDevices = new List<UnityEngine.InputSystem.InputDevice>();
foreach (UnityEngine.InputSystem.InputDevice inputDevice in inputDevices)
{
if (inputDevice.name.Contains("ControllerOpenXR"))
{
selectedInputDevices.Add(inputDevice);
}
}
Then I try to add the selectedInputDevices to the player manager using the Join Player Method, but it doesn't appear to be working and returns null everytime only for the OpenXR controllers. I tried binding my Keyboard and that works fine. Is this due to a conflict with how the current controllers are being used within the XR Interaction Toolkit or something???
playerInput = playerInputManager.JoinPlayer(default, default, "Keyboard & Mouse", selectedInputDevices.ToArray());
ok... I figured it out.... I gotta have XR Controller in the Control Scheme attached with it
I wanna make touch inputs that work also with mouse. I need click, drag and drop and press. What's a good approach?
Working with UI elements
I have a question with converting 2 axis inputs into 1 vector2 input if that makes sense.
For example I have a GameCube (from Nintendo) controller and an 8bitdo gbros adapter to connect it to my Mac. As shown in the images above it shows the controller debug with all its inputs and my input map that I created.
What I’m aiming to achieve is using the C stick (right joystick) for camera movement using cinemachine. Upon placing the axis into the slot for the cinemachine input provider it gives an error along the lines of “axis is not a vector2”. As I’m currently on a cruise I haven’t found much since, other than this GitHub repo (https://github.com/popcron/extra-controllers) which didn’t help as I’m using a gbros adapter and no input gets detected.
I haven’t found anything new other than that and this problem is still here. If anything else do I need to switch to the old input manager as a last resort?
Yes
To what?
Everything
is it possible to have a "switch" in the new input system?
Like I press once its activated, I press second time it gets disactivated etc.
Just do this in your code
Make a button that toggles a bool variable
I hoped the new input system will allow me to delate player settings to configuring Input assets instead of configuring my own logic.
like
whats the point of input asset otherwise
@grave rapids Let's cover input system stuff here.
Thanks, I somehow didn't see this! I've got to do some IRL stuff real quick but I should be back in under 5 minutes.
First of all, are you generating a C# class from your input actions object?
Flipping a switch is game logic, not input logic. The input system is about reading input data. An imaginary virtual switch is not input data
Sorry about that, I am back now. Yes, I generated a C# class which is accessed by my bare-bones ControlCharacter.cs script at the moment, the button logs a message and the Vector2 moves the character.
Okay, so you are able to read input. Then what PraetorBlue said might be what you need: you don't change the input state through code. You read button presses and then use those signals to modify state somewhere else, such as in a class that handles the state of your menu,.
Oh he wasn't talking to you. What does your menu system code look like?
I may have went a bit over the top with some of the modularity and such, but I made this code:
https://hatebin.com/bunspvhisk
Okay, I presume you have some separate class that implements your input actions through an interface?
I'm not exactly sure what that means
If you press your button, where in your code are you capturing it?
The function OpenMenu() opens up one menu and closes the rest and is what brings me to my controls menu. However, if you mean the button for changing a control, I am working on the control changing in a second script to keep things organized.
That's what I mean... there is no input-handling code in the file that you sent, but that might suffice. Is this an issue with the input system or with the model of your menu controller? What was the issue again?
My goal is to create a function which allows me to set one of the controls from InputActions when the function is called. However, I'm not sure how to change an InputAction.
https://hatebin.com/dfsdtfzwwi
Oh, like rebind your keys?
Exactly
Is a framework kind of like a library of accessible functions? I'm not sure that I've used any yet.
https://youtu.be/xF2zUOfPyg8 Check around minute 25 of this Unity tutorial for a good overview of how this works. It's definitely a microcosm of study that's worth a read to understand because there's a lot of filtering that you need to be aware of when listening for key inputs.
Andy Touch, from our Technical Marketing team, shows you how to solve common scenarios when developing a cross-platform game that uses the new Input System. Learn how to quickly switch control schemes, rebind control settings, and connect the Input System with other Unity features.
Speaker:
Andy Touch - Senior Global Content Developer (Unity)
...
Code starts around minute 28, but the concepts are important to understand throughout.
Perfect, this seems very helpful. Thanks!
Unfortunately, what you write when changing a key has a few dimensions such as device number, key filtering etc. that the system can intelligently handle, but there's some layers to the implementation and it's not super intuitive (imo) if it's your first time looking at it.
That makes sense, for some reason when I was searching I couldn't find any relevant tutorials or articles not meant for more experienced users (probably bad search terms due to lack of knowledge) .
One thing that I'd like to warn you about: everytime you use new GameControls(); you aren't referencing the original asset where you store your initial bindings. The C# file you generate actually doesn't read the object at all.
@grave rapids To access the asset, you can do something like InputActions.asset or something to reference the original ScriptableObject that opens up in the editor. If you run into problems where you're changing your keys but your game controls don't seem to respect the change, this is likely the cause.
Gotcha, so should I generally avoid new GameControls(), or just when doing rebinds?
Just when doing rebinds, otherwise you'll be rebinding an instance. Using new in a read scenario should be fine.
Perfect, I'll keep that in mind. Is there any downside to using InputActions.asset over the new GameControls()?
I personally don't think so.
I'm taking a look in the inspector, how is InputActions.asset generally used? Is it something I assign GameControls to, or is it a separate type?
Let me check that quick.
Oh, there is a variable type called InputActionsAsset. Is that it?
For you, I guess it would be GameControls.asset.
Would that be a modification of the line public GameControls playerControls; or of playerControls = new GameControls();?
Or do I forgo both of those lines and just call GameControls.asset whenever I want to acess the game controls
For reading, you have to instantiate the class GameControls somewhere, so using new is fine for that. I use a singleton once in my project to make sure I'm always on the same instance like so:
{
get
{
if (_inputActions == null)
{
_inputActions = new InputActions();
}
return _inputActions;
}
}```
When I'm rebinding, I get the action using `asset.FindAction(string name)` which returns an `InputAction` object. That object contains the `PerformInteractiveRebinding()` method which assures that I'm binding on the action from the asset.
Are singletons just statics?
So, I read from an instance of the generated class, but I write using the native binding behaviour of the individual InputAction objects, taken from the generated class .asset.FindAction().
That ensures I'm not making copies of the input generated class and changing the bindings on copies that don't persist.
A singleton is any object that prevents itself from being instantiated twice, however you want to go about enforcing that.
Alright, so I am trying my best to understand how this works. However, I'm not quite sure how get{ works. Also, is InputActions InputActions a variable type and a name that are identical or is there some other reason for having it repeated twice?
InputActions is a parameter with separate behaviours for reading and writing. Anytime I read InputMaster.InputActions (the name of my class), I return the value stored at _inputActions, which is a private member. If _inputActions is null, then I call new InputActions() to fill it. This ensures that the first time the member is accessed it creates a new instance of InputActions, then all future read actions just returns the same stored object.
There is no "set" because InputMaster.InputActions = new object() is not intended behaviour, so I don't allow it.
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties @grave rapids
Alright, I'm reading through what you sent and the properties and this all seems to mostly be making sense. I assume a private member is a variable?
Okay, I've been looking through the docs for a bit now and I think I am starting to understand it some. This example was provided
{
private double _seconds;
public double Hours
{
get { return _seconds / 3600; }
set
{
if (value < 0 || value > 24)
throw new ArgumentOutOfRangeException(nameof(value),
"The valid range is between 0 and 24.");
_seconds = value * 3600;
}
}
}```
If I am understanding this correctly, this mean that I can essentially set a number inside of the function (Hours in this case) and/or retrieve a number from inside of the function, correct?
If so, what class do I put these properties in? Also, where do I set _inputActions?
members are anything that belongs to a class at the instance level:
- fields
- methods
- properties
- events
etc
Hi all, does anyone have some experience in setting up multiple touchscreens and success in using the both at the same time (think interactive for kids playing at the same time on two screens)?
Ps. Will deploy on Linux but development is on windows, if it would work for both great, but focus is on Linux for now...
Idk man, a switch sounds like input to me
Is there a way to get the bindingIndex for a binding immediately after adding it?
The return value of AddBinding has a bindingIndex field which has the wrong value in it
Okay it looks like I found a workaround for this but it's still weird behaviour/potentially a bug
If you had a physical switch on your desk, yes
I guess the same frame does not yet know about the index, so you might wait for the nextframe?
I don't think it's that, because I can see the new binding right there in the array. it's not like it's deferring adding it or anything
The workaround was to ignore the return value and just loop through the bindings array on the action until I find the control I want
Which is fine, just weird that AddBinding gives this totally incorrect value for no visible reason
How is the return value called? Just was jumping through docs and could not find how you get the return value
Oh, the function itself is a Binding Syntax, got it
How do you do it codewise? Just to see an example
like int newIndex = action.AddBinding(control).bindingIndex;
where control is an InputControl
And what if you just for testing put that in the next frame. Like accessing the index? Does it change?
I would prefer not to atm because I'm right in the middle of ripping a lot of complicated input code apart
You can try to just wait with a task or use a simple coroutine. but if you are into another thing right now, I get that
await System.Threading.Tasks.Task.Run (async () => {
await System.Threading.Tasks.Task.Delay(1000);
Debug.Log(newIndex);
});
Howdy everyone! I am getting the following errors in the unity console. Does anyone know what I am doing wrong?
ControlCharacter1.Update () (at Assets/Characters/ControlCharacter1.cs:47)```
```NullReferenceException: Object reference not set to an instance of an object
ControlCharacter1.OnEnable () (at Assets/Characters/ControlCharacter1.cs:26)```
```UnityException: CreateScriptableObjectInstanceFromType is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'ControlCharacter1' on game object 'Character1'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject.CreateInstance (System.Type type) (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
UnityEngine.ScriptableObject.CreateInstance[T] () (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
UnityEngine.InputSystem.InputActionAsset.FromJson (System.String json) (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Actions/InputActionAsset.cs:465)
GameControls..ctor () (at Assets/Characters/GameControls.cs:23)
ControlsLogic+GameControlsMaster.get_GameControls () (at Assets/Scripts/ControlsLogic.cs:20)
ControlCharacter1..ctor () (at Assets/Characters/ControlCharacter1.cs:20)
Character controls script:
https://hatebin.com/yeuepszpsw
Controls manager script:
https://hatebin.com/tvnuqyrczs
It seems like the line private GameControls playerControls = GameControlsMaster.GameControls; is what is causing the latter problem, however I cannot find what is wrong with it
Put that assignment in OnEnable or awake instead
gotcha
Don't assign in the field initializer
That makes sense
hi, does anyone know a better way to write this bit of code
void Update() {
if (Keyboard.current[key].isPressed) {
// do stuff
}
}```
how do you know? You should add Debug.Log
https://hatebin.com/nmqpjvcyrt
I've been working on this script for a while now, but I can't seem to get it to work. It throws InvalidOperationException: Cannot reconfigure rebinding while operation is in progress.
I thought the problem might be related to it being enabled, but adding actionToRebind.Disable(); did nothing.
Oh, it seems like people put the rebind script on the button itself. Maybe doing that will work better.
If anyone has any tips or similar for this, feel free to send me a ping and I will respond ASAP.
For now I am going to come back to this in a bit, hopefully coming back in a while will give me better insight for the error
fovSlider is null
Hi! I'm very new to Unity and I'm trying to experiment using the Input System. I have a simple setup with a single InputAction with two maps: Player and Camera. What I wanted to do is to have the player object use the Player map and the camera use the Camera map (I want to use it to toggle camera perspective on key press).
However, this isn't working. Am I missing something or do I necessarily have to have two different InputActions in order to make it work?
Right now I have a PlayerInput component both in the player and in the camera object
Each PlayerInput is assigned its map and both are set to "Send Messages".
They only work if only one is enabled. If I enable both, nothing works
How do i get current active tmp text input (webgl)
Without havin to make an on select for each…
good news, I have fixed the error at the cost of some sort of memory leak. At least it's a change of scenery from my script
How can I implement the new input system so that I could move my player to left and right through touch input?
anyone have some good methods for button prompts, was thinking for a action i could just search through and get the path of the binding
and have a lookup table for those paths to icons
Is it bad to make each direction of input (MovementUp, MovementDown, etc) a separate action? I'm not sure how else I could use my StartInteractiveRebind script on anything with more than one binding.
Never mind, I just need to put in a binding value, that should work if I just add another parameter.
Hey folks, I seem to have forgotten how to set up WASD on a new Input Action. I can't get access to the composite bindings and... I'm getting really confused.
I'm trying to do this...
...but all I have is this:
I believe that implementation is the 'correct' one for dealing with matching a control's name to an icon, especially if you are going to allow rebinding, or an input action/control that is bound to an icon on the screen may change at runtime.
You most likely want to use the 'name' property of an InputControl. The documentation states this for the 'name' property:
The name of the control, i.e. the final name part in its path.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.5/api/UnityEngine.InputSystem.InputControl.html#UnityEngine_InputSystem_InputControl_name
yeah looks like i will have to do that
but handle seperatly buttons by name
buttons by position
and buttons by purpose
It looks like you are using a 'Button' style of action for your Move Action. I think you will want a Value type action, with a vector2 value
By position and purpose?
do not allow rebinding, but what i bind to in game depends on a few things
some cases it will be A and B always since its for stuff like confirm and Cancel
but other times i am using North, South, East or West and position matters more
since a b x y are all in different spots in switch vs xbox
Ah.
I haven't messed around much with rebinding (one of the things that I really wanted to take a crack at), but from my understanding is that you can initiate a rebinding operation passing into it a series of either limitations, or requirements.
Sorry Matt, this is the current state of my Input Action... but I'm still trying to replicate the layout of the original one from the example package (see above).
The documentation has this nifty example which seems to do some of it
var rebind = new RebindingOperation()
.WithAction(myAction)
.WithBindingGroup("Gamepad")
.WithCancelingThrough("<Keyboard>/escape");
rebind.Start();
and it also contains an example for excluding
rebind
.WithControlsExcluding("<Pointer>/position") // Don't bind to mouse position
.WithControlsExcluding("<Pointer>/delta") // Don't bind to mouse movement deltas
.WithControlsExcluding("<Pointer>/{PrimaryAction}") // don't bind to controls such as leftButton and taps.
Does that seem what you require passerby?
I may be misunderstanding what you need Reverend.
Now that you have set your Move Action as a Value and a Vector2 Control, if you select to 'Add' a new binding, does it not display the option of an up/down/left/right control?
After enabling the input system used in my project to "Both", I am constantly getting 3 of these errors whenever launching the editor, and testing the game:
Hi Matt - sorry, I missed your response. I am getting the option, 'Add Up/Down/Left/Right Composite', but a) I don't get the option of 1D Axis as in my first example image (replicated here), which is the example I'm trying to copy, b) I'm a bit confused over how I incorporate the gamepads into this scheme.
I'm also missing the options to reduce the stick output to one axis (note the original example I'm copying from is on the RIGHT in the following image):
hey whats the best input system for Local Multiplayer games? It's just gonna be 1 keyboard and mouse player and up to 3 controller players but idk if i should use the new system or some people reccomend "ReWired"
Hm... Okay... So, first things first.
There exists Bindings and Composite Bindings. A Binding binds itself to a SINGLE control (a Keyboard Button, a Gamepad Button, or a single Axis Control, such as the mouse Scrollwheel). A Composite Binding can bind itself to two or more controls. (A and D Keyboard buttons for example).
The option to use 1D axis in the Composite Binding can only be enabled if you create a binding that HAS a Positive/Negative Binding (aka, a Composite Binding).
You can only create a Composite Binding for Actions of certain types.
ActionType Button grants the option to create a Composite Binding, however, if you are creating a Move action, they aren't ideal if you want to support Gamepad since moving the Gamepad stick has values between 0 and 1, and Buttons only trigger once if the value crosses the .5 threshold (or whatever value you've defined in your InputSettings asset). For Gamepad Stick support, what you want is to use ActionType of Value.
ActionType Value HAS the option to create a Positive/Negative binding if you select certain control types.
A ControlType of Axis will allow you to create a Positive/Negative binding. When you select this Binding that you just created, you'll be able to change the composite type (which is what you are showing on your first picture there). So that solves your issue A.
With an ActionType Value, and a normal Binding (not a composite one), you can bind that to the Gamepad Left Stick X or Y values. The left stick X can bind to Control types of Axis (you just have to specify if you want the X or the Y axis when you are doing the binding to control), or 2D axis (where you specify to just use the Left Stick itself.
A ControlType of Vector2 allows you to create a Up/Down/Left/Right binding. With that binding you can select WASD as your input keys, and you can select the LeftStick control itself (since the left stick control is a Vector2 ControlType)
That's great info, @rough trench ! I'm in transit atm, but I'll try that info out tomorrow!
I (relatively inconsistently) get these errors thrown. It's not a 100% of the time issue, and as far as I can see in my code it seems fine.
Peeked through the past instances of this in the thread, but either I missed something or the issue itself is something different, typically seems to happen after I update scripts. Is this something "normal" or a sign that there's some sort of issue that's a common thing to find?
The weird thing is in regards to some of the lines are kind of nonsense? For example for the CamZoom script, line 28 is just the final curly bracket in the script
Hi people! How do I detect if a keyboard is present at startup ( in Awake() )?
I tried googleing but was not lucky until now
(maybe I should ask Bing LOL)
If (Keyboard.current != null) should do it I think
I'll try it out, thanks!
Thank you, Matt. Christ, I should get that information tattooed to my forearm, but I'll settle for saving it in a document. As it turns out, I've learnt all this before, but every time I go back to the Input System fresh I end up confusing myself over the options available from Action Type and Control Type. Switching to Action Type 'Value' and Control Type 'Axis' allowed me to construct the controls as I had originally intended. It's just frustrating to realise I'm not getting better at configuring this system...! Again, cheers for all the advice...!
There's no way of knowing by just looking at these errors.
All they say is there's some null references in your script.
Are they related to the InputSystem?
Np.
Yeah it can get a bit confusing with all of the input devices, users, controls, processors, interactions yada yada.
Best of luck~
Yep, pretty much exclusively related to whenever I've made changes relating to the input system code specifically.
I'm not getting them now, but was more curious than anything else what the general cause would be. The joys of an inconsistent error and all that.
- sigh * Anybody know how I can check if Unity is seeing my PS5 Duel Sense pad?
You'd have to post some samples of your code for us to have any idea. Usually missing references to the input system may be because you edited the asset, and it is setup to be saved as a C# file, and it errors out while the c# file is being recompiled.
That'd be my best guess without looking
I'm looking at the Input Debugger atm, and while it lists the Duelsense, I don't seem to be getting any input from it. Eg. when I use the 'listen' function in the Input Action window, it's giving me no response.
Additionally I'm not getting input from it when running my little test game.
Yeah, I'm looking at that right now.
Try disconnecting and reconnecting it and see if unity prints out in the console that it has recognized it being connected
It does detect that, I tried that earlier (and just now!).
...Although it doesn't appear to show up in the Input Debugger now. =/
It's listed under 'Disconnected', though I've just had the console message, "Joystick reconnected ("Wireless Controller").
I don't know off the top of my head, but you can give the supported devices page a try, and read up on their notes to see if there's anything specific you should be looking out for.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.5/manual/SupportedDevices.html
"PS5 DualSense is supported on Windows and macOS via USB HID, though setting motor rumble and lightbar color when connected over Bluetooth is currently not supported."
Yeah. It should be supported. And I'm wired, here.
On Unity restart, it's found it...
...and it responds to the input in-game. So, turn it off, turn it back on again. The Old Ways.
Hah. Praise jebus!
Hi everyone! My input was working fine (touch on iPhone and the simulator in unity), and then yesterday with literally no changes (I'm using version control so 'really' no changes) it stopped working. I now get this error (and doing this doesn't fix the issue). any ideas?
InvalidOperationException: EnhancedTouch API is not enabled; call EnhancedTouchSupport.Enable()
Hey, I am creating a fps view game and I want to add console controller controls but the joystick Y Axis does not work. Is that normal ?
I'm making a game with multiple controllers, and every time i reload a script while playing it crashes giving a NullReferenceException when it runs OnEnable, saying controls.Player doesn't exist (which is the control scheme)
PlayerControls controls;
void Awake()
{
controls = new PlayerControls();
selector = gameObject.transform.Find("Selector");
selector.GetComponent<SpriteRenderer>().color = SetPlayerColor();
terminal = GameObject.Find("Terminal 1").GetComponent<Terminal>();
}
void OnEnable() => controls.Player.Enable();
void OnDisable() => controls.Player.Disable();
Now without reloading while the game plays it works perfectly fine, but i don't think it's supposed to happen and i definitely don't want it happening during build versions
How can I make it so the player can change their keybinds through code?
Hello everyone, I am new to unity, I want to know that, How can I integrate Bluetooth in my Unity Game? I have HC-05 Bluetooth module. Please help.
Hi there, was looking for a way to handle dragging with the new input system. Upon googling, I found https://docs.unity3d.com/Packages/com.unity.inputsystem@0.1/api/UnityEngine.Experimental.Input.Interactions.DragInteraction.html
I can't for the life of me figure out how to add this to our project? Does anyone know?
Hey! I'm using OnScreenStick with Control Path "Left Stick [Gamepad]" and it's working nicely for movement.
The problem is that I would like to be able to instantiate this On-Screen Stick to the screen position that is touched and get movement (dragging) working immediately without separate touch. I mean, I'm now able to instantiate the stick to desired position but I need to touch&drag it again in order to start the movement. Any tips?
"dragging" is quite vague, you'll have to be more specific
Hi everyone! My input was working fine (touch on iPhone and the simulator in unity), and then yesterday with literally no changes (I'm using version control so 'really' no changes) it stopped working. I now get this error (and doing this doesn't fix the issue). any ideas?
InvalidOperationException: EnhancedTouch API is not enabled; call EnhancedTouchSupport.Enable()
Have you enabled it like the error suggests?
private void Awake()
{
EnhancedTouchSupport.Enable();
}
For InputAction, I’m trying to make a bullet hell and doing the controls first, I have the InputAction package and I’m trying to figure out action and control type, I’m doing it so when the player presses on the screen, when they drag their finger they can move where the ship is, any suggestions? no mouse controls, finger
@fair plaza I pointed you to a tutorial, like an hour ago. Did you bother to look it up?
I did, and I have a touch input system, a touch manager https://gdl.space/iyuvatucag.cs, so now I'm just trying to figure out the drag and move
i know how to transform an object instantly from point A to B, but not drag and move
It covers virtual joystick drag inputs
oh where? apologies I didn't see that part
It has chapters and even points to them in the description
I don't actually have to make a joystick do I?
Why don't you start by looking it up?
oh are you referring to movement action?
@fair plaza You can stop tagging me with useless questions as well. Look up the video. See how it works. Implement it.
oh wait it uses applyforce, that wont work for me
It takes variable input, how you use it it's your code...
ah I meant code wise, I know its basically the code for the rollaball game every unity coder starts with, just not sure how to apply that to a gameobject that wont have a rigidbody
You should start with basic tutorials on !learn Preferably Essentials Pathways courses.
🧑🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
Joystick just gives you Vector2 which input system can normalize for you as well. You need to know how to use it.
Hey everyone I have been following https://catlikecoding.com/unity/tutorials/movement/orbit-camera/.
Instead of using the old input system I am trying to use the new input system to make myself familiar with it.
void ManualRotation () { Vector2 input = new Vector2( Input.GetAxis("Vertical Camera"), // <-- using old input system. Input.GetAxis("Horizontal Camera") ); const float e = 0.001f; if (input.x < -e || input.x > e || input.y < -e || input.y > e) { orbitAngles += rotationSpeed * Time.unscaledDeltaTime * input; } }
I found that the default input scheme it generated for me already had Look action defined so i just used it instead. I've added sceenshot of the input scheme.
I also added Normalize Vector2 processor to it which improved it a bit but it's still jagged.
private void ManualRotation() { Vector2 input = new Vector2(-look.ReadValue<Vector2>().y, look.ReadValue<Vector2>().x); const float e = 0.001f; if (input.x < -e || input.x > e || input.y < -e || input.y > e) { orbitAngles += rotationSpeed * Time.unscaledDeltaTime * input; } }
But it gives me erratic results with jagged camera. I know I could lerp the camera movement but I don't want to make it any complex than it has to be.
I also tried finding the Vertical Camera Axis in the input manager settings so i could replicate it in actions which is what i did for wasd movement.
But, I couldn't find it listed anywhere, i've added screenshot of the Input Manager Axes.
I am using Unity 2021.3.5f1 on Windows. I would appreciate any help in this. Here's my full code for camera controller: https://gdl.space/hudatikozu.cs
the "sceenshot of the input scheme" you provided is from the old input system, as the warning at the top is saying
it is not related to your new input system code at all
oh sorry didn't see the second screenshot 😓
thanks for replying. Yeah I am trying to use the new input system.
what is "orbitAngles?"
i couldn't find "Horizontal Camera" axis defined anywhere. I though I could replicate it
The main difference between the new and old code is that GetAxis does some automatic smoothing
It's just a fixed angle at which camera is positioned at, 45 degrees, looking down at the sphere
those axes are not there by default. He would have defined them in the tutorial
I had the older code working and i don't remember defining an axis called "Horizontal Camera".
by older code i mean older input system
Nor did i import any packages from the tutorial. I built it from scratch.
Should I put the project on github so people can quickly test it?
I am quite sure but i'll take a look if i missed something. Thanks for replying
test it for what exactly?
As mentioned this is probably the issue
so you'll need to recreate that smoothing yourself if you want the same behavior
see how jagged the camera movement is
if only i can find how they defined the new axis ;_;
probably just default settings
it's nothing special
Sorry I must have missed it. How do i do the smoothing on the mouse delta i get? I have normalized it but i can't think of any other way then lerping which will drag the camera behind i guess
and no how could I? I cannot see your computer
normalizing it is going to make things significantly worse
The GetAxis gravity stuff is dead simple
it's just MoveTowards
well i can make a gif or put the whole project on github. it's just a single scene
I'm not going to download your project
Suffice it to say I believe you
because there is no input smoothing
oh okay
you can just use MoveTowards to get the same behavior as GetAxis used to have
float speed;
Vector2 currentValue;
void Update() {
Vector2 input = myInputAction.ReadValue<Vector2>();
currentValue = Vector2.MoveTowards(currentValue, input, Time.deltaTime * speed);
}```
"speed" is like "gravity" from the old system
but the problem is the orbit movement being jagged, i have set it up to follow the and i directly set the transform of the camera
you'd have to show the code for the orbit movement
i sent the paste link but i'll send it again
LateUpdate is where I set the transforms. UpdateFocusPoint is where i lerp the camera to the moving sphere. Sorry for not commenting the code i was following the tutorial
this seems wrong:
Vector3 lookDirection = transform.forward;```
shouldn't it be:
Vector3 lookDirection = lookRotation * Vector3.forward;```?
right now you're using the old look direction to calculate the new camera position
that seems off
the tutorial instructed to set roation seperately, transform.SetPositionAndRotation(lookPosition, lookRotation); where lookRotation is calculated from orbitAngles
I understand that
^
I would assume you would use the newly calculated rotation to determine where to position the camera
it's using the rotation from last frame to do that currently
which could easily lead to stuttering / weirdness
lemme share a video of it stuttering, i feel it will help you help me better
have you tried making the small change I suggested?
yeah i'll do that first
you know what that fixed it haha. I have axes inverted which i can easily fix
Can you explain to my why it was stuttering? why it worked with the old input system? I still don't fully understand it.
So I'm scrolling through past information but I'm still not grasping it. With this example, what would be the best replacement for Input.GeyKeyDown
if (Input.GetKeyDown(KeyCode.Escape) && canPauseGame == true)
{
PauseUnpause();
}
the best replacement would be to switch to using Input Actions and handle the performed event for the escape action you defined.
it's not just a 1:1 code replacement
it's a totally different approacj
fml, this new system is so confusing
the 1:1 code replacement would be: Keyboard.Current[Key.Escape].wasPressedThisFrame
but that's not the "best" replacement
ok
As i know we calculate the orbit angles from the input, which is quaternion of the direciton I am looking at then i multiply it with forwad to get my lookdirection. the position I set using the look direction. and finally set rotation.
wait a second. I didn't multiply the forwatd direction -
Would it be something like this in the update function?
isGamePaused = piRef.actions["PauseGame"].ReadValue<bool>();
if (isGamePaused) { PauseUnpause(); }
I would add an action called escape and use a function to pause it where i check canPauseGame is true
when you say 'use a function'
you don't want/need a Press action on your button
Youneed to just go follow some new input system tutorails
so you can understand how the event based stuff works
in code
pause= controls.Player.Jump; pause.Enable(); pause.performed += (ctx) => { if (canPauseGame) PauseUnPause(); };
._.
controls would be C# script generated by input action asset,
okay wait a second. Ill send proper code.
with screenshots
You define the action, it's type is Button as we don't want values
Generate a C# class
And then you hook it, like this. https://gdl.space/zehamofemi.cs
i should use a pastebin
That's what I would do
i am assumign you're doing the if check in the Update funtion, this way you won't have anything in Update()
btw i dunno how i got the Input Action Asset, it was just there when i set it up. I renamed it from Tutorial to PlayerControls
Yeah, i think of it as an event. I guess the old input system relied too much on checking stuff on each frame. The new input system is I guess event based. You define actions. if they're "event-like" like jumping or pausing you define it as button. then hook a function as callback so unity can call it for you when those actions take place
what about this
if (playerInput.actions["PauseUnpause"].triggered)
{
PauseUnpause();
}
it changes how you code 🤔 so there's no 1-1 translation
I never rly learned how to do events during my degree
and that was ages ago now
you can do this? interesting
i thought you could only ReadValue() since it returns float i was doing weird stuff like checking against 1.0f 😄
doesn't work properly btw.
the thing i posted, or the thing you said doesnt work?
the thing i did, if (action.ReadValue<float>() == 1.0f) { ... } this doesn't work properly
whoa there's a setter triggered i could have just used it
btw thanks everyone :). Have a nice day.
if u can, i cant get it to work lol
i saw it in a video i was watching
gah, i hate this system!
Oh lemme see. You want pausing unpausing right?
yeah for this example
if (... get esc button down) { Debug.Log(...) } so something like this would be fine right? You can put the pause functionality inplace of debug log. I guess you want to toggle it as well 🤔
I need help, for some reason My touches in my simulator arent being responded, I'm trying to do drag and drop movement like in Bullet Hell gams with the player ship, anything seem out of place as to why my input is noty working?https://gdl.space/iyasavagir.cs
Hello, for input action, I’m trying to set up an input action for Android controller, would that be press or hold?
why there is no vectors?
you haven't set your action as Value/Vector2
ty😅
Anyone ever successfully use QueueDeltaStateEvent for a custom device?
Hey there! I am a student and planning to make my first mobile game in unity...my previous games were all pc and controller based and all were made with legacy input system so I thought to give input system a try but it feels pretty overwhelming compared to legacy input system....Since the input system is best for controllers and crossplay options is it worth it to learn all this for touch inputs or shall I use legacy inputs for this touch controlled mobile game?
this here is code for my player movement, I'm doing a touch based player input, any suggestions on how to put a limit on how far the player can go on the screen? so my player doesnt go off screen https://gdl.space/zaxiyedife.cpp
Place colliders in the world at the edges
remind me, how do I set it so my player doesnt go through 2d Object doesn't go through objects with box coliders?
Move your player in a physics-aware way
e.g. setting velocity or using AddForce
any suggestion as to why my colliders arent working?
Are you moving the player in a physics aware way?
So…..I had my plane set to…kinematic
how do i make the button press so it only registers once when pressed down?
it registers if i press and hold it and i dont want that
I think taking a bit of time to learn the new system is a good idea because it makes things simpler in general, just has some complicated ideas to learn
I think my favorite features have been free events and the fact that it supports control bindings automatically, and lets you set new ones with one function
Overall its nice to use i think
yep that'll do it
I have indeed! but the weird thing is, it worked before without that. and with it enabled, it still does not work.
how would one go with making a double jump and hold to jump higher script with the new input system?
cant really find tutorials for it
the things you are asking for are about code logic and gameplay not about input handling
sorry
Hi friends, when I jump a single time it's immediately using up the bonusJump token, rather than waiting for another input. And logically I understand why, but I don't know how to fix it. I tried creating a new function called BonusJump and binding it to the same button, but same issue persists.
Looking online i might be able to use something like playerControls.Player.Jump.IsPressed, ill have to give it a go
Hi all i want to create vr car race game for oculus secondary thumbstick pressed up car move forward, thumbstick pressed down apply break smoothly how i can map thumbstick controller key binding for specific action
Probably, you aren't being restrictive enough about in which phase you should run this script. If Jump is receiving input events, then this method is being called once per frame, once again on the first frame when it is pressed and an extra time on the final frame.
context should have a phase enum where you can determine what phase of the input action invoked Jump(). You probably want to narrow for Phase.Started.
ill look into this when i get home, thx
hello, I use the events, and I would like to run the event on all the Item.cs scripts in my scene but the function is not showing when I select the script.. How can i select all the scripts instances without put one by one the object reference..?
this si the function in the Item class
you are not supposed to drag the script in. You are supposed to drag the GameObject with the script attached to it
Thank you
I am trying to use Touch input for my game so I am just testing if it works by checking if (Input.touchCount > 0) but this condition never becomes true. So this means that there is no touch input right? I don't want to use the new input system so is there something I need to do in order to get this to work
yep if touchCount is 0, there are no touches
Then how can I fix it, like, I am using my mouse's LMB for clicking
Do I have to assign Mouse 0 as touch input or something?
Mouse input will not be considered as touch input.
But touch input by default is considered pointer/mouse input
So is there no way for me to test touch input on pc :legasp:
Hey guys, I am trying to make a test class for testing my inputs however when I try to inherit the class from InputTestFixture it says that the class is missing...
Is there any workaround for this?
I have added the "com.unity.inputsystem" under the "testtables" section in manifest.json
Figured out it is "testables" and not "testtables". Fixed now.
However, it seems like my mouse click and movement won't get simulated in the system... it won't print the statements which i wrote when the UI element gets clicked ,could there be a reason for this?
Does anyone experienced the bug that although added controller and keyboard functions to your inputSystem, only one gets read. And this is completely random? xD I have no idea how to fix that. Please @tame coyote me if you know how to fix it 🙂
Okay, I got this finally working. If you guys are wondering why you can't use InputTestFixture even after adding testables in the manifest.json then all I had to do was update the my type of input system in the EventSystem game object.
im trying to make it so that when i tap the space key i jump once, and continuously jump when i hold down the space key, but only the tap input is working and the player doesnt jump at all when i hold down the space key, how do i fix this?
what script are you using to trigger the jump method?
private void jumpInput(InputAction.CallbackContext context)
{
if (readyToJump && grounded)
{
readyToJump = false;
Jump();
Invoke(nameof(ResetJump), jumpCd);
}
}
here
jumpCd is set to 0 for testing
from what i see this is how hold interactions are used:
fireAction.started +=
context =>
{
if (context.Interaction is SlowTapInteraction)
ShowChargingUI();
};
fireAction.performed +=
context =>
{
if (context.Interaction is SlowTapInteraction)
ChargedFire();
else
Fire();
};
fireAction.canceled +=
_ => HideChargingUI();
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Interactions.html
oh
Hey guys, is it possible to simulate keyboard inputs (such as typing with keys) for UI testing with InputTestFixture?
So I'm having an issue when using the input system, that prevents my player character from moving the way I want. I am using Invoke Unity Events to call this function. But instead of allowing my character to walk continuously in whatever direction the player wants to move, it just moves a bit then stops.
public void MovePlayer(InputAction.CallbackContext context)
{
var value = context.ReadValue<Vector2>();
Vector3 direction = new Vector3(value.x, 0f, value.y).normalized;
animator.SetBool("Walking", true);
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + mainCamera.transform.eulerAngles.y;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnsmoothVelcoity, turnSmoothTime);
transform.rotation = Quaternion.Euler(0f, angle, 0f);
Vector3 movedirection = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
controller.Move(movedirection.normalized * walkspeed * Time.deltaTime);
Debug.Log(movedirection);
if (context.canceled)
{
animator.SetBool("Walking", false);
return;
}
}```
couple ideas:
-
Check the input system configuration: Make sure that the input system is correctly configured to recognize continuous input from the player. For example, if you are using a joystick or a gamepad, make sure that the axis values are mapped to the correct input actions and that the axis values are continuous. If you are using keyboard input, make sure that the input system recognizes key press and key release events.
-
Check the Invoke Unity Events: Make sure that the MovePlayer function is being called continuously while the input is being held down. If the function is only being called once, then the character will only move a bit before stopping. You can check this by adding a Debug.Log statement inside the MovePlayer function and checking the output in the console.
-
Check the controller input values: Check the values of the direction vector and the movedirection vector to make sure that they are being calculated correctly. You can add Debug.Log statements to print the values of these vectors to the console and check that they are what you expect them to be.
-
Check the walkspeed value: Make sure that the walkspeed value is set to a value that allows the character to move continuously. If the walkspeed is too low, the character will move slowly and may stop after a short distance.
-
Check the controller.Move function: Make sure that the character controller is moving the character in the correct direction and at the correct speed. You can add Debug.Log statements to print the values of the movedirection vector and the walkspeed value to the console to check that they are what you expect them to be.
Well, I did assume it might be option 2, and it is only being read once, but I'm not sure how to go about fixing it.
or rather
MovePlayer() is being triggered three times with the same values. But seemingly only moving my player once.
may i dm you? i might have something that could work but it might fill up this channel with the texts if i cant get it across well in few messages
Ofc
for the life of me i cannot figure out how to explicitly state which input devices to pair with which player input components, it seems to just choose the first device available instead of the ones i want
i'll have a keyboard and two gamepads, and sometimes i might want to use two gamepads instead of all three or a keyboard and gamepad but it seems like i have no control over that
Are you using InputUser.PerformPairingWithDevice? https://tinyurl.com/2p9xx7td (that link just goes to Unity docs, just using tinyurl to shorten it so it will fit lol)
i actually wasn't using anything but i'm wondering does it add a device or make that the only device that can use that instance of a player input
I want move a car when Oculus secondary thumbstick pressed up how to bind controls in unity
Hi can I get some help, I tried to click the world space canvas with the WMR controller, but the button never reacts when I pull the trigger or any other buttons. What should I do?
I'm having a problem with the new Input System, I just want to switch from tiles to tiles in my UI Menu, but for some reason when I decide to go left, it calls the function multiple times and continues to go left until there's no more "Left Tile" left (no pun intended).
for the record, it does not just jump from the right one to the left one, it goes inside the middle one and immediately goes to the next left one.
private void Awake()
{
controls = new InputControls();
updateTileStyle();
}
private void OnEnable()
{
controls.TiledMenu.Enable();
controls.TiledMenu.RightTile.performed += moveToRightTile;
controls.TiledMenu.TopTile.performed += moveToTopTile;
controls.TiledMenu.BottomTile.performed += moveToBottomTile;
controls.TiledMenu.LeftTile.performed += moveToLeftTile;
}
private void OnDisable()
{
controls.TiledMenu.Disable();
controls.TiledMenu.RightTile.performed -= moveToRightTile;
controls.TiledMenu.LeftTile.performed -= moveToLeftTile;
controls.TiledMenu.TopTile.performed -= moveToTopTile;
controls.TiledMenu.BottomTile.performed -= moveToBottomTile;
}
private void moveToRightTile(InputAction.CallbackContext ctx)
{
if (!isSelected || rightTile == null) return;
unSelectTile();
rightTile.GetComponent<TileManager>().selectTile();
}
private void moveToLeftTile(InputAction.CallbackContext ctx)
{
if (!isSelected || leftTile == null) return;
unSelectTile();
leftTile.GetComponent<TileManager>().selectTile();
}
private void moveToTopTile(InputAction.CallbackContext ctx)
{
if (!isSelected || topTile == null) return;
unSelectTile();
topTile.GetComponent<TileManager>().selectTile();
}
private void moveToBottomTile(InputAction.CallbackContext ctx)
{
if (!isSelected || bottomTile == null) return;
unSelectTile();
bottomTile.GetComponent<TileManager>().selectTile();
}
Is this script on every single one of your tiles?
Actually, nevermind, it is.
The issue is pretty simple.
You have the following execution order
RightTile
MiddleTile
LeftTile
each of them will try to execute one of these actions you've setup with every input you make at the 'same' time.
The problem comes from the fact that each of them is attempting to move left on their own, and because of the execution order, it seems like the selection jumped too far.
The step by step of what's happening is, when you have the RightTile as the isSelected = true.
RightTile reacts to your LeftTile action and executes a move left. That means MiddleTile isSelected = true.
MiddleTile reacts to your LeftTile action and executes a move left. That means LeftTile isSelected = true.
LeftTile reacts to your LeftTile action and does nothing because its leftTile property is null;
If you move in the opposite direction (right) starting from the left tile, in the background, what is happening is
RightTile reacts to your RightTile action and does nothing because it is not selected.
MiddleTile reacts to your RightTile action and does nothing because it is not selected.
LeftTile reacts to your RightTile action and executes a move right.
What you need is instead of having each tile receive the input and attempt to move on their own, you need a controller script that will receive the input, know what's the currently selected tile, and attempt to move left or right based on the currently selected tile's left/right/up/down tiles, and then deselect the current tile, and select the new one
It's pretty much the same behaviour as Unity's UI EventSystem and its Selectables.
ooooh I see, it makes sense, thanks a lot for the explanation @rough trench 🙏
ok i finally came back to working on the input system and i have no idea what InputUser means in context or how to use it
Do you have PlayerInput components attached to your player gameobjects?
yyep
You should test it out! I can't be of much help at this point
🔴 Do not
• Ask or answer questions using unverified AI-generated responses.
ah okay
actually earlier I was using PlayerInput.Instantiate with controlScheme/pairWithDevice as parameters and it seems to work fine, but if there's only one player then anyone can control that player
if there's two or more then that device only works for that player and other devices don't interfere
Howdy folks! Is there a way to get an action map from a static Input Action Asset based on a string? I can't seem to figure out how/where to use something like FindActionMap.
I can of course directly search for the binding, but some bindings (eg. between players) share names and I'd assume there is a more elegant way of finding the map than just naming my InputActions things like Player1Movement and Player2Movement.
(I am also fine with using an ID or whatever for getting the InputActionMap - I just can't seem to access it at all at the moment without a direct reference like controls.Player2.movement)
Alright, I think I figured out my problem. I'm not completely sure why, but when I use controls.asset.actionMaps that gives me what I need. I'll be doing more searching to figure out exactly why it is like this , but I should be all set on my own without help for now.
hi, thank you in advance.
I am going to make a floatingjoystick using new inputsystem.
who can help me?
I am searching in google but not found.
there are some useful youtube but they don't show me FloatingJoystic.cs from Llama Academy.
If you have FloatingJoystick.cs, please send me.
What's a floating joystick?
If you mean an on screen joystick, the input system has built-in support for that
it's not productable, I think
there should knob, background at least and should be floating,
I want to control character by touching any position of screen.
@austere grotto make sense what I want?
Please help me
Not really no, maybe show an example
Not sure what "not productable" means
🚨Synty Humble Bundle LIVE NOW through March 16 2023: https://www.humblebundle.com/software/syntys-polygon-game-dev-assets-bundle-3-software?partner=llamasoftware&charity=2280172 20 high quality, popular, low-poly style packs for as low as $25!🚨 This week you can learn how to add a Touch Movement Joystick to control your player using the New Inpu...
this video show how to use FloatingJoystick.cs but now show the source code of FloatingJoystick.cs
the new input system doesn't really work in webGL - it works on windows and play mode
so I have 2 players both set to 1 input system file
In it I have Move, Jump, Teleport, and then I copied them to rename them (Move1, Jump1, Teleport1) and changed the keys
they I made one player work on Move, Jump, Teleport and the other on Move1, Jump1, Teleport1
like I said it works in play mode and on windows but just not webGL, any help?
also Move, Jump, and Teleport is WASD and Move1, Jump1 and Teleport1 are arrow keys
ping me
how do i get gyroscope for Xbox/PS4/Switch Pro controllers with new input system?
public override void SetMoveValue(InputAction.CallbackContext input)
{
Vector2 moveInput = input.ReadValue<Vector2>();
Vector3 moveDirection = transform.forward * moveInput.y + transform.right * moveInput.x;
moveValue = moveDirection.normalized * speed;
}
so i hooked this function in a unity event but the player keeps moving the in same direction until the key is released,any idea why this is happening and if it is the fault of the input system or another system?
That's the expected behaviour of the system.
When an action is performed/executed/cancelled, the method is called, and the moveValue is updated.
If you have an Update function that moves the player based on move value, the player will be constantly moving since moveValue has had its value set to the input.
Once the key is released, moveValue is returned to 0
Why is my friend's Switch's Pro Gamepad Gyro detected as Right Analog Stick?
Or more rather, how to disable it?
does this also work for Gamepad's sensors?
(in pc ofc)
yeah but that's not the problem,the problem is it keeps moving in the same original direction regardless if i rotate the transform and it only changes when i stop pressing and repress
A bit late, but I just upgraded now and have this same issue. Did you figure out what is causing it? Edit: Never mind. I reimported the package and the file and it has resolved.
That's because the move value is only ever updated when the ACTION is updated, which means, when the action starts, you read transform.forward. if in the next frame you rotate the transform, it doesn't matter to the moveValue, because move value is not being updated unless the action is updated
You would have to update your moveValue in update to the updated transform.forward
okay
this is where i get the value of the moveValue from the other class,how would i update it?
and here is the main fps movement script
You will have to use the transform.forward in your Update method like I mentioned.
In your setup, maybe I'd create a method 'CalculateMovementValue' that returns the moveValue from your inputbase, and you'd pass the transform of the character controller as a parameter
Can't help much atm, working atm.
How important is it to unregister callbacks to InputActionAsset during exiting playmode?
I don't use generated C# class, I reference asset directly
through inspector
I'm wondering how to work this with a mouse focused strategy/sim game. Like If I want to select a tile or a an ui button, would I have one script that checks what I clicked on and then call the "clicked" method on my target. Or do I need a different approach for ui and other gameobjects? For UI there seems to be the "OnScreenButton" script available.... but i think that is only intended for mobile stick+a/b button like stuff and you should not use it for other ui elements. Implementing IPointerDownHandler etc. seems to be the new input way for ui stuff, it wouldn't work on tiles/gameobjects right?
IPointerDownHandler etc are the preferred approaches. They will work nicely with UI elements blocking them etc
And yes they work for non-ui
For tilemaps there will be an extra step of determining which tile you clicked on inside the OnPointerDown.
{// Get the current mouse cursor position in screen space
Vector2 mousePosition = eventData.position;
// Convert the mouse position from screen space to world space
Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition);
// Convert the world position to a cell position in the tilemap
Vector3Int cellPosition = tilemap.WorldToCell(worldPosition);```
like that right
as a script on the tilemap
- tilemap.GetTile(cellPosition);
Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition);
not this
eventData contains the world position in it
you don't want/need to calculate it yourself
So you can just do this directly:
Vector3Int cellPosition = tilemap.WorldToCell(eventData.worldPosition);```
aaah how do i copy from this mouse over ? 😄
Vector2 worldPosition = eventData.pointerPressRaycast.worldPosition;```
oh sorry:
Vector3 worldPosition = eventData.pointerCurrentRaycast.worldPosition;```
then:
Vector3Int cellPosition = tilemap.WorldToCell(worldPosition);```
the collider on the tilemap doesn't seem to work correctly but it is registering the click so thank you!
Does anyone have an idea of how did they do warthunders instructor? Did they use PID controlers?
hi, for some reason the UI is not changing based on the D-Pad input some times, is this a known bug or what ?
here's a video of me pressing the D-Pad to move through my UI on a DS4 controller, even tho the Input Debugger shows that i'm pressing the D-Pad down it does not affect the UI some times, having to press up to 3 times so the UI can change the navigation properly
on joystick navigation i don't have this issue at all
I think you just need to uncheck simulated
That’s already been solved
This has absolutely nothing to do with unity, but by chance could you dm me how you make obs make that screen effect
how do I return which number I pressed with code?
is there anything like context.button?
You should be able to do this. Autocomplete shows the following:
UnityEngine.InputSystem.InputAction.CallbackContext context;
var pressedNumber = context.action.bindingMask.Value.path;
All you need is to attach an event handler to your Switch action.
do I use var or int or string?
It's a string, but it doesn't matter. I use var so I don't need to worry about type declarations.
Shot tutorial on how to get the Oculus animated hands in action based vr rigs in Unity
I got the input system working with VR hand animations today lol
it was fun
Hello!
I am trying to use the new Input System. I plugged in a Gamepad and Unity recognised it as a USB Joystick. I can navigate through the UI with it, but when i press Button 2[USB Joystick] on a UI Button nothing happens
In the DefaultInputActions i added a new binding for the Click action, but with no success
Did I miss something? Any tips on what should I try?
Has anybody done any dev work with the steam deck? I'm trying to figure out the axes of the RT and LT triggers. They're working fine with an Xbox controller in windows.
Is there any way i can make certain buttons happen regardless of if a player has joined with a Player Input Manager?
anyone
For anyone with the same problem. I solved it by adding a new binding to the 'Submit' action instead of the 'Click' action
How can I do a charge up with the new input system? I'm using unity events and I want to know how I can record how long I'm holding down a button to charge an attack
start a timer when you first press the button, stop it (and check the value) when you release
there are timers in unity?
how would i use a timer?
i was just thinking of like increasing a value while its held down, and when its released you check that value
by "timer" I just mean a float variable that you increment each frame with Time.deltaTime
i see, what about if i want something that automatically releases after a set amount of time?
so like if im charging a railgun shot that has a chargeup time of 2 sceonds
then you check if the timer >= 2 and fire it
None of this is really input system related
the input system will tell you when the button is pressed and released
the rest is up to you
isnt there a state for held?
im using callback context
theres like ctx.performed and canceledd
theres one for held down
sure, you can check if it's currently held. But that's only useful if you're polling input in Update
so it depends on if you're using event-based input handling, or polling.
i believe im using event based input handling?
This screensahot doesn't really tell us much. Though it would be helpful to see the expansion of the Events thing
but your code could literally be doing anything
how about this?
so yeah looks like you're using events
in this case you need to either:
- start a coroutine when the button is pressed and stop it when released
- set a bool true (isChargingWeapon) and timer to 0 when the button is pressed, update the timer in Update, and handle the release when the button is released
awesome, thanks. would i use update or fixed update? because when i pause, it switches input action maps
and same when i die
I have a little red box that moves when you touch it, and I have it in a on screenstick mapped to the left stick
how do I get this into a script
i have the basic move
mapped to wasd
i'm guessing that means you didn't bother reading what i said past linking this channel. you may also want to see #854851968446365696 for how to correctly ask a question
Ok so i set all the values correctly and unable to find the 2D Vector composite any help ?
remember how i already told you it's the up/down/left/right one in the options when you go to add a binding?
No it doesnt come up so i can add the 2D value composite
show what options you do have then
I cant when i tab into my snipping tool i cant see the options are we able to go in a call you do not have to speak its just so i can show you?
set a delay with the snipping tool
remember how i told you twice already that it's the up/down/left/right one? (this makes three now)
alright sorry you didnt have to be like that im new to this stuff like give me a bit im new to unity
It’s ok I will use another discord
that wasn't directed at you. the other person deleted their message after i had sent that
Hi, I'm experiencing a massive performance drop when moving after I ported my project to the new input system, has anyone had a similar experience?
How can I update to version 1.4 / 1.5? Do I need to get it through GitHub or something?
Was looking a thread (https://forum.unity.com/threads/is-it-possible-to-rebind-mouse-scrollwheel-on-new-input-system.1100518/), and saw that DeltaControl is only available in 1.4+
I have not, but you can use the profiler to see what's going on
Is this a known issue or maybe a bug in my unity version? I have this very simple code and everything works fine for the first if. But then if i press the key it doesnt get triggered. I have to spam the key rlly fast to get single or multiple triggers and the output. I also tried it with the newer input system and i have the same result but i have no idea why. Code:
private void OnTriggerStay(Collider other)
{
if(other.transform.gameObject.transform.tag == "climbObject")
{
//until here everything is fine
if (Input.GetKeyDown(KeyCode.Y))
{
Debug.Log("test");
}
}
}```
You should not be reading input here
Reading input should only happen in Update
it was just unity being unity. Rebaked occlusion culling and that fixed my issues
weird that it seemed so connected to my movement though
This is what you should do:
bool inClimb = false;
private void OnTriggerEnter(Collider other)
{
if(other.transform.tag == "climbObject")
{
inClimb = true;
}
}
private void OnTriggerExit(Collider other)
{
if(other.transform.tag == "climbObject")
{
inClimb = false;
}
}
void Update() {
if (inClimb && Input.GetKeyDown(KeyCode.Y))
{
Debug.Log("test");
}
}```
but has that sth to do with how OnTriggerStay works? Because in a video everything works fine
yes it has to do with OnTriggerStay
OnTriggerStay runs during the physics simulation
the physics simulation does not run every frame
so it is liable to skip input
ok makes sense, ty ❤️
Hello, not sure if this is the right channel to ask this, but does anyone know if the XR Interaction Toolkit can be made to work with the Valve Index controllers? I'm trying to complete Learn.Unity's VR course and they claim that the toolkit works with Valve Index, but that doesn't seem to be the case anymore as the Grip sensitivity seems to be just true/false ( as if the grip was simply a button )
(also if there's a better/proper place to ask this on the server, where is that?)
hello! I'm having an issue with writing a custom interaction detecting a full 360 of a joystick. The custom interaction code is always reading the context Vector2 as <0,0>, but a separate movement action is working just fine with the same bindings.
If you have custom code, you should post it.
Is it normal when i generating c# file after it this file has compiler errors?
the input system works in the editor but not in the build
I have already tried googling for a solution but they dont work
I have tried
- setting Active Input Handling to Both
- setting the Architecture to x86
- resetting playerprefs
I tried building it in an android and it works fine
Hi there, I'm quite new to the new input system, and am trying to find an implementation for a drag interaction. I've followed this thread: https://forum.unity.com/threads/implement-a-mouse-drag-composite.807906/
It works wonders on PC with the mouse, but the isPressed value mentioned in the script is never true for touch input. Is there another value I could check to see if I'm currently pressing down on a touchscreen?
late reply, but youre right! here's the custom interaction script, and the action map https://gdl.space/osorigoxur.cs
i still have no idea why reading the value as a Vector2 is resulting in <0,0>. the only thing i could think of is if the Move action is eating it, but if i delete that completely and only have the Spin action have WASD/joystick bindings, its still <0,0>
What happens if you remove one of the bindings
still 0,0 every input with just WASD bound to Spin
its weird in that its correctly calling IInputInteraction.Process when the input is changed, but its 0
Can you show your code
Shouldn't you ReadValue from the context directly
You're calling ReadValue on the action
Or even from the control?
See example here:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.5/manual/Interactions.html#writing-custom-interactions
im running into an issue with a cursor sprite ive got following the mouse jittering
im using URP on Unity 2021.3.20f1
it doesnt come across as violent in video as opposed to just ingame but issue still visible
the camera moves in late update and sets itself to the player rigidbody transform
the cursor moves in update and sets itself to ScreenToWorldPoint(Input.mousePosition)
using Pixel Perfect Camera also
no lerping anywhere, and doesnt seem to get better if i swap which update each of them do stuff in
i am mainly just having difficulty narrowing this down as it could be any of:
- Pixel perfect camera messing up with rounding
- Pixel perfect camera messing up Input.MousePosition
- ScreenToWorldPoint not being fully correct
- Code to set position in wrong Update function
The camera moves after you set the cursor position, so it ends up in a different place on the screen?
perhaps, however I'd expect consistent behaviour rather than seemingly random jitters
With a good time between each like 400ms maybe
why? Your camera can move different distances based on the frame rate and speed of the player
The camera sets itself to the position of the rigidbody which is moving with the physics
Ah that would make sense why it's not constant jittering
and then I suppose yes I then want the cursor in late update and camera before it somehow prob in fixed update
Yeah that all makes sense will try it tommorow
Thanks for the suggestions
here's the complete and correct interaction code for a 360 input from before btw, in case anyone ever searches for this: https://gdl.space/ajiqubupoh.cs
(figured hard coding joystick quadrants was safest bc idk how this layer handles GC etc.)
The Input system doesn't work in my standalone build but it works perfectly in the editor. I'm gradually losing my sanity trying to find a solution for this. Please help me!
Hey Guys!
Can't assign InputActionReference to fields of InputSystemUIModule
I am making a Co-op game and looking at implementing full controller remapping with the new unity input system. In order to do this I am cloning the input action asset with Instantiate() so that each player can have there own controls.
I then have to assign this new copy to the PlayerInput, which is working fine for me and also the InputSystemUIModule, which is where my problem is.
Currently, when I assign the new clone to the ActionAsset field, it resets all of the bindings. (Point, Left Click, Move ect). To work around this I get the InputActionReferences to the actions I want to re-assign and then set the field to the InputActionReference.
However, rather than correctly set it, it just remains as none. I get no errors or debug messages, and I am fairly sure that the InputActionReference I have is correct. The only other information I have is that when attempting to set the values' through the inspector, the only value available is none.
Here is the code I am using:
newInputAsset = Instantiate(inputAsset);
InputAction moveAction = inputActionAsset.FindActionMap("Player").FindAction("Menu Move");
InputSystemUIModule uiInputModule = GetComponentInChildren<InputSystemUIModule>();
uiInputModule.move = InputActionReference.Create(moveAction);
I'm on unity Version 2020.3 and input system version 1.1! Does anyone know how I might solve this problem, or circumvent it somehow? Any help much appreciated.
this hasnt worked
Camera moves in Update or FixedUpdate
Cursor moves in LateUpdate
still jitters
When using the new input system, does anyone know if the pointer needs to be over a UI element to trigger the UI inputs like "click" or "middle click" etc or if these are performed every time whenever the e.g. left mouse button is clicked?
Like, would I need to add new input actions for "left click" etc when not dealing with UI elements?
You need to hook into the clicks if you want to use them outside of the UI, because the UI is using its own EventSystem to default work with inputs
I don't necessarily "need to", I was just wondering if any left click would be registered as a click. But I get the impression that they don't? In that case, if I make a new action that triggers whenever the LMB is clicked, will that trigger too whenever I use the UI click?
Thanks for your reply! 🙂
Well the event system will get the click too, but do nothing if not over an UI element. And yes, it will run both events if you click, so you gotta check with some bool if your UI is open our use the event system to check against its bool IsOverGameObject, so you know its hovering a UI element
Alright, thanks! 🙂 And what is a UI element is determined by if it's on the UI layer?
If its inside a canvas holding a graphics raycaster I assume
Ooh, okay!
Hi, how would I go about getting references to each individual binding in this group? (for rebinding purposes)
solved
can you use the input system on 2 different objects?
Really vague question, but yes you can do pretty much anything you want
I'm just trying to figure out why my controller isn't working on object2. I guess the mouse works for it but the controller doesn't. The controller does work on object1, so I don't think it is a controller issue
here is the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Sight : MonoBehaviour
{
Vector2 lookVector;
[SerializeField] float sightDist;
// Start is called before the first frame update
void Awake()
{
}
// Update is called once per frame
void FixedUpdate()
{
transform.localPosition = new Vector2(lookVector.x * sightDist, lookVector.y * sightDist);
}
private void OnLook(InputValue value)
{
lookVector = value.Get<Vector2>();
lookVector.Normalize();
}
}
So I pulled the values from my main movement script and it seems to be working now.
How are you calling OnLook
Seems like anytime I change the name/input of an action in the PlayerInput manager, it breaks my code. It seems like it's trying to update/compile the PlayerInput script but it takes forever. Anyone see this before? Code was working fine before I changed the name of the action. Compiling seems to be locked up in the background task tab
Nvm figured it out - I had the PlayerInput asset in a different folder so when I made changes it created a new PlayerInput script in that folder and clashed with the old script in my script folder
@austere grotto This is how I was calling it https://hatebin.com/gqnrjyyjdq
Now I am calling it in an input class essentially then referencing the values from there, that seems to work.
There's nothing in this code that calls it at all
A callback like that I would expect to be used with the PlayerInput component
Using the new input system it gets called via a sendmessage
Not the way that code was set up it doesn't
right and I had one on my sight
Ok well you confused two approaches then
playerInputs = new PlayerInputs()
This is a totally different thing
this is my currently working classes https://hatebin.com/aqrqkswcid
You have a bunch of pointless code here
PlayerInputs playerInputs;
This whole variable is not doing anything
The real work is being done by the separate component you attached to your GameObject
Called PlayerInput
right, i thought I had to call the enable and disable functions for it to work, I must have misunderstood
You're confused
Because you have named your input action asset similarly
But your "PlayerInputs" and the "PlayerInput" component are two separate things
yes i understand that
You have the beginnings of a different approach to input handling in your code but ultimately it's not being used and can just be removed
ok, When I was learning about the input system i must have gotten confused
so I will just use the send message and call the On functions
Yes it's confusing because there are many different ways to use the system
yeah i noticed that
You've landed somewhere between two ways. Your code will still work if you remove this whole variable:
PlayerInputs playerInputs;
thank you for the help
Having some controller issues. The controller is seen everywhere but when I play the game in unity. I've tried restarting unity, restarting the controller, restarting my PC, deleting and reconnecting the controller. Search the internet, there seems to be issues with the switch controller, but I am using an XboxOne controller. Any ideas?
hi, I am trying to bind a 2D vector composite to a controller. I have a rebind key component which handles this for me, the only thing I'm struggling with is getting the correct path.
Whenever I perform the interactive binding, I get the following paths for the controller: <Gamepad>/leftStick/y, but what I'm looking for is <Gamepad>/leftStick/up.
Is there a way of getting the up/left/down/right paths instead of just x/y?
Is there a way to prevent the Delta [Mouse] input from taking cursor-locking into account? When I lock the cursor using Cursor.lockState = CursorLockMode.Locked and then move the mouse, producing a non-zero delta, it seems it applies the movement of the mouse from its position to the center of the screen plus whatever actual mouse movement I did
In this example I moved my mouse around without locking it to the center of the screen, and enabled/disabled camera movement based on the delta value - worked fine. Once I started locking the cursor though, you can see the camera snap
The values printed in the Console are just the values being given by mouseDeltaAction.ReadValue<Vector2>(); when I move the mouse after locking the cursor, you can see it emit a very large vector in comparison to the usual small ones
Can you show your code and your input action setup? It shouldn't do that
Sure. The code in my main project is too complex to share easily, but I was able to reproduce the issue in a minimal project - uploading that to my Google Drive now, and then I'll have a link...
I can also post the script from the minimal project + a screenshot of the input action setup
Here is the minimal script: https://gist.github.com/8abadd0dd7e2a4dedeee7e6a5a569632
And attached is a screenshot of the Input Action asset
And here is the whole minimal project example https://drive.google.com/file/d/1GfAI69o7w2TRyHDHfbegfZuL3dwyFy2b/view?usp=sharing
I suppose it's possible I'm just going about implementing this the wrong way? But at the moment, I can't think of what the "right" way to do it would be, if that's the case...
Has anyone else experienced the new input system not working on a standalone build?
this is all i need for a hold a key to do things system ryt?
depends what you mean by "hold"
If you mean - an action is triggered one time after holding the button for n seconds, then yes
If you mean - continuously do something while the button is held, then no
Hi guys, does anyone know how to set up the "stepcounter" in the input system. I tried this about a week ago, but it doesn't work
This should work(The swiping right) or can anyone detect an issue?Or is that even the right InputAction?
https://paste.ofcode.org/QdatCMuspJwRnEybPS5sxc
Anyone know why i alsways have an input put in at exactly trhe image values, i have disconected everything and it still doesent work, it has also tried being transfered over to another pc and when it is there it works. In any other game i play it never happens and when i build it still happen please help its starting to get annoying XD
bluetooth controller maybe?
Definitely sounds like a connected joystick or gamepad
Using this code, I run PlayMode in Simulation (not Game) and this prints 2 when clicking with mouse left. Only when I switch tabs to Game and back to Simulation does it print 1.
private void OnEnable()
{
TouchSimulation.Enable();
EnhancedTouchSupport.Enable();
}
private void OnDisable()
{
TouchSimulation.Disable();
EnhancedTouchSupport.Disable();
}
private void Update()
{
Debug.Log(EnhancedTouch.Touch.activeFingers.Count) // PRINTS 2
}```
hey yall, im following along with this tutorial and the mouse movement script provided has inverted the up and down, ive been trying to fix it by changing stuff like the xrotation and yrotation but cant seem to find it, any help would be appreciated
i figured it out
for anyone wondering, change the xRotation -= yRotation to xRotation += yRotation
I am using the new input system and I have a pick up and drop event. Both are on the same button currently because it feels intuitive however I want the option to later split it in seperate buttons.
Because they are bound to the same button, if I press it, it will pick up and immediately drop whatever I picked up. Which is kinda logical. What is the best way to solve this?
Please ping or reply me so I get a notification
How can I make it so these events only happen once at a time, for example if I when I click normally and am holdings shift at the same time, Both SelectShift and Select occur and I only want SelectShift to fire
hello folks, got a bit of an issue, I have a movement script in 3d space (up, down, left right, forwards, backwards) and when setting up control scheme for both controller and keyboard, only the controller, works, as soon as I remove the controller, keyboard works, not sure what is the issue exactly, since afaik, it should just work
The simplest way is to separate actions for shift and the button. Then in your code for the button do this:
if (shiftAction.IsPressed()) {
// do shift thing
}
else {
// do non-shift thing
}```
This would be instead of trying to use the Button With One Modifier composite, which is not that well thought out.
Figured this out, if anyone was wondering. Had to add these scripting definition symbol checks for DEVICE_SIMULATOR and deactivate TouchSimulation. TouchSimulation was adding a second touchscreen on top of my Simulator touchscreen, which was causing EnhancedTouch.Touch.activeFingers to have 2x index == 0 fingers.
private void OnEnable()
{
#if !DEVICE_SIMULATOR && UNITY_EDITOR
TouchSimulation.Enable();
#endif
EnhancedTouchSupport.Enable();
}
private void OnDisable()
{
#if !DEVICE_SIMULATOR && UNITY_EDITOR
TouchSimulation.Disable();
#endif
EnhancedTouchSupport.Disable();
}```
Does anyone know if I can put the same input system on multiple different objects? I want the player to interact with a door and npc but I want the input system on the door and npc because right now it’s on the player. Is there any way to go about this?
Wdym by "put the input system" on different objects?
What you want to do doesn't need input system on the door or npc. You need to do a Raycast and hit the door and NPC and have those implement an interface called IInteractable (which you should create). Both NPC and Door script should have a method named Interact() that do different things, because adding the interface to the class composition will force those scripts to have and Interact() method. Then the Raycast should look for the IInteractable component and if found, do Interact()
public interface IInteractable
{
void Interact();
}``````cs
public class Door : MonoBehaviour, IInteractable
{
public void Interact()
{
OpenOrClose();
}
}```
I wanna put it on multiple objects
Even for a 2D game?
Yes. Physics2D.Raycast, Physics2D.BoxCast, latest active IInteractable OnCollisionStay2D, etc...
Haven’t done much raycasting so I’ll have to play with it
Hi, I'm trying to teleport the player, which has a characterController, when a button is pressed by setting transform.position, but I think it's being overridden by a characterController.Move() call that I make every update, so it isn't teleporting. I'm able to fix it by using Move() and IgnoreLayerCollisions() to teleport, but I feel like this isn't a perfect solution as there may be more layers in the future that it has to avoid. Is there any way I can make the InputAction that teleports the player occur later, like around the same time as LateUpdate?
put what
what do you mean by "input system" specifically?
Are you talking about the PlayerInput component?
An instance of the generated C# class?
what?
two options:
- disable the CC before the teleport, perform the teleport, then enable the CC
- call Physics.SyncTransforms() right after the teleport
ah SyncTransforms sounds perfect! thanks 🙂
I’m talking about the player input
I have no idea why you would want to put a PlayerInput component on a door
that makes little sense.
You can certainly throw that component on any object you want, but it is intended to represent a human player, and makes little sense on anything other than a character or object controlled by a human player.
My dialogue system and changing level system depends on the input system and I would want it on the door and npc so it only is on the scene when I’m the place where the npc and door are
that still doesn't explain why it goes on the door
Because you need to be near the door and interact with it to change levels
that doesn't mean you need an input handler on the door
you have an input handler on the player. The player detects when it's near the door and then opens it.
Has anyone made EnhancedTouch work with DeviceSimulator? I'm getting Touch ScreenPositions of Infinity, -Infinity
Looks like it's not compatible
This rotator isn't following the player it just stays at 0,0
I have no idea why it is doing this
because you gave it a Rigidbody2D
it follows the whims of the physics engine now, not the hierarchy
ok, how so I just have to make it rotate without a rigid body?
I don't see why you added a Rigidbody
to make it rotate based on mouse position
what does that have to do with Rigidbodies
Rigidbodies are for physics
not mouse input