Game Development Community

Scripting questions

by Ean Huddleston · in Torque Game Engine · 10/20/2006 (1:09 am) · 4 replies

I'm working on creating a psychology experiment using TGE. I have all the assets for my experiment, but I'm new to TGE scripting and game scripting in general, so am stumbling a bit on how to code my experiment. Here's the basic idea of what I'm trying to do:
- have an object appear in front of the player/subject
- the subject looks at this object, then moves his player to an appropriate location within the game level (there will be 12 different objects, and each object will cue the subject to move the player to a unique location)
- when the subject's player enters that location, he is then transported back to the starting location
- this cycle repeats with all 12 objects until a criterion is met

Here are some questions I have, in case you can help me out with any of them:

- how do I set up the "control" of my experiment? Do I make a master loop that keeps iterating through the objects, then waiting for the subject to move to particular locations? Or do things need to be more "event driven," where each object, when touched, calls functions that determine what should happen next?
- in which file(s) should I insert my scripts?
- should I create all 12 objects at the beginning of the experiment, then only make 1 of them visible at a time? Or should I create and delete objects as needed?

Thanks in advance for any help or advice you can give me.

Ean

#1
10/20/2006 (2:33 am)
Well heres one way to do it it may be the easiest so its quite good for you:

code a script if the player has collided with the object, and when you collide with the object it warps you somewhere VERY far from that original object you picked up. So thatd be probably the esiest way.

Do you think you could code this or do you need some help?
#2
10/20/2006 (7:30 am)
When the object appears in front of the player how does the player know to go to the specific area? Does it say on the object, or is the player familar with the game area?

Basically you can do this by making variables and when the player collides with the 'area' you want them to go to (which could be an object or it could just be a trigger) you can set the variable to a '1' or true and then reset the players position. When all the variables == 'true' you can end the game, or start over or change levels, etc.. whatever you want to do. You can check the variables if they all == "true" when the player collides with the area (the trigger).

As for the objects, if you just want to do one at a time just make one appear at first then after they get positioned back at the start check what the last object was and make the next object appear.. using a switch statement or however you like.
#3
10/20/2006 (2:34 pm)
Thanks for the suggestions guys.

@mb - The player won't at first know which location to run to for a given object; but a step I left out in my previous post is that after they are shown an object and run to the location they think it should go in, that object will then appear in the location that it *should* go in. So given this feedback, the player will eventually learn to run to the correct location.

A few more questions:

- in which files would you recommend putting the script that creates the variables? (I'm using the starter.fps files to start from)
- I think I'll use 12 triggers to detect when the player has moved into one of the 12 locations, then have all these triggers call a single function. The function will then check if the location is correct, change bookkeeping variables accordingly, and make the next object appear. Is this a good approach? In which files should I put the script for the triggers and main function?

Thanks again,

Ean
#4
10/20/2006 (10:06 pm)
Ahh now i understand :D
I'd say server\scripts\game.cs would be a good place to start. the triggers can be in seperate files.