Changing Player Character

Started by Revan, Tue 15/11/2005 13:38:16

Previous topic - Next topic

Revan

How do I make the playable charatcer change halfway through the game?
<sorry if this has already been posted or if its on the tutorial but ie serched with no luck>

strazer

#1
AGS Beginners FAQ

AGS v2.7+:

To change the player character to ROGER:
Code: ags

  cRoger.SetAsPlayer();


To let the player character say something depending on who he is:

Code: ags

  // script for interaction: Look at couch

  if (player == cRoger) {
    cRoger.Say("Roger, you idiot, that's a couch!");
  }
  else if (player == cIdiot) {
    cIdiot.Say("That's a...uh...buffalo. Yeah...! That's the ticket!");
  }
  // ...more characters
  else player.Say("That's a couch.");

strazer

Quote from: Revan (via pm)
I'm still having difficulty in being able to change the playable charactor... I want to start off as one guy (KRAS) and on the click of a hotspot (HOTSPOT) change playability to another guy (RHONIN) please can you help me...

To make KRAS the player character by default, check his "This is the player character" checkbox in the Characters pane.

Making RHONIN the player character when clicking on a hotspot:

- Select "Room Editor" from the left side
- Load room (double-click) the hotspot is in
- Select "Areas" from left side
- Select "Hotspots" from drop-down above
- Select/draw the appropriate hotspot
- Click "Interaction..." button
- Right-click "Interact hotspot" (or "Look at" or whatever fits)
- "New action..."
- Select "Run script" from the drop-down
- Click "Edit script..." button
- cRhonin.SetAsPlayer();
- Close, Save, Yes, OK etc.

Revan

Thankyou, was coding all last night tryin to get it to work... Didn't realise that the interactions dropdown box had a 'run script' selection... cheers

strazer


Revan

I am making a game with multiple character selection at the start. Having trouble with the 3rd room; you get to choose ur character then it moves you to a bar where all the characters are but you only controle the 1 you pick... but whenever you go outside the bar it automaically changes the character to the one in 'character 1' slot how can I change this?

strazer

#6
Quote from: Revan on Thu 17/11/2005 11:28:00
whenever you go outside the bar it automaically changes the character to the one in 'character 1' slot

AGS doesn't automatically change the player character.

In your scripts, you probably have told it to use a specific character, like
  cEgo.Say("Hello");
instead of
  player.Say("Hello");
which always refers to the current player character.

So search all scripts for all those occurrences where a specific character is used as player character and change that to "player" instead.

SMF spam blocked by CleanTalk