[Answered] The correct way to redirect input from a pawn to another actor

I want to make actors with whom you can interact, but who are not pawns. When interacting, the player’s pawn must have control blocked, and control commands must be transmitted to the actor (for example, the ship’s steering wheel). I suppose this should be done using the UInputComponent, but could not find any examples. Please help determine the direction for finding information.

You are correct, you can have a special InputComponent, created on the ship, then in the player controller, you can swap the input to that., When finished with the ship, switch it back. These two functions are what you need



    /** Adds an inputcomponent to the top of the input stack. */
    virtual void PushInputComponent(UInputComponent* Input);

    /** Removes given inputcomponent from the input stack (regardless of if it's the top, actually). */
    virtual bool PopInputComponent(UInputComponent* Input);

2 Likes