RPG Combat Course - Need help/guidance on implementing Rewired/New Input System

Hello everyone I need some guidance on how to completely integrate Rewired tools into the RPG project. Can someone help/guide me If they have done it already or have any idea on how to start and what to change in the code to completely replace the old input system in to Rewired?

Unfortunately, I’m unfamiliar with this asset, so I’m afraid I won’t be much help with this.

What about the new input system? I think their somewhat similar. One of the things that I want to know is the location of codes where I need to replace the old input system to new input system? Maybe you can help me on that part?

The new input system is more of an event driven system than the old system, at least when ti comes to keyboard input, like pressing I for Inventory, etc…

We’ll start with the stuff that is similar…
You can get the position of the mouse with

Vector2 position = Mouse.current.position.readvalue;

You can determine if the mouse is clicked with

bool isClicked = Mouse.current.leftButton.isPressed;

Key presses are a bit trickier, as you have to create an Input Asset and create specific events for each Key… for example, you might have a Save with S bound to it, a Load with L bound to it, etc. We no longer have anything equivalent to if (Input.GetKeyDown(KeyCode.S))

From there, there are multiple ways of subscribing to these events… The easiest is to add a Player Input component to the Core gameobject, and add your Input Action Asset to it. Then there is a drop down for Behavior, where you can specify “Send Messages”, “Broadcast Messages” and “UnityEvent”.

UnityEvent lets you select components on any GameObject to call specific functions… the functions must take a CallbackContext as it’s parameter… for example,

public void Save(CallbackContext context)
{
    if(context.performed) PerformSave();
}

This does create some issues with the SavingWrapper, as these event links don’t tend to work… so for this, I add a special class added to the Core that passes these messages on to FindObjectOfType<SavingWrapper>()

Creating an Input Asset

1 Like

Privacy & Terms