Jump to content
Sign in to follow this  
DiabloMuerto

How to: Move player control from one unit to another unit

Recommended Posts

I've been trying to find some info. on moving the player from controlling one unit to controlling a different unit preferably after a trigger. Basically for the set up I am doing the mission starts and you're playing a special forces team. After a set number of tasks that team returns to base and at that point what I would like to do is fade to black, then when it fades back in you've been dropped in control of a separate unit + his squad of guys (not SpecForces). I know how to do pretty much all I need except for move control of the player from the current unit over to the new units.

On a tangent to this question, in the mission I am doing I am allowing the player to control any units in the squad. So the other thing I would need to know how to do is how to make it so these particular units are not "playable" until I trigger the control swap so that they don't show up in the list when you press "U" while you're playing as the spec ops team. I know spawning the units in at the time of the trigger would solve that but I don't know how to spawn units with custom loadouts yet. I know how to give custom loadouts just not call in a unit that hasn't been placed on the map and then assign him that loadout.

I have no scripting skills so mainly I'm looking for solutions that can be executed in the editor.

To sum it up for those who don't want to read all that...

1. How to move the player from controlling one unit/squad to controlling another unit/squad

2. How to make a unit that was dropped as 'non-playable' into a 'playable'

3. How to spawn a unit with a pre-defined loadout

Mainly looking for how to do these things after a trigger or similar action.

Share this post


Link to post
Share on other sites

3. This is a bit more complex, so until you're more proficient with scripting you could look around for existing scripts that you can adapt/utilize. You don't really have to use that unless you're creating a very big mission and you're running into performance problems due to the high amount of existing units.

2. I assume you're making a singleplayer mission with Team_Switch. So just give the unit a name and put this in a trigger:

addSwitchableUnit unitName

See here for a more detailed description of the command (and similar commands).:

https://community.bistudio.com/wiki/addSwitchableUnit

1. To force-switch the player into a certain unit, use this:

selectPlayer unitName

As described here:

https://community.bistudio.com/wiki/selectPlayer

Share this post


Link to post
Share on other sites

I've made the experience that if you use selectPlayer the previous player unit adds to switchable units. So to prevent the player from switching back to his old unit you might want to use (untested) after selectPlayer:

removeSwitchableUnit oldUnit;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×