Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

generate Input.GetKeyDown("space") event from agent.

Discussion in 'ML-Agents' started by hammer_head, Apr 4, 2020.

  1. hammer_head

    hammer_head

    Joined:
    Nov 4, 2018
    Posts:
    11
    Hi ,

    Lets say I have a existing game in which I use GetKeyDown("space") for character Jump , Now with agent action I want to control the Jump without disturbing the original code i.e agent should generate "space" presses instead of human.

    How do I pass actions from my agents to unity input system without or with minimal modification to original code ? this will enable to easily create a agent without disturbing the original game.


    Thanks.
     
  2. awjuliani

    awjuliani

    Unity Technologies

    Joined:
    Mar 1, 2017
    Posts:
    69
    Hello,

    It is currently not possible to add ML-Agents to a game that uses the input system without some amount of code changes. It isn't possible for the agent to generate a virtual key press. I would recommend taking a look at the Heurstic function, and see whether you can put the space check in there. That may allow you to use an ML-Agents agent under the hood for your behavior. https://github.com/Unity-Technologi...ronment-Create-New.md#testing-the-environment
     
  3. hammer_head

    hammer_head

    Joined:
    Nov 4, 2018
    Posts:
    11
    Thanks you , I will look into it.