I was wondering how to make a character follow the player character when the player character changes.
For ex. i have three characters(A,B,and C) and the player character is A.
Player A tells player B to follow,
but when i switch to player C and use the follow command on player B i want B to follow C not A.
Look up Character.FollowCharacter...
Try something like:
cCharname.FollowCharacter(player);
i know that command im using it
but for (Player) is there somthing i can put in it for it to follow the player character
For ex.
cA.FollowCharacter(Player Character);
You'll need to be a bit more clear. And tell us what version you are using, please. ( Which 2.7)
I am making an RTS game and i have 10 tanks and no way to move more than one of them at a time.Ã, To solve this i added a crusor and i want to program it so that when you click on a unit it will follow the tank you are.Ã, You can also switch any of the tanks to the player character , but thats my problem.
I was wondering if for the command cCharname.FollowCharacter(player); if for FollowCharacter(player); if it could follow the player character no matter who the player character is.
im also using V.2.7
player is a global pointer to the player character!
You can use cCharname.FollowCharacter(player); where Charname is the script name of your character that you want to follow the player.
You can also check that the character isn't the player with something like:
if (character[0] != player) character[0].FollowCharacter(player);
or you can set it up in a loop:
int maxchars = GetGameParameter(GP_NUMCHARACTERS, 0, 0, 0); /* or set this to the last character that should appear in the room? */
int i = 0; /* or the first character in the room? */
while (i < maxchars) {
if (character[i] != player) character[i].FollowCharacter(player);
i++;
}
That would run through all the characters in the game (or the room depending on the values you set for maxchars and i) and make them all follow the player. Now if you set that up in repeatedly_execute, it would do that the whole duration of the room (for a room rep_ex) or the game (for a global rep_ex)...
Of course you probably don't want all the characters in the game following the player, so you'll want to change those indexes, but it should get you started.
Thx it worked. :D
BTW, I'm not sure if making a character follow themselves just does nothing...but I added checks to prevent it anyway. Glad you got it working ;)