Game Development Community

Simulating a keypress / stick input

by James Ford · in Torque X 2D · 07/17/2007 (10:52 am) · 2 replies

Is there a way to simulate gamepad / keyboard input? I was going to modify a Move object but it is read only.

#1
07/17/2007 (12:09 pm)
Apparently I can create a new Move object and supply its values in the contructor, so if I want to make a new Move obj with one button pressed but everythingelse the same I can supply the old Move objects "parts" in the contructor and the new value for the one i wish to change, but this just seems a little annoying.

The idea is to handle AI player actions the same way I handle human player actions, that is, with the same ControllerComponent. So in my controllercomponent::updateticks if the move == null because it is not a player then it will grab the Move object from the AIBrainComponent (where it is generated). Does this seem like a good idea or does someone else have a better one '-)
#2
07/17/2007 (12:59 pm)
A better approach might be to split your player input and whatever processing you do into two separate components that communicate via interfaces. Then you can keep the processing component but swap out the input handling component for the AI component, as long as they use the same interfaces.