I need help moving a character from one room to the next.

Started by Last Boy Scout, Mon 16/08/2010 08:12:45

Previous topic - Next topic

Last Boy Scout

Hi,

I'm just starting out, have 2 rooms built and I want to be able to move the character into the next room. I made the front door a hotspot, but the character can't walk into the next room when he touches it.

Under the edges event list I selected "room_Leave" and still nothing happens when you approach the doors.

I'm really frustrated with this simple problem and can't find any answers on the forum or in the manual for this.

I'm sure someone knows the solution to this. Please help!

Matti

Quote from: Last Boy Scout on Mon 16/08/2010 08:12:45
Under the edges event list I selected "room_Leave" and still nothing happens when you approach the doors.!

There is no "edges event list", that's the room event list and you chose room_leave which is called as soon as the character left the room.

Quote
I'm just starting out, have 2 rooms built and I want to be able to move the character into the next room. I made the front door a hotspot, but the character can't walk into the next room when he touches it.

If you put a character.ChangeRoom() command in the hotspot's interaction event (like 'interact hotspot' or 'any click on hotspot') then it should work just fine.

Mouth for war

mass genocide is the most exhausting activity one can engage in, next to soccer


Khris

You'd use a region and its "player steps onto region" event.

Using the edge should work, too: in the room editor, select "Show this room's" edges, then move the line so that the character's feet can cross it.

Last Boy Scout

Thanks guys,

         I tried what all of you said, I feel it's close to working, but when the player tries to interact with the hotspot the game crashes.

         It says this:

         Error: prepare_script: error -18 (no such function in script) trying to run 'cEgo.ChangeRoom()'  (Room 1)

          I'll play around with it a bit more. If anyone still has any suggestions for this problem please let me know.

           :-\


Khris

It doesn't work like that; you don't put the script command ('cEgo.ChangeRoom()') directly into the field.
Remove all text from the field.

What you do is you click on the event text in the table, in this case "Interact hotspot". A small button should appear at the end of the empty field next to it, showing "...".
Click that button.
AGS will put the function name into the field and append the function to the room script. The room script is opened or made the active tab. At the end you should see the newly created function:

Code: ags
function hHotspot1_Interact()
{

}


(My hotspot was still named hHotspot1, it's recommended to rename the hotspot to something appropriate like "hDoor" before clicking the ellipses button.)
If you go back to the hotspot's event list, you can see that in the previously empty field next to the event name it says now "hHotspot1_Interact" (or "hDoor_Interact", or whatever you named the hotspot, with "_Interact" added at the end).

(It's still possible to rename the function to something else; however, the function name and the text in the field must be identical (capitalization included), otherwise you'll get the same error again.)

The final step is to put the script command inside the function's body, i.e. in between the { and }:

Code: ags
function hHotspot1_Interact()
{
  player.ChangeRoom(2);
}


("player" is a substitute for the currently active character.)


Note that all the main parts of my explanation can be found in the tutorial that comes with AGS. Open the helpfile and go to Tutorial -> Starting off -> Tutorial Part 3 - Hotspots and events.

Last Boy Scout

Khris,

         I think putting the room number inside the parenthesis helped. For some reason the hot spot command didn't quite work, however, when I used this same technique for edges it did! Go figure.

         I was finally able to change rooms and come back to the first room. It took a lot of work but I was able to pull it off with a bit of your help and every one else's. Whew!

         I'll keep you posted if I have any more problems with this. Thanks a lot! That was a big help.



         

DoorKnobHandle

You might be interested in densming's video tutorials, they are well done and explain simple stuff like interactions in a visual and easy to follow manner. Might clear up future issues as well!

SMF spam blocked by CleanTalk