Comments (3)
It isn't directly supported but there's a way around it.
You can create your own component that implements IGoldInput
. You'll need to implement all the classic input methods, like GetButton
, GetButtonDown
, etc. Using that you could check if the hash is the same as your action and then return true.
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!
from gold-player.
EnableAction
is for enabling input to be registered at all, basically an on/off switch. From what I understand you want to actually trigger the input, like faking a button press?
from gold-player.
you want to actually trigger the input, like faking a button press?
Exactly, yeah, I'd like to be able to fake button inputs.
from gold-player.
Related Issues (20)
- AudioItem GUI does not work when outside player controller in 2019.1+ HOT 2
- Error when on any Unity Version earlier than 2019.3, and not using the new Input System. HOT 1
- Having problems using the new input system with mouse input. HOT 9
- Trying to use Gold Player with the old input system. HOT 3
- Can't set position through script HOT 2
- Provide examples HOT 2
- Unsure how to properly setup. HOT 3
- Gold Player movement is buggy on low time scales HOT 1
- Allow for camera based recoil/external forces being applied to the camera rotation HOT 3
- How can I embed the code in my project so I can modify the code my self HOT 2
- GetAxis returns wrong value in input system
- Can't get the player controller to even start without an error... HOT 4
- Cannot jump when up against any kind of wall collider... HOT 3
- Humanoid Rig HOT 1
- How to disable "Can look around"?
- How to hide a text, when mouse look doesn't placed on interactable object? HOT 1
- Is there any info/documentation on multiplayer integration? Since it's even mentioned to be 'easy' to setup. HOT 4
- Look angle animation not working HOT 2
- Head bob happens while player is not on ground
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gold-player.