Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 07/07/2005 00:45:07

Title: Always the character face the hotspots
Post by: on Thu 07/07/2005 00:45:07
Hi. I want the player when look,interact in any hotspot to turn his face on that.
for example:when the player comes from up to down (He is like as he sees me),and the hotspot is at the left of the screen,he won't turn over and the script will start.
I already checked the box from the "General settings" Character turns to face direction.
Don't say to put at the interaction of every hotspot, the command face location the right x,y.It's very boring!!!!
Thanks for your help.
Title: Re: Always the character face the hotspots
Post by: Ashen on Thu 07/07/2005 01:08:44
Boring yes, but perhaps the most reliable way.
How exactly would you want it to work? Would the character turn when the mouse moves over the hotspot, or when the player clicks on the hotspot?

For 'mouse over hotspot', something like:

//in 'repeatedly_execute'
if (GetHotspotAt(mouse.x, mouse.y) != 0) FaceLocation (GetPlayerCharacter(), mouse.x, mouse.y);


For 'click on hotspot':

// in 'on_mouse_click'
else if (button == LEFT) { // This bit should already be there
  if (GetHotspotAt(mouse.x, mouse.y) != 0) FaceLocation (GetPlayerCharacter(), mouse.x, mouse.y);
  Wait(1);
  ProcessClick(mouse.x, mouse.y, GetCursorMode());
}


One of them should work, anyway. If not, or if I've misunderstood what you're asking, could you be a bit more specific about what you want.
Title: Re: Always the character face the hotspots
Post by: on Thu 07/07/2005 09:34:50
Ashen thanks for the code but it doesn't work. :-[
I have AGS vers. 2.7 and the command GetHotspotAT doesn't know it.

Ok.I tried to be more specific with a example:

Let's say that i have a hotspot at the left of the screen and i set the
Walk-to point at (96,203).
I click in Interaction and at the Look at hotspot i put the player says "Nice picture!!".

If he is on (140,203),when i click the look icon he'll walk at (96,203)=walk-to point and he face looks towards the hotspot(because he came from right to left).
BUT when he is on (96,160),he will come from UP to DOWN and he'll say
"Nice picture!!" with he face looks ME!! because he came from UP to DOWN.

See the problem???
HELP!!
Title: Re: Always the character face the hotspots
Post by: hedgefield on Thu 07/07/2005 10:03:53
I think you have to manually set the characterview in every interaction script you make for a hotspot (look, use etc). This way he will always turn towards the hotspot when he reaches the walk-to point, no matter which direction he came from.



*Didn't see the part about the x-y value method, sorry. But you don't have to set the values, you only have to specify which way the character should be facing when he is on the walk-to point. E.g. you main walkcycle is view 1, and you want him to face right, then you say SetCharacterViewEx (EGO, 1, 2, ALIGN_CENTRE); Copy n paste for each interaction, changing the second number for the direction and it should work fine.
Title: Re: Always the character face the hotspots
Post by: on Thu 07/07/2005 10:17:12
I already know that!!! 8)
At my first message i said another solution except that.
It is very boring and tired. :-\
Title: Re: Always the character face the hotspots
Post by: Gilbert on Thu 07/07/2005 10:35:31
If you're using V2.7, GetHotspotAt() had undergone a name change into Hotspot.GetAtScreenXY().
Title: Re: Always the character face the hotspots
Post by: Ashen on Thu 07/07/2005 11:15:20
Yes, sorry. It was late and I couldn't think of the 2.7 code off the top of my head. Try:

// in 'on_mouse_click'
else if (button == eMouseLeft) { // This bit should already be there
  if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) != hotspot[0]) player.FaceLocation(mouse.x, mouse.y, eBlock);
  ProcessClick(mouse.x, mouse.y, mouse.Mode);
}


(Look the commands up in the manual for the proper usage, if it still doesn't work.)
Title: Re: Always the character face the hotspots
Post by: coach z on Sun 27/03/2011 18:30:07
Had same problem so searched and found this thread.  Ashen, is there a way you can face the hotspot first then go on with whatever the player does upon the click of the hotspot?  Thanks anyone who can answer.
Title: Re: Always the character face the hotspots
Post by: Khris on Sun 27/03/2011 18:38:52
Ashen has been AWOL for a few years now :(

This should work:

// in 'on_mouse_click'
  else if (button == eMouseLeft) { // This bit should already be there
    if (GetLocationType(mouse.x, mouse.y) != eLocationNothing) player.FaceLocation(mouse.x, mouse.y, eBlock);
    ProcessClick(mouse.x, mouse.y, mouse.Mode);
  }


This will make the character face the mouse position if the mouse is over a Hotspot, Object or Character.
Title: Re: Always the character face the hotspots
Post by: coach z on Mon 28/03/2011 01:27:49
Thanks Khris.  I thin I figured out the problem.  The player is saying what I have scripted him to say when he looks at an object (ex: "Nice door.") then turning to face it.  It must just be because he player is saying something and the text is not displayed instead?
Title: Re: Always the character face the hotspots
Post by: Khris on Mon 28/03/2011 01:29:53
Could you post the code you're using?
Title: Re: Always the character face the hotspots
Post by: coach z on Tue 29/03/2011 00:22:52
 else if (button == eMouseLeft) { // This bit should already be there
    if (GetLocationType(mouse.x, mouse.y) != eLocationNothing) player.FaceLocation(mouse.x, mouse.y, eBlock);
    ProcessClick(mouse.x, mouse.y, mouse.Mode);

So when I click on a hotspot the function takes place depending on if its look, interact, talk to and then the player faces it.
Title: Re: Always the character face the hotspots
Post by: Khris on Tue 29/03/2011 00:55:58
I meant could you post the door's interaction code?
Title: Re: Always the character face the hotspots
Post by: coach z on Tue 29/03/2011 22:49:17
function door_Interact()
{
player.Walk(280, 158, eBlock);
player.Say("It leads to Tesla's lab and testing facility.");
player.Say("Against my better judgment,  I'll enter, but I did not stock up on a 14 pack of replacement razor heads this weekend,  just so I can die today.");
player.ChangeRoom(3, 22, 136);
}
Title: Re: Always the character face the hotspots
Post by: Monsieur OUXX on Wed 30/03/2011 09:00:01
Always X marks the spot.



(sorry)

Title: Re: Always the character face the hotspots
Post by: coach z on Thu 31/03/2011 23:17:32
elaborate Ouxxey_games  please...
Title: Re: Always the character face the hotspots
Post by: monkey0506 on Thu 31/03/2011 23:21:08
Do you have, per chance, more than one on_mouse_click function?
Title: Re: Always the character face the hotspots
Post by: coach z on Fri 01/04/2011 07:28:35
No, but thanks for trying.