Basic Useful Object-Interaction Commands
by Bill "Black Manatee" Pomidor · in Torque Game Engine · 01/10/2006 (7:12 pm) · 1 replies
Howdy--
I've had TGE for about a year now and have been very impressed with the way things have evolved to become more newbie-friendly. I've used Finney's excellent "3D Game Programming All-In-One," as well as a lot of the excellent tutorials on-line (and I've just ordered Ken's sequel!).
However, I have to admit to being a little frustrated about some simple game-design issues--mainly because I can't find a lot of script operators/functions that seem like they would be in common use--especially with regard to objects and/or NPC's. For instance, I'm having a heck of a time finding a resource or TorqueScript command that simply checks the distance between the player and a given object or NPC (or another player) and returns the value. I've seen a suggestion about calculating vectors, but I had the impression that was for checking angles rather than distances. And I know you could calculate the x,y,z coordinates for both objects and subtract to compare, but the math involved would seem like an inefficient use of the script engine's processor resources--especially if you've got a lot of objects moving at once. I'd like to use this kind of command for triggering NPC interaction and also possibly for pathfinding--at least for some of the NPC's...
Other common commands, like getting an object to "track" a player or another object, or "freezing" the action in a game while a video plays (or getting the video to play on a certain trigger) also seem surprisingly complex. I know that there are work-arounds which can be created either in C++ or through creative use of some of the Script variables, but I was wondering if maybe there's a resource or list of variables/operators that I've missed in my travels through the TDN and the various tutorials/guides. I'm hoping that the Advanced 3DGPAIO book might be able to offer some pointers as well. But if anyone has any suggestions for me, I'd really appreciate it. Thanks!
~~Bill
I've had TGE for about a year now and have been very impressed with the way things have evolved to become more newbie-friendly. I've used Finney's excellent "3D Game Programming All-In-One," as well as a lot of the excellent tutorials on-line (and I've just ordered Ken's sequel!).
However, I have to admit to being a little frustrated about some simple game-design issues--mainly because I can't find a lot of script operators/functions that seem like they would be in common use--especially with regard to objects and/or NPC's. For instance, I'm having a heck of a time finding a resource or TorqueScript command that simply checks the distance between the player and a given object or NPC (or another player) and returns the value. I've seen a suggestion about calculating vectors, but I had the impression that was for checking angles rather than distances. And I know you could calculate the x,y,z coordinates for both objects and subtract to compare, but the math involved would seem like an inefficient use of the script engine's processor resources--especially if you've got a lot of objects moving at once. I'd like to use this kind of command for triggering NPC interaction and also possibly for pathfinding--at least for some of the NPC's...
Other common commands, like getting an object to "track" a player or another object, or "freezing" the action in a game while a video plays (or getting the video to play on a certain trigger) also seem surprisingly complex. I know that there are work-arounds which can be created either in C++ or through creative use of some of the Script variables, but I was wondering if maybe there's a resource or list of variables/operators that I've missed in my travels through the TDN and the various tutorials/guides. I'm hoping that the Advanced 3DGPAIO book might be able to offer some pointers as well. But if anyone has any suggestions for me, I'd really appreciate it. Thanks!
~~Bill
Torque 3D Owner Matthew Langley
Torque
All a vector is, is the distance an object is from 0,0 (the origin)... so an example vector could be 5, 15... the difference between this and positions is that you can manipulate what 0,0 (the origin) is to calculate more information, such as offsets, angles, etc.
Cartesian coordinates are the 0 0 format, while polar coordinates of a vector is something along the lines of 30 distance at 45 degrees... you can convert back and forth between the two to get distance offsets and many other things.