Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Which behavior to use?

Discussion in 'Input System' started by N1warhead, Oct 5, 2020.

  1. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Is there any benefit to selecting one of the 4 behaviors on Player Input component?
    Better yet, is it required to use this component at all?

    But if I have too, are any of the behaviors the go-to solution? Is Send Messages (Default selection) faster than the documentation using Invoke Unity Events, etc.

    @Ryiah figured I'd tag you as you've used the input system.

    Thanks for the help everyone.
     
    ChrisDiPiero likes this.
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,221
    Send message tries to invoke the function in all components attached to the same GameObject as the PlayerInput component. Broadcast does the same but takes it one step further by trying to do it with all of the components of the child GameObjects too.

    I'm currently using UnityEvents because I know exactly which components should receive the events.

    No. It's just a helper class. I'm currently using it with my contract project because it was the easiest way to get multiplayer working with limited knowledge of the input system. With what I know now though I don't know if I would use it again. At least without making changes to the class itself.
     
    Last edited: Oct 5, 2020
    ChrisDiPiero likes this.
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Thank you. Not sure if Send Message is very efficient then if it tries to call it on All Components, seems like it would be a lot of unnecessary calls. Seems like using events is specific and straight to the point.

    I figured with the word it was the same way as the SendMessage in code, which I learned quickly wasn't great.

    But thank you Ryiah :)
    I'm going to try and make my own class to handle it all myself.