#🖱️┃input-system
1 messages · Page 43 of 1
Check the value in the inspector
Is your code actually running? Any errors im console?
Is the rigidbody kinematic?
What keys are you pressing
private void FixedUpdate(){
Vector3 velocity = rb.velocity;
//this preserves the existing Y velocity from gravity
velocity.x = xInput * speed;
rb.velocity = velocity;
}
is there a way to get the text on a rich text input without the markdown stuff
likeHello<i>World</i>would result in HelloWorldeven tho its being displayed as italic
or is there a way to set a word's color without the use of <color=#xxxxxx></color>
welp found it
Hi guys, how do I detect joystick released? I mean how to detect when my thumb left the joystick
currently my problem is, say I move the joystick to some value like (0.5, 0.6), and then I release it, and the input value goes back to around 0 with the joystick reset
I want to keep the last input value as (0.5, 0.6) after my thumb left
please help😫
(stick deadzone doesnt work, the last input value just goes back to min deadzone instead of 0)
Make sure you're either polling input every frame or also listening for the canceled event/phase
The callback for canceled will contain the return to 0 values
You will have to cache that value yourself.
im not sure what this input system is or what an input manager is for unity, I want to create an input that activates when I press the right mouse bottom down called aim. Anyone know how to create this so I can use it in my code, I want to add the action to my player.
Fixed. Thanks @rough ledge
Can i somehow use two joysticks with different bindings using this new inputsystem maybe DevID? I'm using the traditional one, GetKey.. Works fine, but my joysticks are same brand same model, and unity likes to mix them up every once in awhile when re-opening project.
guys is there a way I can implement gamepad to my game without new input system
https://docs.unity3d.com/Manual/class-InputManager.html
You can map it in the old input system via the Joystick button #.
I'm having a weird problem with input
Excuse the picture of a screen, I'm on a school computer
So basically the jump input doesn't register if I'm holding two directional keys
Unless it's up and right
I had to come here and ask because I have no idea how to google this
I don't think it's a problem with the code as it never even reaches the OnJump method under those conditions
That shouldn't a problem, it definitely works:
So either it is the code, or there's something funky with that version of the Input Manager you're using. Though I'm more inclined to think it's code related.
I don't think it's the code
I put a print statement in the method and it doesn't print it
Meaning it never reaches that part of the code to begin with
Is there any way to check what version I'm on?
The package in the package manager will tell you. You can also update it if there's one available.
It's on 1.0.2
Yep, same. I have no issues with running and jumping. 🤔
Always a possibility of a keybaord rollover issue
but never heard of that with only 2 keys
are you pressing other keys too at the same time?
No
Try pressing the two directional keys and the jump key at the same time
see if they show up properly here
If not - it's a keyboard rollover issue
Oh here's a simpler page for the same thing
ok
Every time i try to make an Input Action Asset this error pops up. i did try to Google it but did not understand that much
and this
Have you tried restarting Unity?
seems like a bug
yeah i have
we are a group of 3 people and i am the only one i the collab that have this problem
Hey guys! I've got a gyroscope and a mouselook on the same file, they both work fine but when I move with my mouse once I take it off (in this case my finger) it snaps to where it was before I moved it
Any one have a clue of what I could do?
Not 100% sure what you're asking but (0, 0, 0, 0) is not a valid Quaternion
Use Quaternion.identity
Anyone know if installing Input System can break code that doesn't interact with it? Because, after switching to it from AirConsole some of my code no longer work despite not using the Input System or AirConsole at all. It's really frustrating
Any errors in console?
Does your code use the Unity event system at all?
how do i get the current device of the player input?
when i use gamepad.current it checks for all devices being pressed when a player joins.
I figured it out in case someone else might need it: Instead of using gamepad.current use PlayerInput.devices[0]; to get the current device on the player input. My understanding is that it is an array in case you want to have multiple devices connected to one player.
What is the Unity event system?
unity event system is for ui
if you have a canvas in your scene it will spawn in automatically
if you click it and youre using the new input system it asks you if you want to switch over to the new input system. just hit yes
Oh that, I think I deleted it as it didn't like not having the old system
go ahead and add it again but click it and convert it to the new input system
what is it for?
is there any example code for 😦 3rd person shooter
something like the last of us
using cinemachine :c
there are plenty of tutorials for that on YouTube
do action performed and action canceled have to be checked every frame? If yes, what's the use for the event actions if you are checking them every frame anyways?
No you can use events
The InputAction have events you can subscribe to
that's what I'm trying to do, but for whatever reason that never changes my value to true
Maybe explain a little about your setup and share some code?
this is inside my playercontroller in Start():
inputManager.CrouchPerformed += ctx => isHoldingCrouch = true;
inputManager.CrouchCanceled += ctx => isHoldingCrouch = false;
this is the action in the inputmanager:
public event Action<InputAction.CallbackContext> CrouchPerformed;
public event Action<InputAction.CallbackContext> CrouchCanceled;
...
public void CrouchingPerformedButton()
{
playerControls.Player.Crouch.performed += CrouchPerformed;
}
public void CrouchingCanceledButton()
{
playerControls.Player.Crouch.canceled += CrouchCanceled;
}
that's how it's supposed to work, is it not?
I'm not actually sure you can add events to other events like that.. though maybe you can
But... How are you calling those functions?
i'm not, they are in the inputmanager
Can anyone help a newbie to understand why my Unity game scene is not visible in HTC Vive headset? The view from the headset is just black (or white if I reset the headset and it has not yet gone to standby). The headset connection is fine (connection in Vive vireless and steamvr shows ok and white screen after resetting it indicates that it's able to function) but from Unity side I have almost no experience and I suspect the problem is there. I have read the docs but there are different guides for different versions and I keep getting stuck by ending up in searching for an item in my Unity menu that does not exist or the result simply does not work like described.
I have done:
- new VR project (Unity 2021.1.3)
- new input system + gamepad controls
- added one cube to fly it around in vr
- added c# script to move the cube (and it moves ok in computer screen)
- checked that in project settings xr plugin management the Mock HMD Loader is ticked and 'initialize xr on startup' is also ticked.
- read Unity manual 2021.1 about xr getting started and made sure GameObject > XR > Add XR Rig is done (in my case it offered to convert main camera to xr rig and did it. The main camera is now placed: xr rig > camera offset > main camera). No error messages.
- all looks good on computer screen and can move the cube but no image in the headset and it soon goes to sleep because it thinks it's not in use.
What am I missing ?
it does work well if I call them in the update function inside the playercontroller, but that seems a bit useless for the events
You subscribe your listeners to the inout actions events directly
Or maybe your way works but you'd have to actually run the code that subscribes your input manager's own events to the imput actions events
Because right now I don't think that code is even running
do you know a better way of making a button work with hold?
I want to implement hold to crouch
do you know how to set them up?
normally you just do this:
playerControls.Player.Crouch.started += ctx => isHoldingCrouch = true;
playerControls.Player.Crouch.canceled += ctx => isHoldingCrouch = false;
But if you want this input manager in the middle you could either have the input manager expose playerControls publically so other scripts can subscribe to it, or else provide public methods to subscribe
great, I think I'm nearly there. But what about the functions inside the inputmanager? ```csharp
public void CrouchingPerformedButton()
{
playerControls.Player.Crouch.performed += CrouchPerformed;
}
should the CrouchPerformed stay there like that?
My personal preference is to not use the generated C# code and instead use an InputActionAsset directly, with InputActionReference fields on my various scripts for them to subscribe to directly.
those functions don't do anything and are never called as far as I know
o I see.
so you are doing
playerControls.Player.XXX.started += ctx => XXX;
everywhere?
nope I'm doing this^
but both ways work
Yep. You just use an InputActionReference in your scripts as needed:
[SerializeField]
InputActionReference crouchAction;
void OnEnable() {
crouchAction.action.started += ...;
}
and assign through inspector?
exactly
then I have a separate class that has a reference to the asset itself but that's just for managing when various action maps are enabled/disabled etc..
InputActionAsset input;
void OnEnable() {
input.Enable();
}``` etc
Yeah I find this way to be the cleanest/most maintainable
awesome, thank you so much ;D
np
So this is using the UnityEngine.InputSystem so I think its related to this?
I am trying to move a sphere around and used the tutorial for making a roll-a-ball game thingy, https://www.youtube.com/watch?v=QIShB1p_Gls&t=243s ^ This one to be exact, I made the code the exact same but im still not getting any movement. Anyone know the problem?
In this tutorial, you’ll:
- Understand components and how to add them to your objects
- Understand what the rigidbody and Collider components are and how they function on an object
- Be able to use package manager and know how to add packages
- Understand what is the Input System is and how to use PlayerInput on a basic GameObject
- Creating a ...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
private Rigidbody rb;
private float movementX;
private float movementY;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
void OnMove(InputValue movementValue)
{
Vector2 movementVector = movementValue.Get<Vector2>();
movementX = movementVector.x;
movementY = movementVector.y;
}
void FixedUpdate()
{
Vector3 movement = new Vector3(movementX, 0.0f, movementY);
rb.AddForce(movement);
}
}
@austere grotto Hi. Do you happen to know how to unsubscribe from the inputs?
[SerializeField]
InputActionReference crouchAction;
void HandleCrouch(InputAction.CallbackContext context) {
// blah
}
void OnEnable() {
crouchAction.action.started += HandleCrouch;
}
void OnDisable() {
crouchAction.action.started -= HandleCrouch;
}
I am currently doing this; playerLogic.crouchAction.action.performed += ctx => Crouch();. Is there a way to easily convert that into your code without making it that large? I have a lot of input actions and need to unsubscribe from all of them
you can't use lambdas - or if you do use lambdas you must save them to a variable:
[SerializeField]
InputActionReference crouchAction;
Action<InputAction.CallbackContext> crouchHandler;
void OnEnable() {
crouchHandler = ctx => Crouch();
crouchAction.action.started += crouchHandler;
}
void OnDisable() {
crouchAction.action.started -= crouchHandler;
}```
Okay will try
Works like a charm! Many thanks 🙂
Hi I ha a problem with the input system
I am using the default Input Action map generated by unity which has a Move action that gets input from WASD, Arrow Keys and the left stick on a controller. If the controller is connected the OnMove event is fired twice: first with the input on the keyboard and then with the input on the controller, this if I move with the keyboard (say input (0, 1))it immediately gets cancelled by the input on the controller (which is (0, 0)), on the other hand if I move with the controller I first receive a (0, 0) value which resets the player rotation and then I receive the controller's value making movement really wonky. If I disable either schema the other one works fine. So how can I keep both bindings without having this strange behavior (BTW I haven't touched unity's default bindings for Move).
Hi there! I have a problem with the input system editor and it does not show any properties! may I have some help?
Hello Everyone,
Might be in the wrong channel but my buddy and I are working on an Archery System (3rd Person) that uses mouse location to screen. We are also using cinemachine with an Aiming Camera attachment.
The concept is:
Rotation with Mouse Movement
onClick turns on Reticle and switches to Aim Camera (Zooms over character shoulder)
While holding mouse down, player pulls back on mouse causing bow string to be pulled backward
On mouse up, Arrow releases with applied force * charged multiplier
Mouse Location must reset after release
The Problem:
After getting the system set up, on the drag pull we experience our camera dumping viewpoint to the floor(as we pull mouse backward)
This is the only headache we have but it's a big one. Has anyone tried something like this?
Thanks for any help
I suspect there are compiles errors, go check the console
@stone crystal #archived-unitytips is not for questions. Your issue is a basic input system issue where your project is configured to use the new input system and yet you have some code using the old one. Choose to use either one or the other. You can switch your project to use both, but it's not advised.
@fair roost holy moly, for some reason I had to uninstall a thing called vJoy on my computer and it finally worked after that
??? insanely weird fix?
Hi guys. Do you know why I cannot make a binding to mouse delta
Somehow
I cant bind the path option to mouse delta
does BOLT use the new input system?
op nvm
just had to use the new input system library on the setup
hey guys im having a problem with unity's new input system, my controller works if it is connected via a lead, but it only works via bluetooth if steam is not running.
as soon as steam is running it just inputs random buttons really fast and just goes crazy, i cant figure out what is going on
has anybody else had this problem?
ds4
are you launchign your game through Steam?
Or launching Unity through steam or something
in the unity editor and in a windows build
I've seen crazier stuff. I launch Epic Games Launcher through Steam sometimes so that Steam can properly configure my DS4 controller to work over my Steam Link
jeez
Yeah I just have the 1 that I think I paid ... $20 for?
maybe 10
don't remember
Haha wtf they're on Amazon for $160 now
Is that you @west oracle selling your stockpile
lol nope i'm keepin em
way too useful for deploying tradeshow shit
I ended up in elevator with Gabe's brother at GDC one year and had a talk about wtf that was about
interesting
#just-sf-bayarea-things
found some others with my controller issue, doesnt seem like there is a fix for it https://forum.unity.com/threads/buggy-input-from-bluetooth-ps4-controllers.898703/ 😦
disabling playstation controller support in steam and resetting the controller seems to have fixed it
I can't seem to see any input devices with the new input system
When I press the + button, nothing happens
Project Settings > Input System Package > Supported Devices > "List is Empty"
If I create an inputactions, it says <No Binding> and the properties pane is blank
If I add a Control Scheme, it says "List is Empty"
My Google-fu has failed me on this one
"All Devices" dropdown is grey-ed out
it's like I don't have anything connected
But clearly, I'm typing with a keyboard 🙂
Latest version of unity, new project, installed New Input System and Cinemachine,
Went into Input System Package and clicked the 'Create Asset' button
Tried to create a new inputactions, and this is result ^
Looks like @ashen arrow has the same thing
Me too!
Same thing
It looks like there's a bug here
This kinda thing happens every time I try to learn stuff with Unity 🤨
I don't know whether I'm doing it wrong, or it's broken 😆
I've got a fix for my issue @thorny pike @ashen arrow
I had to uninstall vJoy. vJoy was causing an error, which caused the Input system to throw an exception, which stopped it seeing any devices
Platform: Windows Repro: 1. Install vJoy (http://vjoystick.sourceforge.net/site/) 2. Launch Unity 3. Observe error in console. ``` C...
It's a shame because there's actually been patches submitted, that haven't been accepted
https://github.com/Unity-Technologies/InputSystem/pull/949
https://github.com/Unity-Technologies/InputSystem/pull/1140
Tested with the Official Wii U Gamecube Controller Adapter. I also profiled memory usage in editor, since whilst working on this I did cause the editor to crash a few times due to introduced memory...
Issue: https://issuetracker.unity3d.com/issues/inputsystem-error-when-vjoy-is-installed
vJoy may produce NaN value that breaks the process of adding a device.
hey everyone im having a really weird issue with unitys new input system where keyboard input seems to be delayed by ~300ms.
Changing V sync settings fixed it for a brief moment and then it came back. I'm soooo confused. Has anyone experienced anything like this before?
Hello all,
I've been working my way into the new input system for days and now I'm stuck. Unfortunately, I can't find any examples for the use-case and this makes me think that I have chosen a completely wrong approach. I want to build a tower on a tile and then not exit the build mode when the player holds down shift. For this I created the actions on the image. Now I try to determine in the code from InputAction.CallbackContext whether shift was pressed when clicking the mouse or not. I could not see any difference so far. Also not in the debugger. I got a difference with ctx.ReadValue<float>(). However, only on the first click. From the second on it doesn't work anymore. 😦
Hm, I just found out that I get this information via ReadValue<float>. I just interpreted it the wrong way around. Also, you have to click shift again for the next mouse click and can't hold it down all the way. Can I set that you can keep shift pressed continuously?
@dense raven yup! i had to uninstall vjoy as well, I thought I said that in a msg but im sorry if I didn;t!
I can't even get .performed to fire
I hate about Unity, that most of my time is spent debugging why something doesn't work because every tutorial is subtly different to whatever you have
because Unity and all the projects are constantly changing
Like constantly
How is your input action configured and how are you listening to the event?
Unity adds a lot but only rarely does "old stuff" stop working unless it was beta/experimental
{
public CameraControls controls;
private void Awake()
{
controls = new CameraControls();
controls.Movement.RotateZoom.performed += ctx =>
{
Debug.Log(ctx.ReadValue<Vector2>());
};
Debug.Log("aa");
controls.Movement.Pan.performed += ctx =>
{
var delta = ctx.ReadValue<Vector2>();
Debug.Log(delta);
gameObject.transform.position = new Vector3(gameObject.transform.position.x + delta.x, gameObject.transform.position.x + delta.y, gameObject.transform.position.z);
};
}
}```
controls.Enable(); is missing
one of my pet peeves about the generated C# class files is that they don't start out enabled
One of several reasons I don't tend to use them
Ah, that's interesting, thanks
public void Jump(InputAction.CallbackContext context)
{
if(context.performed && IsGrounded())
{
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}
if(context.canceled && rb.velocity.y > 0f)
{
rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
}
}
``` heres my code and i get these errors when i try to jump.
Seems like you set up the space bar as a binding on your Move action which is a Vector2 action
e.g. it's not related to your code it's an issue with how you set up the InputActions
yeah i think its with the input actions but what do i do to fix it xD
show screenshot of your Move action
probably remove spacebar as a binding for it
that doesn't seem to make sense
exactly
lol
now it gives me no error
ty 🙂
actually it doesnt work for holding down the button to jump higher though
it just jumps the full way instead of the hold to jump higher
nvm i fixed it lol
how do i see if a input action is pressed?
you can just setup a Debug.Log(); to check the action
Good day folks! I have a weird issue that I do not understand: I am trying to use the new Input System with URP... and now my project seems to be broken.
I can't make my player jump or move around anymore. It happens once, then just stops working entirely. Input system was working until I added URP 8.3.1. Already crossposted in #archived-hdrp. I am using Input System 1.0.2. I have found, https://issuetracker.unity3d.com/issues/urp-errors-are-constantly-thrown-when-active-input-handling-is-set-to-input-system-package?page=1#comments, but I can not use the work-around listed as I can not found out where to set 'Active Input Handling' to 'Both'.
How to reproduce: 1. Create a new URP template project 2. Open Project Settings > Player > Active Input Handling and set it to...
Found where to set the input handling to Both.
Let's pray this workaround works. I am rather baffled as to why a rendering subsystem can affect the input system.
Nope. Did not work.
Are you seeing errors in your console?
What version of Unity and URP are you using ? 8.3.1 is quite old
I do not get errors @austere grotto, and 8.3.1 is what my Package Manager lists as available version.
Using Unity 2020.1.16f1, Input System 1.0.2, URP + Shader Graph 8.3.1.
I can upgrade to 2020.3 LTS latest and see if that fixes my issues.
https://i.gyazo.com/39c1f0ee4f1d14debbcc26754e09d784.png Screenshot of my package manager.
You should update and upgrade. But if you're not getting those errors why do you think setting input handling to both would solve your issue?
For the record the latest version of URP on LTS is 10.4.0
More likely I think something is just wrong with your input setup
With Unity I have had countless of times where a workaround mentioned that came with a bug or problem that was slightly related to my problem helped. Figured it may have helped here too, upgrading project as we speak.
Update complete, it did not work. And I am taking a wee break. Using 2020.3 latest LTS.
did you upgrade URP too?
Yep, URP and Shader Graph are on 10.4.0
I found something interesting, what I meant earlier with 'it does not work', and only lets me jump once etc: That's only visually the case. I can actually still rotate the player (the rotation values change in the inspector).
Still not sure what is wrong though, because I have a double jump mechanic implemented... and it does not allow me to double jump. Only single jump, and still after that jump is performed it won't let me jump again.
Real strange stuff is happening. Lmfao.
So here you can see the playerprefab sometimes 'walk in air'.... I don't get that because there's no collider that big that would prevent it from dropping down.
Most likely just an issue in your script that is controlling the player?
I have very little to work with here
That code did not change when I added URP/ShaderGraph.
That code worked fine before adding URP/ShaderGraph.
If you revert, does it work again as expected? Are you using version control?
So I am perplexed as to why adding URP/ShaderGraph has any influence on an Input System at all.
I am using version control but I want to use URP/ShaderGraph.
It shouldn't. But maybe you changed something and forgot about it
something that was minor in your mind
Hmm. Maybe the order in which I did was wrong
I first added ShaderGraph then URP.
I wasn't aware that ShaderGraph was related to URP, hence that order.
that shouldn't really matter
So you understand my confusion.
They actually both just depend on ScriptableRenderPipeline
I'm not you so of course I don't know exactly what happened - but I would check my version control diffs and see if anything changed in any scenes, prefabs or scripts
If it happens again when I add URP/ShaderGraph, I'll report back.
I'm somewhat convinced it will happen again because I made sure to have a working project before adding these packages.
Still quite frustrated that adding an official package broke my project.
Confirmed, the order mattered.
I did a git reset/clean, added the Universal RP package. Everything works as expected.
To verify if my order was messed up, I did the git reset/clean again... imported ShaderGraph first and then I had input issuess again.
There is a definite possibility 'something' of note was in the file diffs before git reeset/clean, but I was not able to quickly spot it.
And it's gamejam time, so I don't feel like spending my time on figuring out exactly why. I am happy I have a solution now though.
Before I forget, thank you for helping me rationally solve the issue @austere grotto 🙂 Much appreciated.
np though I can't say the result was not surprising to me
Usually when people have an issue like this it ends up with "oh yeah I forgot I changed that one little thing"
I'm a total noob with the input system, in fact i've never touched it before, so this is probably a really dumb question - any change someone could help clarify this error?
ArgumentException: Input Axis Mouse 2 is not setup.
To change the input settings use: Edit -> Settings -> Input
AimBehaviourBasic.Update () (at Assets/3rdPerson+Fly/Scripts/PlayerScripts/AimBehaviourBasic.cs:27)
I know it says right in it there what the problem is - but, like, it's confusing to me - is it looking for the axis, or mouse2, or.. what even
figured it out - I lost my project settings during a series of unfortunate events earlier, so input settings were all wrong
ahhhh nevermind, jumped the gun - same error after re-importing the settings
yeh, no idea what it wants.
help plz 😛
what does your code look like
in AimBehaviourBasic line 27
Sounds like this is the "old" input system you're talking about?
yessir, it is using the old input system, I temporarily just now installed the new system in an attempt to possibly fix, quickly realized its not anywhere near the same thing at all, and reverted
yeah it's not a "quick" fix, you'd have to rewrite basically all of your input handling code
yeah, after realizing my character controller was 100% incompatible, figured best to try and fix this axis mouse 2 thing
anyway what does the code look like?
But it just sounds like you need to set up an axis named "Mouse 2"
Though I'm curious if this is supposed to be a Button or an Axis
button I think based on the code, here it is
er wait one sec ill have to hatebin it
well! hatebin refuses to make a url
I did not write this btw, it is from an asset
my character controller is like, three assets mashed together, with a bunch of customizations
dirty, I know
Ok so it seems like in the inspector for this object you've put "Mouse 2" into the Aim Button field
is that the case?
yes sir
Ok so ... the real question is what button do you want to use to activate this thing?
well, it self populated
It seems to be the button for... aiming
Oh you know what, yeah, I want it on mouse1 not 2 - 1 is right mouse button eh
Well it's really going to depend on what you set up in the input manager
I think im starting to follow now though
yes exacto
it must have repopulated Mouse2/3 in the inspector when I re-imported the asset
but basically the string you put here in the inspector needs to exist as an axis in the Input Manager with the same name
Turns out that was the last error from my corruption - game loads and everything is functional again
phewwwwww
6-ish hours to re-jigger everything, lost libraries, player settings, mlapi, and my main player prefab
How can I check to make sure the player is holding the key down in the new input system for moving the character and once they release it stops
Use the started and canceled phases or events. Set a bool to true on started, and set it false on canceled
Alternatively, read the action's value every frame and check if it's > 0
Uh, not quite sure how to do that yet to be honest. I just started with the new input system today
I created the Input C# class from the input asset and created a new instance by using the new keyword
Do you have a reference to an InputAction?
ok
so get the input action you care about
what's it called?
controls.Movement.Player.performed += ctx => Debug.Log("Test"); I called it InputMaster
Your input action is called "Player"?
I have it Movement -> Player, Other
For now I have 2 objects I wanna control individually, I know that probably sounds weird
Ok on a basic level it would be something like this though:
bool playerHeldDown = false;
void OnEnable() {
InputAction playerAction = controls.Movement.Player;
playerAction.started += ctx -> playerHeldDown = true;
playerAction.canceled += ctx -> playerHeldDown = false;
}```
Ohhhh okay, I didn't know you could do started and canceled
Like that they were part of the actions. that makes more sense
Just wondering how to set up a toggle using the InputAction.CallbackContext?
Ah everyone is asleep 😛
I'm trying to translate the C# to visual script and make my character rotate in the direction I want
I'm almost there but I'm having a problem with making my character rotate properly
"First of all, we're checking if the character is moving by checking that the movement direction is not zero." I don't really know what this means. I'm pretty new to this so I'm trying to understand this as well.
I tried to apply it here but it's still not working and I don't know if I'm supposed to be using "If"
What is the graph tool you are using?
Script Graph, one built in unity, not bolt
I should be able to type a certain unity in and get the unit I want
It's been easier to translate C# into Visual. There are somethings I still don't understand
Unit*
I think you may want to do a rotation instead of the translation.
Transform rotate?
using the horizontal axis
and using the vertical axis for moving forwards and backwards
In my visual script, what would be my "movementDirection"? If I can find that out, I can solve my problem right now, maybe.
If I can grab that and then apply the "if" and "!=" to my visual script, I can solve a lot
brb
transform.rotation = transform.rotation * Quaternion.Euler(new Vector3(0f, h * speed * Time.deltaTime, 0f));
that may help fix that rotation issue
What is h?
Yeah
float speed = 10f;
float speedRot = 100f;
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.rotation = transform.rotation * Quaternion.Euler(new Vector3(0f, h * speedRot * Time.deltaTime, 0f));
transform.Translate(Vector3.forward * v * speed * Time.deltaTime);
OH!!
that may make more sense!
so that is working for me.. But i was wondering what kind of movement are you aiming for?
I want the movement to be like Dark Souls
oh ok!!!! lol
Bloodborne stuff like that
► ANIMATIONS
https://drive.google.com/drive/folders/1j2HicZMabg4h2Oe8ocxGNuKBHY5kzFJA?usp=sharing
► PLAYER MODEL
https://drive.google.com/drive/folders/1X6DLqSsLT2EAIYpcZGYL-Z93hYOo2sxa?usp=sharing
► EPISODE TWO
https://youtu.be/c1FYp1oOFIs
► SUPPORT ME ON PATREON!
http://www.patreon.com/SebastianGraves
► FOLLOW ME IN INSTAGRAM!
https://www....
so i found someone doing a tutorial on it
So i code i wrote will not strafe.
Oh damn! This series has been goin gon for awhile, hopefully I can transfer his C# to Visual properly
just write it in c# use visual for quick scripting
I wanna know how to do everything in visual script tho, I prefer it that way. It may be more difficult but if I can get it down to the tea, then I'll be a happy man.
i thought the visual stuff is for map designers and artists.
Visual script can do everything C# can do, I just need to find the right units to translate the code
it looks like more work to me but good luck
anyway back to my space sim development for me.
Just wondering how to set up a toggle using the InputAction.CallbackContext?
Ok worked it out 😛
can someone help me with my buttons as an input?
mainly just the on click stuff
{
if(pc.health == 3 && endgame == false){
Destroy(Player);
endgame = true;
Debug.Log("Game Over");
GameObject newCanvas = Instantiate(canvas) as GameObject;
Button btn = button.GetComponent<Button>();
btn.onClick.AddListener(Restart);
}
}
void Restart(){
SceneManager.LoadScene("Main");
} ```
The instantiation of the canvas works and it shows up normally
but im trying to get the click of the button to work
When the canvas is instantiated, there is a button and a piece of text parented to it, so they show up as well
how can i control that button that comes with the canvas?
@astral karma it sounds like you want to get a reference to the button that is a child of the canvas prefab (instaniated as newCanvas)
Correct
just from the code you pasted, "button" variable is probably reference the prefab's button, not the new instance.
so you'll need to use either .Find, GetComponentInChildren, or keep another script on the canvas to hold a reference to the instantiated copy of the button
ie: newCanvas.transform.Find("ButtonObjectName").GetComponent<Button>();
this type of lookup is kinda sloppy and I prefer having something like "MenuManager.cs" that holds a reference to the button ahead of time, but to each their own.
Im getting an error saying object referenced not set to an instance of an object
Oop Nevermind
Just needed to change the name
Thank you it work
and thats why its "Sloppy" 🙂
Works*
lots of human error involved
its one button now 😛
True true
then its....200 buttons in your project lol
and you rename one thing and it all goes to shit lol
Understandable
#bestpractices
Well thank you anyways for now
anyway, this was more of a #archived-code-general thing than an #🖱️┃input-system thing. FYI 🙂
👍
Hi, I'm using the new input system and i ran into this error. it won't respond to my joystick inputs
That has nothing to do with the input system per se - you've just got an unassigned or improperly assigned variable
i fixed t, i just need to enable the controller.enable()
Hello, I am using this to subscribe to a button press
Controls.Gameplay.Interact.started += context => OnInteract();
and this to unsubscribe
Controls.Gameplay.Interact.started -= context => OnInteract();
The subscribing is working just fine, but the unsubscribing doesn't seem to happen. What am I doing wrong?
You're unsubscribing a completely different lambda function basically
I see, would I have to subscribe not using lambda then?
Either promote it to a full method or save the lambda in a variable and subscribe/unsubscribe that
alright that makes 100% sense thank you
np
what would the return type be for the full method? I get this when I try
Controls.Gameplay.Interact.started += OnInteract()
figured it out, it had to look like this
public void OnInteract(InputAction.CallbackContext context)
and then
Controls.Gameplay.Interact.started += OnInteract;
yep, no parentheses when using the method as a delegate
Hey, should be fairly simple. My UI buttons aren't recognising taps or the likes on the screen (the default onclick). I've got a slightly changed version of the default input action maps, with Touch support setup. I've got the Event System setup to use the new UI Input Module too.
I've tried reading from Touchscreen.current.position.ReadValue() and it debugs the position as expected, so Touch is being recognized.
What might be the issue?
(It works on the editor, just not on the actual device.)
how can change from old input to new input inside a script because i am doing a player movement script and i am watching a tutorial video that using the old input system and i am stuck
With what?
You can't. You could run in "Both" mode but it's not a really good idea.
Probably better to ask what you're stuck on and someone can help you translate old->new
It's not usually complicated in basic movement scripts
gamepad*
Need some help setting up an action map for mouse movement. Right now I have this. I'm only reading the X axis but the value is always 0 when I attempt to print it to the console. How do I correctly set this up?
Can someone send me a link to a tutorial video on how to use the new input system properly, I’ve had such a trouble trying to understand, it’s ridiculous.
hey, can someone help me out here? i want to make my character climb the wall, but i want him to do it if i press the button before getting close to the wall too, here's the code i'm using:
void Climb()
{
controls.Player.Climb.performed += ctx =>
{
if (!onWall)
{
wallGrab = false;
}
if (onWall)
{
wallGrab = true;
}
};
controls.Player.Climb.canceled += ctx => wallGrab = false;
if (!onWall)
{
wallGrab = false;
}
}
he is just making the variable wallGrab = true when i press the button near the wall, but i want to press, and then go to the wall too
While using the new Input system Action based Rig and Oculus Plug In, my camera in my headset is only updating when the Game window is focused, can I change that behavior?
Hey,
In my build my character moves to the left border. Does not in Editor Playmode. I don't have the problem with bought games and I unplugged all perepherie.
Any ideas what's happening?
Actual project is a platformer with corgis engine, but the problem appears in every build I do.
Unity 2019.4
I need some help with what backward movement to use: https://www.strawpoll.me/45211566
Please check out and vote. Thank you.
kinda depends on the style of the game, no?
e.g. I would expect a tank to roll backwards without turning probably.
Also I could imagine it being different under certain circumstances. E.g. maybe the character turns and runs under normal circumstances but if you are in "aiming mode" they run backwards.
That you for the alternative! Its been a week and I still am not confident in what action.
Hello ! I have a problem with the d-pad in my built game, it simply doesn't work although everything works fine in the engine...
(With controller)
Does anyone know why the (old) input system seems to stop reading continuous input when you trigger a scene load and how to avoid/fix the issue? For example, if you are holding a direction and reading out the horizontal axis from Input it will suddenly read 0 once a scene load completes and won't change until you release and re-press the direction. I think you can sort of work around this by loading scenes additively and then manually unloading old scenes but that particular structure is not ideal for what I'm doing, so I'm hoping someone else maybe has a different solution?
ez
I have no idea what this is.
use ```
if(Input.getkey (keycode.KEY) && Input.getkey (keycode.KEY)){}
or somthing
wait
yea it works
This is My Script, it's easy to understand.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Idenje : MonoBehaviour
{
public CharacterController kontroler;
float brzina = 20f;
float zemljina_teza = -1.5f;
float ripanje_jacina = 4f;
public Transform sevnja_provera;
float sevnja_doleko = 0.2f;
public LayerMask sevnja_maska;
Vector3 pravac;
bool prizemen;
void Update()
{
prizemen = Physics.CheckSphere(sevnja_provera.position, sevnja_doleko, sevnja_maska);
if(prizemen && pravac.y < 0)
{
pravac.y = -1f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 odenje = transform.right * x + transform.forward * z;
kontroler.Move(odenje * brzina * Time.deltaTime);
if(Input.GetButtonDown("ripanje") && prizemen)
{
pravac.y = Mathf.Sqrt(ripanje_jacina * -2f * zemljina_teza);
}
pravac.y += zemljina_teza * Time.deltaTime * 32;
kontroler.Move(pravac * Time.deltaTime);
}
}
Although I have no idea what CharacterController is.
Hmm... I do not know. When I press the button.
Yes! There!
So "W".
oh
That is a jump. 😄
What about My old line? What about ripanje?
what is ripanje?
I do not know, that's the problem, exists only there as far as I know.
It's fine. So what does keycode means in your line?
keycode is getting the key that ne eds to be pressed
do you use Visual studio code?
if so
then use that in for your code
the double click the command
and it brings you the the dir of the command
and shows you the code
of how it works
and the commands have //comments
witch makes it easyer to read
Not sure how to do that, double-clicking just select.
I have a question, how to change this? It's in My Player.
public CharacterController kontroler;
I assume this is the default and I need the one I just created.
Sorry.
you need to make a new PlayerController
Yes but how?
public CharacterController Name;
I mean I have a quite experience in programing but I am new to Unity.
But old name is okay.
oh ok
I just have to change that CharacterController I guess.
yea
anyone know how to revert back to the old input system
It's in project settings
search for "active input handling"
anything else
that's it
k thanks
you will need to restart Unity
in that case lemme just
when prompted
save everything first
probably a good idea
sucks that theres no autosave
k im in the player settings
what do I need to do next
there's a setting called Active Input Handling
you change that back to the old input system
what did you change the setting from and what are you trying to change it to?
another thing
You can just say no if you don't want to use the new input system
this message started popping up when I switched from VS to VS Code
probably unrelated to that - you'll see this message if you installed the input system package but have this setting set to use the old input system
k then imma just press No each time
You should uninstall the inpuit system package in package manager
and you won't see that message anymore
figured
I'm kind of at a loss rn and would be happy if someone could help me out.
I can't disable or enable Actions and I don't know why.
I'm trying to disable movement while reading signs, but it doesn't work.
This is my code for enabling and disabling.
void Interact()
{
if (playerInRange)
{
if (dialogueBox.activeInHierarchy)
{
dialogueBox.SetActive(false);
interact.Player.Move.Enable();
}
else
{
dialogueBox.SetActive(true);
dialogue.text = dialogueText;
interact.Player.Move.Disable();
}
}
}
The only thing I can think of it not working is, that I've made multiple instances of InputActions in different scripts.
But I couldn't think of another way to do it and couldn't find any info on it.
Yep if you've created different copies of your generated C# class in different scripts, each one is independent of each other
a few options:
- Use one singleton object to be the custodian of a single instance of the generated C# class and share it with other scripts
- Use a direct serialized references to an InputActionAsset in your project instead
- Use InputActionReference in all your scripts to directly reference individual input actions on your InputActionAsset
I prefer the third one
The generated class is sorta convenient but not really worth it IMO
The third options sounds the most convenient I think.
But I don't know how I can reference individual input actions on my InputActionAsset.
I just told you
Use InputActionReference
[SerializeField]
InputActionReference moveAction;
Ah, yes!
I was just a little bit confused overall, just got it to work.
Thank you very much!
I appreciate it a lot.
Also, it seems like the game is now lagging a bit every time the player interacts with a sign.
Is there a way I can fix that?
you'd have to use the profiler to see what the issue is. I doubt it's related to the input system
Well, something new I need to get into then.
But thanks!
You were a big help!
okay so I'm trying to use the new Unity InputSystem and I have added a Jump action in the Input Actions editor window. but for some reason when I press the corresponding button (space) the event is fired 3 times. does anyone know how to fix this?
You're getting 3 different events
started
performed
canceled
You're supposed to check which one it is in your code and act accordingly
how do I check which event I'm getting? and which one do I even want? performed?
It's in the callback context
sorry but I have no idea what you mean. do I need to add a parameter to the event function that Unity will assign?
the documentation is so confusing. I get that I need to use InputAction.CallbackContext context in the function but I have no idea how to check for the right event. maybe I should figure out how to get Visual Studio to work and make it use Autocomplete so I can see methods more easily. right now I'm just working in Sublime Text with no error correction, code completion or anything
You 100% need to get autocomplete working
I tried to use Visual Studio but it didn't seem to have autocomplete either. is there a way to fix it?
Yes check the pinned messages in #💻┃code-beginner for how to configure VS for use with Unity
I got it to work! but that'll help quite a bit. but I have a question. can I use a button as a boolean instead of calling an event like how it used to be? I need to check a boolean from an API so I want the button to be a boolean too instead of an event. otherwise I'll have to set a boolean in the event and check it together with the other boolean
Yes you just need a reference to the InputAction and you can check wasPressedThisFrame
so constructive
Don't spam the channel or use offensive language.
whats the best input system to use in terms of most compatible
and how many input systems are there
Unity has two - the "old" one and the "new" one
the "new" one is the best in my opinion.
There are also third party assets like ReWired
Indeed. The old one is legendarily bad
is the input action asset apart of the new or old
new
sure - what trouble are you having with it?
I created the "shoot" left click action, whats the code to use it, so if this action is active, then do this
There are a lot of ways to do it.
My personal favorite is to put this in your script:
[SerializeField]
InputActionReference shootAction;
void Shoot(InputAction.CallbackContext context) {
Debug.Log("Shoot!");
}
void OnEnable() {
shootAction.action.performed += Shoot;
}
void OnDisable() {
shootAction.action.performed -= Shoot;
}
Then you assign the Shoot Action variable in the inspector
to the Shoot action you created.
do I need to put private before InputActionReference shootAction;
did I do something wrong
@austere grotto what should the action type and control type for the shoot command be
You need to find your EventSystem object and convert it to the new Input Module
There should be a button on it to do that
event system object as in the player? or
idk this is complicated, everything I touch makes an error, and its my first time using unity, idk why I decided to use unity for my computer science project, lol its due today, it would be faster if I started from scratch and use another engine that I already know how to use instead
The new Input system has a steep learning curve if you don't know C# and Unity already
basically
im going straight in, and learning C#, unity, and the new input system all at once
so thats prob whats giving me issues
Yeah
i'll come back after a month when school is over and I have summer break so I can learn this stuff, thank you though
hey guys i am trying to undestand how the oculus touch controller work... and yeah i got it but the thumb control does not work... the thumbstick is a stick with touch detection so how do i use this in unity?
Check out the Course: https://bit.ly/3i7lLtH
Learn how to use the new Unity3D Input System. The system is in an early access form and available now to try out. In this tutorial, I'll show you the basics of setting up the system. We'll create a mini project with some different behaviors like rapid fire, movement, and more all using t...
can have different inputs mapped to the same action and it sees controllers
yeah but does it also sees the thumb touch input?
im pretty sure it can map to that as well
so its not premapped?
nope, the action maps you create with the new unity system you map yourself
but it makes it really simple
uhhhh
at the same time it gets rid of the Input.getAxis stuff
i think i did it in a other way...
wait a sec
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hand : MonoBehaviour
{
Animator animator;
SkinnedMeshRenderer mesh;
public float speed;
private float triggerTarget;
private float gripTarget;
private float gripCurrent;
private float thumbTarget;
private float thumbCurrent;
private float triggerCurrent;
private String animatorGripParam = "Grip";
private String animatorTriggerParam = "Trigger";
private String animatorThumbParam = "Thumb";
void Start()
{
animator = GetComponent<Animator>();
mesh = GetComponentInChildren<SkinnedMeshRenderer>();
}
void Update()
{
AnimateHand();
}
internal void SetGrip(float v)
{
gripTarget = v;
}
internal void SetTrigger(float v)
{
triggerTarget = v;
}
internal void SetThumb(float v)
{
thumbTarget = v;
}
void AnimateHand()
{
if(gripCurrent != gripTarget)
{
gripCurrent = Mathf.MoveTowards(gripCurrent, gripTarget, Time.deltaTime * speed);
animator.SetFloat(animatorGripParam, gripCurrent);
}
if (triggerCurrent != triggerTarget)
{
triggerCurrent = Mathf.MoveTowards(triggerCurrent, triggerTarget, Time.deltaTime * speed);
animator.SetFloat(animatorTriggerParam, triggerCurrent);
}
if (thumbCurrent != thumbTarget)
{
triggerCurrent = Mathf.MoveTowards(thumbCurrent, thumbTarget, Time.deltaTime * speed);
animator.SetFloat(animatorThumbParam, thumbCurrent);
}
}
public void ToggleVisibility()
{
mesh.enabled = !mesh.enabled;
}
}
this is my hand.cs it works but the thumb dont work :(
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
[RequireComponent(typeof(ActionBasedController))]
public class HandController : MonoBehaviour
{
ActionBasedController controller;
public Hand hand;
void Start()
{
controller = GetComponent<ActionBasedController>();
}
void Update()
{
hand.SetGrip(controller.selectAction.action.ReadValue<float>());
hand.SetTrigger(controller.activateAction.action.ReadValue<float>());
hand.SetThumb(controller.activateAction.action.ReadValue<float>());
}
}
and this is the handcontroller.cs
what do you think?
are you capturing the input yourself?
or tying to?
I would go with the new input system its wayy easier than that
you dont even need to code it
yeah, its drag and drop with the new unity system basically. The code then reads the values from the input regardless of the input device being used
fuuuuuuuuck
i sat there all night long and coded because i know nothing about the input system
okay
hmmm
yeah take a look at the new input system
and where exactly can i do this "drag and drop" in unity?
oh okay
thanks anyways
lol
Package Manager -> Input System
but when you install it it deactivates the old input system
You can activate both in Project Settings -> Player -> Other Settings -> Active Input Handling. Useful when switching over.
I'm actually struggling with the Input System after initially prototyping in the old Input Manager. I think I've got the hang of it in some ways, but my problem is that, for example, my player object has multiple states and not every state uses the same controls. Like my jump state has both horizontal movement and jump controls, but the "idle" state only has horizontal movement. Right now, that's easy to implement using the Input Manager because I can just run the Move() or Jump() methods from the player controller in the Update method of the appropriate state, and the Move() method for example only has this code:
public void Move() {
if (Input.GetAxis("Horizontal") != 0) {
movement = new Vector3(Input.GetAxis("Horizontal"),0,0);
rb.AddForce(movement * thrust);
}
}
That's super easy. I can give states domain over controls by running or not running those methods and by extension their conditionals. But I'm not sure what is the best way to have state-managed controls with the Input System, if that makes sense? All of the tutorials I've looked at didn't work with state machines on the affected game objects.
You can do this with separate action maps
give your player a different action map for each state they're in
when you switch states, you can enable/disable the different action maps as needed
you can also just enable/disable individual InputActions
Thanks. Enabling/disabling individual InputActions was the solution I came up with, but I wanted to ask before implementing since I already wasted a bunch of time on failed solutions. Separate action maps is also an interesting idea!
Yeah separate action maps more or less just lets you group the input actions so you can enable/disable them with a single line of code.
So I happened to come across this blog post from a few months ago: https://blogs.unity3d.com/2020/11/26/learn-the-input-system-with-updated-tutorials-and-our-sample-project-warriors/ It concerns the Input System UI Input Module component. There's some sample code where it seems that you can disable it using the DeactivateInput method, to disable input to the whole UI I guess. It's throwing an error that it does not contain a definition for that method, so am I just misunderstanding the blog post?
With the Input System, you can quickly set up controls for multiple platforms, from mobile to VR. Get started with our example projects and new video tutorials for beginners and intermediate users. Input is at the heart of what makes your real-time projects interactive. Unity’s system for input standardizes the way you implement controls and […]
Is it just saying that you can disable player input while in a menu, not that you disable UI input?
I haven't read that article but I do this sometimes. The input module has a reference to an InputActionAsset. If you disable that asset, it will disable all the UI interactions
By default it points to a default asset from inside the input system package, but you can also point it at your own custom InputActionAsset
Oh, duh 🤦 Let me try that!
You'll need a reference directly to the same asset. You can have a Serialized Field of type InputActionAsset to point to it.
GetComponent<InputSystemUIInputModule>().actionsAsset seems to work.
But that is good to know for maintaining a reference so I don't have to GetComponent every time!
Oh yeah that'll do it too
That way might be better because then the references can't go out of sync.
Oooh, ok, thanks! This is still much better than my way of locking input before, which required separate code for locking the keyboard and mouse.
Yeah once you get the hang of the concepts of managing InputActionAssets and actionMaps it's really cool what you can do with the Input System 😎
Yeah, my opinion has totally changed since this morning because of you! 👍
Hey there! I'm trying to enable both the old and new input systems on my project, so I've set the Active Input Handling setting to "Both". However whenever I add an Event System with the old Standalone Input Module I'm getting an error because I'm using the old InputManager
Does anyone have any ideas why this is happening?
so I'm using InputAction.CallbackContext listener
How the hell do I change the presspoint?
I've been searching and searching and I'm kinda lost here
😦
Hi i'm trying to learn the new input system, my first goal was to achieve something like Input.GetAxis() and I failed........ pls help me
private PlayerControls controls;
private void Awake()
{
controls = new PlayerControls();
controls.Player.Pitch.performed += ctx => pitch = ctx.ReadValue<float>();
}
Do you need any help or did you just want to say that?
oh scroll up
oh
here
I don't get why this is so incredibly hard and complicated for whatever reason
I'm getting salty here 😛
XD
is press point the time it was pressed or the posiition?
and yes I've been reading the docs and watching vids
oh it's the time it's pressed for a float
hmm
for an axis or value
just trying to find a way to access this and change it during runtime....
I just downloaded a example that had a input recorder script they probably had something like that
hold on ill see if theres any thing usefull in that script
Sorry i cant find anything but u should probably take a look at it
Could anyone pls help me
@surreal smelt just use the unity callback system
whats that?
oh that
and add the object with that script on it to that listener
but how could i set a float using that?
samwe way you just did kinda
ok thx
float x = context.ReadValue<float>();
context is this
this accesses your input action map
thx
like the time since the game started right?
? you just went from inputsystem to game loop logic
what do you mean?
your goal is to get the time the button was pressed after starting the game right?
I'm just gonna write my own pressinteraction, this system is so freakin' spaghetti it's unbelievable
it is
I'm giving up, I'm just gonna write it myself
Yh it's like it's made by someone who just wants to frustrate everyone... It's extremely hard to see if something is readonly cause there are so many values, where do i find the set, i only see get, do i create a reference first? ... and their new api is layered ontop of the old api
so it's like, super handy unity callback listener system... great! but if you want the rest of the functionality you have to resort to their old super weird syntax
if I'm wrong (I hope I am) then great job on making input simpler, rly made my life easier (sarcasm)
I'm salty af XD
@everyone anyone? going nuts here
how the hell do i access the presspoint of an action
this thing
why is this so hard
@flat crater have you checked https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Interactions.html ?
Yes
but yeah I do agree that new input system is quite complicated in compared to the old stuff
also I JUST found out that I have to use InputActionReference class to get a reference to an action that is predefined in the inputsystem asset
I couldnt find that in the docs
I had to read an article
-____-
you probably don't have to, there's usually several routes to get access to new input system things
it doesn't help that Unity's own examples use different approaches for different things either
but yeah, what you wrote does make sense
I haven't spent much time recently on new input system but when I did evaluate it (and integrate my own native input code for it), it was quite difficult to find the specific things from the docs or examples
So I guess InputActionReference is going to magically define itself cause the author is only declaring it
This is like someone writing uncommented code
it's absolute hell
the docs i mean
it's so extremely misleading cause
look how beautiful and simple this looks
no unity dev in their right mind would think that this will be a chore to access
"looks easy to me"
then further down the line you realise you're deep into a spaghetti mess up till your neck
I think ill keep using the old system
why are you trying to use the new one?
@flat crater
two reasons... automatic device detection (switching on the fly during runtime)
and the rebinding system
inputsystem does a great job at that
thats actually the same reason i wanted to use the new one but there has to be a option for the old one
something like```
if(input.buttons!= false)
{
return input.currentButton;
}
there's plenty of reasons to not use the old input system on unity
it's just not great
nor is the new replacement (it's very buggy still)
Its way simpler tho
And it feels hard dirty and undocumented to use the new one
and old thing just works unless you need hotplugging or support for devices that the old thing doesn't support
hotplugging is one huge thing that is lacking on the old setup, it still amazes me that Unity didn't just patch it
sheeeeeeeeeeesh
really?
so that's just two ways of accessing something
I'm still nowhere near to find out how to change the interaction!!!
😂
So ill just stay with the old one for now Im not planning to realese my current project so i dont really car if its not perfect
Yeah I agree with you man, I'm pretty much too far into this now
Yh
Just look at this:```CSharp
public class Plane : MonoBehaviour
{
public float pitch;
public float roll;
public float yaw;
void Update()
{
GetInput();
}
void GetInput()
{
pitch = Input.GetAxis("Vertical");
roll = Input.GetAxis("Horizontal");
yaw = Input.GetAxis("Yaw");
}
}
So easy
but yeah i agree, rather use a plain old fashioned hammer and nail than a broken nailgun that'll get you into the hospital instead
Rewired seams pretty cool.
I would still recommend looking at Rewired though, Olento is right, hot plugging is a must-have if you build for multiple devices
true
Yeah no not dealing with this stupid sh*t
I'm getting Rewired
People are PISSED 😂
Solution:
there is this trend with new Unity packages that they do overengineer and complicate things more than necessary, this new input system isn't exception there IMHO
afaik rewired isn't all around great either but it's probably one of the most solid asset store offerings still
input is tricky but depending on your game genre, assets like rewired might just work well for you
dude @sick cradle If I can't access or change a variable in a system with ease... Then I can't be arsed
It's just mindblowing
rewired was too limited for my use cases but I'm really difficult customer.. new input system did let me expand it and fix some of the weird stuff myself
well... you can do most of the things with the new input system but it's not a piece of software that's trivial to use + it's still very bugged
you working for nasa or something?
I reported bunch of bugs some months ago, they've fixed one so far I think
this is the one they fixed https://issuetracker.unity3d.com/issues/input-system-input-system-axis-deadzone-minimum-value-fallsback-to-default-value-if-its-set-to-0
Reproduction steps: 1. Open the attached user's project "BugInputSystemDeadzone.zip" 2. In the Project window under the "Assets" fol...
but even their fix was super hacky
I could tell some stories about similar stuff that broke for similar level wtf stuff
if it works for you that's great, but when I have difficulty with docs and reaching a variable, that's not good
they hardcode all kinds of weird things there
I literally spent one month integrating my own stuff to it + fixing some of the weird stuff they had there
Yeah I've already wasted enough time thanks to it
new input system also is super sketchy on HID devices
it's straight up broken on many older devices
❤️
but those aren't really thing you'd normally worry about on game that's not some sort of sim (like racing game or flight sim)
anyway, good luck with rewired 🙂
dude this already looks way better at the installation
Thanks man! ❤️
Thanks for the support guys
Here's a cool script for converting circle analogue to square analogue values
(You usually only find square to circle so this is pretty rare and you might need it some day for rectangle or UI crosshair/reticule)
{{ description }}
Save it! 🙂 Wish you guys goodluck too!
❤️
@sick cradle
@surreal smelt
Thanks
Hello 👋
i use the new input system and i will create a binding who call my methode one times. Currently my methode is called six times 🤔 Does anyone know what i should do differently?
Thanks!
show some code @uncut crescent
do it like this:
ignore the red squiglies, i just hopepd over to Rewired
anyway that right there is a unity invoke method (you can set that up in your player input component)
crazy thing is... it's not a button... that right there is a value or axis
with a presspoint
once that presspoint is passed, the inputsystem will call the phase "Started"
the trick is to not read the value but simply let the value trigger whatever method
and then write the functionality in that method
this is way to have single-frame execution with a value input in the inputsystem
with a Button it would be much much simpler so you'll figure that out definitely
with a button you would do (context.performed)
goodluck 🙂
@flat crater This is my code:
_inputMaster.VehicleAi.SelectTargetAi.performed += ctx =>
{
Debug.Log("Open AI Target Dialog");
_G.GuiManager.ToggleGui(GUIs.AiTargetSelector);
};``` The entry in the log will print with that code two times when i press the binding (lctrl +h)
InputMaster is the generated cs-file from the inputactions
it's very misterios 🤔
{
lock(lo)
{
if (_toggle)
{
Debug.Log(string.Format("{0} {1} {2}", ctx.duration, ctx.ReadValue<float>(), ctx.ReadValueAsButton()));
_G.GuiManager.ToggleGui(GUIs.AiTargetSelector);
}
_toggle = !_toggle;
}
};``` This will also print the entry multiple 🤔
when and where are you running this code?
Uhh.. this was the right question 🤦♂️ I have two vehicles, and now it will call it on booth 🙄
I thinks that is my error and not the inputsystem 🙈 Thanks for your support @austere grotto and @flat crater 🙂
Unity has an in-depth one on their YouTube Channel.
Hey, I have a question about the new unity input system. In the UI menu there is a Submit text and its keybind is Submit[any] How do I actually know what keybinds is in this Submit[any] and how do I modify them? Thanks!
Do you know how to use YouTube? Just look up input system on their channel, I don't need to do it for you.
@modest meteor Don't post off-topic media
oki !
No need to be arrogant
It's based on what InputAction you have bound to Submit in your Input Module
Thanks for that, but I'm still somewhat confused. I am using the default input module, I can open that up in the event system by clicking on it. Inside is a script with a ton of examples and the only time time I can find them using the submit action is in the examples ///submitAction.AddBinding(...) Do you know where I can find the actual module that binds all my keys?
So if you look here this actually points at an InputActionAsset that comes built in to the Input System (by default). You shouldn't modify it. But you can click on that to find it and duplicate it. Then you can modify your duplicate and drag your duplicate into that slot instead
So that is the original concern. The binding is just Usages > Submit
lol that's what I've been trying to figure out
not sure where to find exactly what that is
It says in the docs something about all controllers having a "default" setting.
So its controller specific but I don't know where to get docs on the controllers
I guess it comes from here: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Controls.html?q=submit#control-usages but again still not sure how a particular InputControl gets the "submit" usage
Yeah thats what I found before
A Control can have one or more associated usages. A usage is a string that denotes the Control's intended use. An example of a Control usage is Submit, which labels a Control that is commonly used to confirm a selection in the UI. On a gamepad, this usage is commonly found on the buttonSouth Control.```
So there's a usages array on InputControl but it's read only: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputControl.html#UnityEngine_InputSystem_InputControl_usages
You're trying to change/assign a usage to a control right?
I think its the other way around, change a control to a usage
I guess it's supposed to be these functions:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_SetDeviceUsage_UnityEngine_InputSystem_InputDevice_System_String_
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_AddDeviceUsage_UnityEngine_InputSystem_InputDevice_System_String_
But that seems to be for a whole device? 🤔
Okay, I'll look into it. Thanks! This is pro
wow Rewired is so much better 🙂 I'm rly happy
Hey there! I'm trying to enable both the old and new input systems on my project, so I've set the Active Input Handling setting to "Both". However whenever I add an Event System with the old Standalone Input Module I'm getting an error because I'm using the old InputManager
Does anyone have any ideas why this is happening?
If a key is held down during scene change, the Input.GetAxisRaw() returns 0 until the key is repressed. how could I fix this?
This seems like a stupid question, but how do I "click" a button in the new unity input system with keys. Enter is the default, but I don't know how to change the keybind. I've changed my action map to UI, and the "Submit" action to they Space [keyboard] key, but the buttons still click with enter.
@plucky flint the default action map for UI has a universal submit mapping
sot hat will respect any OS-set "Submit" button
if you specifically only want Click, you'll need to copy/modify the default mapping
I was actually trying to do that yesterday (See just a few posts up) But i can't seem to figure that out. I would have assumed that just doing this would have changed the keybinding to space.
(On gamepads thats typically Button South, mouse left click, etc)
The other issue, is that space isn't working as a submit keybind
seems to do the right thing; mapped only the Spacebar to the submit action
Ah, I think I figured it out. So I was working with a Player Input component that was active on another game object. The UI element was using the default input, not the player input on that other game object.
^ this.
So another dumb question then. What determines which action map is used?
within PlayerInput?
generally oyu enable/disable actionmaps yourself. PlayerInput lets you set a Default Action Map and provides helper functions for switching.
Yeah, so the event system handled my UI even though I had another game object controlling my character.
the Input System UI Input Modle (or multiuser one) automatically enables specific actions from the list (Point Left Click, etc)
what's your goal? the multiuser-event-system stuff is pretty obnoxiously complex but I'm very familiar with it
At the moment just a better understanding. I have a character controller for movement, firing etc. I open up the pause menu, turn the player controller ActionsAsset to UI mode and suddenly I'm using a different Actions Asset. Instead of using the Actions Asset that was a component of my player character I'm using the Actions Asset on the eventsystem. I'm not sure why
which event system?
The root eventsystem game object that has the "Event System" componenet and the "Input System UI Input Module" component
are you dealing w/ multiple players / devices?
Nope
so when you enable the Pause Menu, is the Input System UI Input Module under it in the hierarchy? (specifically, is it Enabled when you open pause?)
Yes, the eventsystem gameobject is the last thing in the hierarchy and the Input System UI Input Module component is always enabled and active
lemme ask better heh... is the UI Input Module a child of the PauseMenu?
no
ok, so its not getting activated when you pop open the pause menu
no.
when you're using PlayerInput, how are you instantiating it?
It is a component of the root player-controlled object, instantiated on scene load, and is referenced in various scripts that are children of the root game object.
instantiated with? the PlayerInputManager or are you just spawning the gameobject?
Just spawning a gameobject.
Okay so I think I understand. Playerinput component is only necessary in multiplayer games. I didn't know this was a thing. Here is what I was missing from the docs
The way PlayerInput notifies script code of events is determined by notificationBehavior. By default, this is set to SendMessages which will use SendMessage to send messages to the GameObject that PlayerInput sits on.
So my UI is not associated with my player object.
it won't ever recieve sendmessage so it will never be activated by the UI.
^ "wont ever" unless you set it
PlayerInput does still have some uses, but it adds complexity.
I covered a bunch of it here
Well thanks for the input!
@plucky flint
here's a really simple version w/ PlayerInput implemented
mostly just makes use of PlayerInput's ActivateInput and DeactivateInput rather than worrying about switching UI contexts around
(also sorry for sending you the other crap in the experiments folder! my bad!)
lol its alright, thanks for the resources
nvm
Does anyone know why OnControlsChanged doesn't always work? I use currentControlScheme to automatically switch between keyboard/mouse and controller, but sometimes it just won't change to controller.
It's a wireless xbox one controller.
I have a controller script that contains
private void Awake()
{
playerController = new PlayerController();
playerController.PlayerInput.Jump.performed += JumpPressed;
}
public void JumpPressed(InputAction.CallbackContext obj)
{
Debug.Log("call");
}
then i have a combat state where i would like to check if say jump is pressed. In the old inputsystems i have
if (Input.GetButtonDown("Jump"))
{
player.StateMachine.ChangeState(player.JumpState);
}
how do i change
Input.GetButtonDown("JUMP")
to work with my newly set up playerController
The JumpPressed function will be called when the button is pressed (since it is added to the event Jump.performed)
which is what happens with GetButtonDown
in the case, you can call your Jump function inside the JumpPressed one
yeah i am trying to keep them separated though
because i have many different player states that i only want certain interactions to be able to happen
if i put the Jump function inside JumpPressed you would be able to jump at any time
so that is why i want to check if GetButtonDown inside the state and not the controller
You could assign a boolean with the jump input. And change it on where GetButtonDown is
on Jump.performed assign a function that makes the jump boolean true
and on Jump.canceled assign a function that makes the jump boolean false
Or even better, maybe you just need to assign it to true on Jump.performed
and after you guaranteed that your character jumped, you return it to false
i was thinking of doing it that way only issue is returning it to false. just seems a lot messier then Input.GetButtonDown("Jump")
hey! trying to get used to the new input system here. so I'm making a game where your controls are mainly only jumping forwards and backwards. and I am following samyams tutorial, which went well.
but since I'm sorta new to coding how would I do the jumping where its back and forth like how the moving back and forth script does?
Here's a screenshot where I kinda "explain" it (green is result). also this is a 2d game.
i had a few typos in the screenshot, for the top red text I meant to say "makes player only jump forwards"
You would need to do something like this:
void Start() {
playerActionControls.Land.Jump.started += Jump;
}
void Jump (InputAction.CallbackContext context) {
float axisValue = context.ReadValue<float>();
if (IsGrounded) {
rb.AddForce(new Vector2(Mathf.Sign(axisValue) * 5.1f, 7f), ForceMode2D.Impulse);
}
}
Thanks for the reply! Idk whats wrong but your code makes it do nothing. no errors btw. also I edited it so that it says "IsGrounded == true" instead of what u had.
heres your same code that I pasted into my script.
the == true is not necessary, but also not harmful.
Perhaps try .performed instead of .started, but it should work with started 🤔
what do you have Jump bound to?
How is it set up?
Is it a single keyboard key? A controller dpad?
this should answer your question.