Actor appearing once only

Non-platform specific questions.

Actor appearing once only

Postby Diana Kennedy » Wed Mar 18, 2009 10:25 pm

When I create a character using a periodic or random timer set to Number 1, the actor will constantly reapeat appearing as soon as he is out of the view. I solved the problem by the destroy actor action, as soon as the actor is put of view or at the end of the path. Problem is, I now need the characther active and alive even it is out of view. How can I make it that he does appear really ONCE only after his creation? If it requires scripting please explain it to me as you would to a 2 year old. :wink:
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: Actor appearing once only

Postby skydereign » Thu Mar 19, 2009 12:33 am

If I get what you are aiming at, you want to create the actor only once, and this is done by an omnipresent timer. I believe all you would need is a variable. Where the timer creates your actor, set an if statement. So it will create the actor only when there is no other actor created.
Code: Select all
if (ActorCount("ACTOR")==0)
{
    //CreateActor
}

Sorry if this is not what you wanted, if it isn't can you explain a little more? What I don't understand is, when do you want to create the actor, and when do you not. I am not really sure on the random creation repeating if not on screen.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Actor appearing once only

Postby Diana Kennedy » Thu Mar 19, 2009 6:40 pm

Yes, you understood it right! That is exactly what I need. Unfortunateley the script does not work. I was probably too dumb to put it in the right way. Here is waht I did:

Timer -> Scrupt Editor and then wrote in:

Code: Select all
if (ActorCount("Tarpan")==0)
{
    //CreateActor("Tarpan", "tarpantangallop01", "(none)", "tarpan1", 494, 160, true);
}


Now the actor does not appear at all.
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: Actor appearing once only

Postby skydereign » Thu Mar 19, 2009 7:12 pm

Oh, I forgot that you are new to scripting.
Code: Select all
// The two slashes mean the line is commented out, in gameEditor, it will turn the code light blue
// this means that it will ignore this code. You can put them in to explain your logic, or show what needs fixing
// etc. Another way to do this is,
/*
These are also commented out
eventhough I don't have the //
*/
// so just get rid of the two // in front of the CreateActor

It should be this.
Code: Select all
if (ActorCount("Tarpan")==0)
{
    CreateActor("Tarpan", "tarpantangallop01", "(none)", "tarpan1", 494, 160, true);
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Actor appearing once only

Postby Diana Kennedy » Thu Mar 19, 2009 9:51 pm

Thank you for explaining me what the slashes mean. Yes, I am really a total noob in Scripting.
I copied the new code in, but still, the actor doesn't appear at all, now. :?
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: Actor appearing once only

Postby skydereign » Thu Mar 19, 2009 9:55 pm

Could it be that the actor is not created on the screen? I don't know what regulation you are doing to keep the actor on the screen. This will also not work if there is another actor of the same kind already. Can you give more detail on your setup?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Actor appearing once only

Postby Diana Kennedy » Fri Mar 20, 2009 9:52 pm

skydereign wrote:Could it be that the actor is not created on the screen?


What do you mean exactly? If the actor is created outside the view? Well it was indeed and so I changed it the way it is created inside the view. Still, it does not work.

I don't know what regulation you are doing to keep the actor on the screen. This will also not work if there is another actor of the same kind already. Can you give more detail on your setup?


I will try. Here is a screenshot of my actual working stage on that project.


Image

The actor in the upper left side A1, circled in red is the one that should create the Actor tarpan, that is the horse in the lesser right corner, also circled in red. There is a path "tarapan". A1 is now supposed to to create a timer at its own creation and this Timer:

Image

Should now create the Horse, which is set to follow the Path Tarpan, and therefore, gallop into the screen from the right to the left. When I do this with the normal create Actor function on the timer, the horse may appear at random in the first time, but then reappear constantly as soon as it has vanished from view. I could set a "destroy actor at path finish or at out of vision, but in fact this would prevent the hunter's arrow to take it down, even if it is out of view. 5and that is required. Since the Hunter can then move forward and find the prey.

Well actually I tried again with the non-szcript method and now, the horse does not appear also. So there must be a deeper Problem.
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: Actor appearing once only

Postby Diana Kennedy » Fri Mar 20, 2009 10:05 pm

UPDATE: I just created another timer and tried it with this one and your script and this time it WORKS! So the old timer must have had a problem. Really dont't know what kind of problem it was, but it is not the first time that some timers just refuse to work. So thank you very much for your help !! :D
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: Actor appearing once only

Postby BlarghNRawr » Sun Mar 22, 2009 3:54 pm

[quote="skydereign"]Oh, I forgot that you are new to scripting.
Code: Select all
// The two slashes mean the line is commented out, in gameEditor, it will turn the code light blue
// this means that it will ignore this code. You can put them in to explain your logic, or show what needs fixing
// etc. Another way to do this is,
/*
These are also commented out
eventhough I don't have the //
*/
// so just get rid of the two // in front of the CreateActor


can i use // in the actual script editor? i thought it was just in the forum... oops
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: Actor appearing once only

Postby jimmynewguy » Wed Mar 25, 2009 1:31 am

kool looking and sounding game by the way, did u draw the sprites yourself? :lol:
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Actor appearing once only

Postby Diana Kennedy » Sun Mar 29, 2009 4:03 am

jimmynewguy wrote:kool looking and sounding game by the way, did u draw the sprites yourself? :lol:



Yes, I did. Glad you like it.
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron