Game Development Community

Some torque questions

by Travis Rupp-Greene · in General Discussion · 07/23/2009 (3:02 pm) · 4 replies

I am pretty new to torque, and I was wondering how I would go about making usable objects (or npcs) and sounds that occur in random intervals, like a lightning storm or something.

If you want more details, I am trying to make a game where you are a vampire that can move and jump with superhuman ability. The goal is to move around town and bite victims necks while avoiding the city watch. You have to get a certain amount of blood before the sun comes up, and when it does, you have to return to your lair before you burn to death. It isn't for any commercial gain, just an experiment so I can learn torque.

I would greatly appreciate it if you could tell me how or give me a push in the right direction. Thanks!

About the author

Recent Threads


#1
07/23/2009 (6:09 pm)
Do you mean making models of the objects, or
writing code to animate the objects!
#2
07/23/2009 (8:59 pm)
I am talking about the code part. Like how would I code something to make sounds at random intervals, and how would i code some thing to react to a keypress while in contact with the player?
#3
07/27/2009 (5:48 pm)

Sounds at random interval:

Do a schedule and modulate a basic time interval by getRandom(). In the scheduled function, play a sound.

Key trigger when something is in contact with player:

I think this partly depends on what it is the player is in contact with. To bind a game function to a key, use the bind method of the MoveMap action map. In the function, check if the condition is true.

You could also temporarily alter the keybinding when going into and out of collision.

On shape objects, the function that gets called on collision is "onCollision". This gets called on the shape's datablock. There's examples on using it in the standard scripts.

However, as for getting notified when an objects moves *out* of the collision, AFAIK only triggers do that.

You could write similar functionality yourself, though. Example: toggle a flag on in onCollision when the player enters your object. Check this flag in the function bound to the key. However, if the flag is true, check first whether the player is still colliding with your object.
#4
08/02/2009 (2:52 pm)
Thanks a bunch man!