Re: Switching actors via Lua
Awesomeness wrote:
...Specifically to no one. As in, for example, when you aren't controlling anything until the rocket spits out the brain in Zombie Cave.
self:SetViewState(Activity.ACTORSELECT, player);
where self is the current activity, if it's not, then do this: ActivityMan:GetActivity():SetViewState(Activity.ACTORSELECT, player);
and player is the player number. 0, unless it's multiplayer.
This gives the effect in Zombie Cave where in the start you have the actor select cursor on until the brain robot pops out from the rocket. The only problem is, I couldn't control where it appears.... (with console at least)
I can only guess that self:SetActorSelectCursor(Vector(3024, 324), player); would set the position of the actor select cursor, if only it would work. But somehow it seems that the activity you get from Activity:GetActivity() isn't the same that ZombieCaveMission:StartActivity() gets. Because game complains that such method does not exist. Same goes for self:SetObservationTarget(self:GetPlayerBrain(player).Pos, player). Weird :/
EDIT:
Awesomeness wrote:
Also, how can I force someone to stay switched to a certain actor?
One way (script attached to game object):
Code:
function Update(self)
local Activity = ActivityMan:GetActivity();
local ForcedControlledActor; --This should have the actor reference that you want the player to be forced to "control"
local CurrentActor = Activity:GetControlledActor(0);
if CurrentActor.ID ~= ForcedControlledActor.ID then -- Warning: may need to use MovableMan:IsActor() for invalid pointer checks, depending how you handle your variables.
Activity:SwitchToActor(ForcedControlledActor, 0, 0);
end
end
If you are planning on using a mission script for this, you can use SetViewState, SetActorSelectCursor, SetObservationTarget etc. functions. Zombie Cave mission script is good example.