Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: armiin on Fri 30/04/2010 01:22:44

Title: Make an action when a character was in x-y position or in other view.
Post by: armiin on Fri 30/04/2010 01:22:44
Hi,

I have a problem:
My character need to take an object, to  do this he need to disturb another character. That character goes to other point and start a new view of him. THEN, my character must can take the object.
Here I have another problem, i need that second character stay only a few seconds there, then he come back. My character need to take thisobject in that time. How can i script this?

Thanks and sorry about my bad english!
Title: Re: Make an action when a character was in x-y position or in other view.
Post by: Khris on Fri 30/04/2010 07:47:20
In the pick up (or interact) script of the object, check if the character is animating or their position is different from where they were standing when watching the object. (It depends on when exactly the character will catch you; are they distracted as soon as they move away or only when animating at the second position.)
So all you need is e.g. if (cOtherguy.x != 153) or if (cOtherGuy.Animating && cOtherGuy.View == 4).

To make them go back after a few seconds, use a timer. SetTimer(1, seconds*GetGameSpeed()); when he gets disturbed.
Add the repeatedly_execute event to the room and in there, use
  if (IsTimerExpired(1)) {
    cOtherGuy.UnlockView();  // stop animation
    cOtherGuy.Walk(153, 180);  // walk back to initial coordinates
  }