Coder Social home page Coder Social logo

Comments (3)

Hertzole avatar Hertzole commented on May 30, 2024 1

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.

Hertzole avatar Hertzole commented on May 30, 2024

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.

XanIves avatar XanIves commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.