Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: KodiakBehr on Sun 27/01/2013 21:48:43

Title: Switching Characters and Camera Tracking
Post by: KodiakBehr on Sun 27/01/2013 21:48:43
Hey guys,

Can you give me some insight as to what is happening here?

I've got a scene where the player, upon crossing a specific point, has his/her attention moved from the protagonist to another character.  Basically, I want the camera to track a new person in a cutscene as they walk a brief path, an event occurs, and then the camera returns to the original player.

The switch appears to happen, but the camera fails to track the new player and all the good stuff appears to be happening off-screen!  Any idea what I can do to remedy this?

Code (AGS) Select

function region5_WalksOnto()
{
    region[5].Enabled=false;
    player.StopMoving();
    odoor.Animate(0, 2, eOnce, eBlock, eForwards);
    cCharacter2.SetAsPlayer();
    player.Walk(1497, 126, eBlock, eAnywhere);
    player.Walk(1262, 126, eBlock, eAnywhere);
    player.Walk(1262, 178, eBlock, eWalkableAreas);
    player.Walk(1054, 177, eBlock, eWalkableAreas);
    player.Walk(1053, 128, eBlock, eWalkableAreas);
}
Title: Re: Switching Characters and Camera Tracking
Post by: selmiak on Sun 27/01/2013 23:29:47
How do you know the switch is happening when you can't see what is happening with cCharacter2? But I just used the same approach for a cutscene and it worked just like intended, though I refer to the new player charater by cCharacter2.Walk(... instead of player.Walk(... but that shouldn't matter.
I see nothing wrong with your code, but to track some more of the offscreen happenings (maybe there is something wrong with what is happening off screen, but it doesn't look wrong at all), have you tried setting the viewport with SetViewport(x, y)?
Title: Re: Switching Characters and Camera Tracking
Post by: KodiakBehr on Sun 27/01/2013 23:41:57
Viewports.  You learn something every day.  Thanks!
Title: Re: Switching Characters and Camera Tracking
Post by: Khris on Mon 28/01/2013 00:25:59
The camera should be following the current player character, without you having to call Viewport commands.
What happens if you add "Wait(1);" after the .SetAsPlayer() command?
Title: Re: Switching Characters and Camera Tracking
Post by: KodiakBehr on Mon 28/01/2013 02:50:04
That seemed to do the trick.  Thanks Khris.