-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switching to using the new Input System Package #49
Comments
|
Exactly, yeah, I'd like to be able to fake button inputs. |
It isn't directly supported but there's a way around it. Here's a small example: public bool doAction; // Set this through other scripts
private readonly int myActionHash = GoldPlayerController.InputNameToHash("My Action");
public bool GetButtonDown(int buttonHash)
{
if (buttonHash == myActionHash)
{
return doAction;
}
return false;
}
// do the same for the other actions... I know this isn't ideal but this is one of the ways to fake input to the controller. There is another method where you should be able to modify the state of the controller directly. I can't say if all the actions are supported since it's been a while since I used gold player myself. But I know of these two that you can use to get decently far. GoldPlayerController controller = GetComponent<GoldPlayerController>();
// Will make the controller jump
controller.Movement.PressedJump = true|false;
// Vector2 with values from 0-1 to make the controller move in a specified direction
// (relative to the controller direction I think)
controller.Movement.MovementInput = new Vector2(0, 1);
// I think the easiest way to rotate the controller
float strength = 5; // I can't remember how strength works exactly, but I believe it has to do with lerping.
controller.Camera.ForceLook(new Vector3(0, 5, 0), strength);
// To stop force looking
controller.Camera.StopForceLook(); This too isn't ideal, but it works. I used it for a prototype with AI-controlled gold player controllers. They just modified these values directly. I hope this helps! |
What I want to do:
Use the new Input System Package (ISP) instead of the legacy Input Manager
What I've tried:
Implemented my own features separately from the Gold Controller, so I'm aware of how the new ISP works with setting up user settings and adding bindings and whatnot.
Since your input system has an EnableAction(int buttonName) method, I tried to call that with an input binding:
The input I was attempting to use was Crouch, which I had bound in the ISP to both C and left-stick-click for controllers.
Figured out you're just using a hash of the button name, so I hardcoded the hash and the editor runs without errors when I click the stick, but I get no successful inputs.
Is there a way to actually trigger an input on the controller from outside the script? I don't mind jury-rigging method inputs by hand on an input-by-input basis, I just want to be consistent and not need to worry about having two different input systems.
The text was updated successfully, but these errors were encountered: