You can use a property that tell the actor if he is active or not. Do it on the player and the horse.
If the property is true (or 1 if integer) then the controls should be enabled. You can do this by adding an property sensor that checks for the correct value. connect this sensor with the “AND” controllers of your controls.
player objects:
property "active" as int default = 1 (or 0)
property sensor --> AND controller --> controls Actuator
active = 1 ->
/
controls sensor/
...
Do this for every controller you want to enable/disable.
Add the same logic to your other actors (e.g horse).
Make sure only one actor has the property set to 1. All other should be set to 0. Otherwise you would control two actors at the same time (nice feature
).
To switch between the actors you need to
a) change the property of the new actor to 1 and
b) change the property of the active actor to 0
There are many ways to achieve this. Here an example:
a) Connect a sensor from any object to a message actuator sending an enable message to the new actor. Don’t forget the “OB” at the beginning of the to field (e.g. “to: OBCube”). The subject could be “enable”.
b) connect another message actuator to the same controller sending an “disable” to everyone (means leave the to: field empty).
any object:
any sensor ---> AND controller ---> message actuator to OBHorse
with subject "enable"
-> message actuator
with subject "disable"
now you need a message sensor to react on enable and one to react on disable messages:
player objects:
message sensor ---> AND controller ---> property actuator
subject: disable active = 0
message sensor ---> AND controller ---> property actuator
subject: enable active = 1
what happens:
if the “any” sensor is triggered ( remember it does not need to be an actor )
- a disable message is send to every object
- an enable message is send to the new active object (horse)
- all actor objects (player and horse) receive the disable message and set active to 0 (use debug button on the properties)
3a. The controls do not work anymore on the actors.
- the new active object (horse) gets the enable message and sets property to 1
4.a. the active object can use the controls.
to switch back you need a different sensor to send the enable message to the player (and the disable messages to everyone else (horse))
Alternatively you can send disable massages directly to the actor that should be deactivated (player). But this increases the amount of message actuators with the amount of actors.
( Sensors should be without any pulse mode)
Hopefully this helps.