Search Unity

Feedback Issues with the New Input System

Discussion in 'Input System' started by TRS6123, Aug 3, 2019.

  1. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    Just posting some issues I'm having with the New Input System

    I know in previous versions you could use just the x or y component of Vector2 mouse actions (position, delta, etc.) as a binding, but I don't see them as an option anymore in 0.9.0-preview. I still think that it would be a useful thing to have.

    Also I think there's something wrong with the Vector2 Normalize preprocessor. It doesn't show any editable fields like it's corresponding Normalize preprocessor for a single axis (shows fields for Min, Max, and Zero).
     
  2. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    Update: The x and y components do show up when the control type is set to "Any", but not when set to "Axis"
     
  3. RichardSim

    RichardSim

    Joined:
    Dec 15, 2013
    Posts:
    14
    I see the same with joysticks - x/y only show up for "Any", though it seems they should show up for "Axis" too.
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Hmm, that's peculiar. I'm not seeing the same. With the action type set to "Value" and the control type set to "Axis", I get all the X and Y components showing up under Mouse/delta, Mouse/position, etc. Definitely not intended for them to get filtered out in that setup.

    Are you still seeing the problem in 0.9.2?

    That one's intentional. ATM NormalizeVector2 is simply the equivalent of standard vector normalization, i.e. turning the vector into one with a length/magnitude of 1.

    What's the parameters you're looking for? In case you simply want to scale the result to a length different than 1, one way is to add a ScaleVector2 processor right after.
     
  5. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    0.9.2 does fix the first problem
     
    Rene-Damm likes this.
  6. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    As for the other problem, I'm specifically trying to use mouse position in an input action. I want the neutral position to be the center of the screen. I was expecting NormalizeVector2 to have Min, Max, and Zero fields for each axis.
     
  7. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Would recommend doing the space conversion after ReadValue rather than inside the action. For the latter, you'd need a custom processor.

    Converting from Unity screen-space to origin-in-center space (in player code; EditorWindow code has a different coordinate system) is simple.

    Code (CSharp):
    1. var pos = action.ReadValue<Vector2>();
    2. pos -= new Vector2(Screen.width / 2, Screen.height / 2);
    Should do the trick.
     
  8. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    look at:
    Code (CSharp):
    1.  
    2.     private void FixedUpdate()
    3.     {
    4.         Camera.main.transform.position = new Vector3(transform.position.x, Camera.main.transform.position.y, transform.position.z - 11.5f);
    5.         RaycastHit hit;
    6.         Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
    7.         if (Physics.Raycast(ray, out hit))
    8.         {
    9.             MousePOSGo.transform.position = new Vector3(hit.point.x, transform.position.y, hit.point.z);
    10.             // Do something with the object that was hit by the raycast.
    11.         }
    12.         transform.LookAt(MousePOSGo.transform);
    13.         Debug.Log(Vector3.SqrMagnitude(MousePOSGo.transform.position - transform.position));
    14.         if (Vector3.SqrMagnitude(MousePOSGo.transform.position - transform.position) > 4f)
    15.         {
    16.             if (anim.GetBool(IsRunning))
    17.                 InputValue *= 0.5f;
    18.             if (anim.GetBool(IsMoving))
    19.                 cc.Move(InputValue);
    20.         }
    21.         if (!cc.isGrounded)
    22.             cc.SimpleMove(Physics.gravity);
    23.     }
    24.  
    25.     private void MoveHandlerStart(InputAction.CallbackContext obj)
    26.     {
    27.         anim.SetBool(IsMoving, true);
    28.     }
    29.  
    30.     private void MoveHandler(InputAction.CallbackContext obj)
    31.     {
    32.         var V2 = obj.ReadValue<Vector2>();
    33.         anim.SetFloat(VelocityX, V2.x);
    34.         anim.SetFloat(VelocityZ, V2.y);
    35.         InputValue = new Vector3(V2.x, 0, V2.y) * MovementSpeed;
    36.     }
    37.  
    38.     private void MoveHandlerCancel(InputAction.CallbackContext obj)
    39.     {
    40.         anim.SetFloat(VelocityX, 0);
    41.         anim.SetFloat(VelocityZ, 0);
    42.         InputValue = Vector2.zero;
    43.         anim.SetBool(IsMoving, false);
    44.     }
    45.  
    46.     private void RunningHandlerStart(InputAction.CallbackContext obj)
    47.     {
    48.         anim.SetBool(IsRunning, true);
    49.     }
    50.  
    51.     private void RunningHandlerCancel(InputAction.CallbackContext obj)
    52.     {
    53.         anim.SetBool(IsRunning, false);
    54.     }
    now try to make it to where character follow correct distance checking. No matter what is done the character will still move regardless of distance values.

    1. if (anim.GetBool(IsRunning))
    2. InputValue *= 0.5f;
    3. if (anim.GetBool(IsMoving))
    4. cc.Move(InputValue);
    runs magically still regardless of previous boolean (Vector3.SqrMagnitude(MousePOSGo.transform.position - transform.position) > 4f)