Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Zanthia on Thu 04/09/2008 07:04:22

Title: Character invisible to visible.. ?
Post by: Zanthia on Thu 04/09/2008 07:04:22
Hello !
First of all, I'd like to say it's my first post on this forum, and my first attempt at making a game with this great tool !

I'm slowly discovering all the features with a test-game, but I seem to be stuck with something.

Here's the point : I want a NPC "hiding" somewhere, and I want him to appear only when the player talks to the place he's hiding.

I've searched in the FAQ, the forum, the wiki, everywhere, but everything that I found don't work.  ???

I tried setting a "bool cCharacter.Visible = false" and do the scripting after that, but I got an error telling me "cCharacter is already imported".
I tried the same without the "bool", but I got an error telling me that "cCharacter is unexpected".
I tried to mess with "Transparency" the same way, but get the same errors...

Ok, but I won't let you win !  >:(
I tried to put the character as an object, therefore allowing me to make it invisible at first, everything is fine. He appears ! Joy !
Oh Shi-, when I start the dialog, its animation doesn't start, because it's considered as an object... -___-

I may be a little confused, I'm sorry (plus I'm French, so the English might not be perfect). And I promised I looked thoroughly at the manual, and searched the forum, but I didn't find anything that worked  :(

A little help would be welcome ! And tell me if I should have put more informations !
Title: Re: Character invisible to visible.. ?
Post by: zabnat on Thu 04/09/2008 07:15:26
You're on the right track by removing the "bool" (since you only use that when declaring variables and in this case characters visible property is already declared), but you need to substitute cCharacter with the script name of your character. You will see the scriptname in the properties of the character in the editor. So if you're characters scriptname is cGhost you would use "cGhost.Visible = false" to make the character cGhost invisible. Remember to place it inside a function (and the semicolons at the end of the row) ;).
Title: Re: Character invisible to visible.. ?
Post by: Zanthia on Thu 04/09/2008 07:26:28
Quote from: zabnat on Thu 04/09/2008 07:15:26
You're on the right track by removing the "bool" (since you only use that when declaring variables and in this case characters visible property is already declared), but you need to substitute cCharacter with the script name of your character. You will see the scriptname in the properties of the character in the editor. So if you're characters scriptname is cGhost you would use "cGhost.Visible = false" to make the character cGhost invisible. Remember to place it inside a function (and the semicolons at the end of the row) ;).

I know that, I just put "Character" to keep my NPC Extraordinaire's name secret ! :-X
But placing it inside a function ? Which is the right one to use ? I didn't put anything around because I wrote it at the very beginning of the room script, and didn't really know what to use (In the infos I found about this, they just put the line as I did...)

Thanks :-[
Title: Re: Character invisible to visible.. ?
Post by: zabnat on Thu 04/09/2008 07:57:17
Okay, my bad. The function where you place it depends on when you want it to happen. You could place it in the rooms "Enters room before fade-in"-function if you want the invisibility to be the default state the character is in. And then place the "cCharacter.Visible = true" to the interaction function when you speak to the hotspot (as you can't talk to the character directly when it's hidden) if you want the character to appear then.
Title: Re: Character invisible to visible.. ?
Post by: Zanthia on Thu 04/09/2008 08:20:29
Quote from: zabnat on Thu 04/09/2008 07:57:17You could place it in the rooms "Enters room before fade-in"-function

I can't seem to find this line... Is it supposed to be in the room script, or in the global one ?  ???
Title: Re: Character invisible to visible.. ?
Post by: Zanthia on Thu 04/09/2008 08:32:26
I managed to do it, using the magic of Walkbehind and IgnoreWalkBehind...

Anyway thanks a lot for the quick answers zabnat !  ;) (Though I would gladly like to know where is this script line you're talking about oO)
Title: Re: Character invisible to visible.. ?
Post by: zabnat on Thu 04/09/2008 08:41:52
I called it "Enters room before fade-in"-function, because you didn't say what version you were using :). In 3.x you can jump (and create if not created) to the function from rooms events tab. There you will find "Enters room before fade-in".
Title: Re: Character invisible to visible.. ?
Post by: FalseHope on Sun 07/09/2008 16:46:38
 ??? Can i know how do you make the character turn invisible? Coz I'm making a game that requires the character to be invisible throughout the WHOLE game.
Title: Re: Character invisible to visible.. ?
Post by: Makeout Patrol on Sun 07/09/2008 17:43:44
Quote from: FalseHope on Sun 07/09/2008 16:46:38
??? Can i know how do you make the character turn invisible? Coz I'm making a game that requires the character to be invisible throughout the WHOLE game.

The easiest way to do this is probably to put transparent sprites in that character's views and set 'clickable' to FALSE in their editor window.
Title: Re: Character invisible to visible.. ?
Post by: Dualnames on Sun 07/09/2008 21:13:33
Why not do this?

cCharacter.Transparency=100;//that makes him invisible
cCharacter.Transparency=0;//that makes him visible.

And if you want to create a function to use for every character put this above everything at the global script.

function invisibility(Character*charac,bool visibility) {
if (visibility==true) {
charac.Transparency=0;
return;
}
else {
charac.Transparency=100;
return;
}
}

So then from every script you just put this:
invisibility(cEgo,true);

ecc..
Title: Re: Character invisible to visible.. ?
Post by: FalseHope on Mon 08/09/2008 10:37:44
Thanks all of you. While I was waiting for ur reply though, I found out I could just set the ShowPlayerCharacter to False for every room.

I got a second question. You know when you begin the game your first cursor is Walk To right? How do you make it to (Example)Look At.
Title: Re: Character invisible to visible.. ?
Post by: Khris on Mon 08/09/2008 10:40:22
In the first room's before fadein event, put
  mouse.Mode = eModeLookat;
Please read the manual, the Beginner's FAQ and use the forum search before posting here.
Basic questions like yours have been answered many times before.