Use Script or Code?
by Griffin Milsap · in Torque Game Engine · 04/30/2006 (10:28 am) · 5 replies
Hey, I have a pretty quick question.
I have a vehicle which is controlled by the computer. Once per frame, it gets told where it has to be, via an X,Y,Z coord. There is however, no simple way to do this. The player has no control over the movement of the vehicle, but he still needs to follow it. It doesn't need to be any fancy class like flyingVehicle. I don't need any of the physics code associated with the vehicle. All I'm interested in is moving a static mesh around.
Heres the question. Would it be better to control this object from the script or the engine itself?
-Griff
I have a vehicle which is controlled by the computer. Once per frame, it gets told where it has to be, via an X,Y,Z coord. There is however, no simple way to do this. The player has no control over the movement of the vehicle, but he still needs to follow it. It doesn't need to be any fancy class like flyingVehicle. I don't need any of the physics code associated with the vehicle. All I'm interested in is moving a static mesh around.
Heres the question. Would it be better to control this object from the script or the engine itself?
-Griff
About the author
#2
The vehicle flies too, so it couldn't follow the terrain, as the track it flies on has no collision.
Most times, the move between frames is a few inches, but it would acheive a very smooth movement.
It appears to me that the code is the way to go with this, but now I need to figure out how to actually create a simpleshape from code.
It shouldn't be difficult to find.
-Griff
04/30/2006 (11:16 am)
Well, basically, I have a path for the vehicle to follow. If I set waypoints, it just doesn't follow the path closely enough, and it takes up processing power to calculate the translation between the waypoints.The vehicle flies too, so it couldn't follow the terrain, as the track it flies on has no collision.
Most times, the move between frames is a few inches, but it would acheive a very smooth movement.
It appears to me that the code is the way to go with this, but now I need to figure out how to actually create a simpleshape from code.
It shouldn't be difficult to find.
-Griff
#3
04/30/2006 (12:49 pm)
Have you looked into the Pathshape resource?
#4
Also, you don't have to worry about having to use static, pre-made pathes. The pathShape (and the pathCamera as well) don't actually use the path objects directly. Instead, it has a C++ method you use to add nodes to build the path it'll follow.
By default, the resource features script code that can feed a pathShape/pathCamera a standard TGE path (the one you can build using the editor), but you're free to make build paths dynamically based on your own criteria.
04/30/2006 (8:07 pm)
Yes, the pathShape resource would be ideal for this, as it allows a shape to follow a path, just like the pathCamera does.Also, you don't have to worry about having to use static, pre-made pathes. The pathShape (and the pathCamera as well) don't actually use the path objects directly. Instead, it has a C++ method you use to add nodes to build the path it'll follow.
By default, the resource features script code that can feed a pathShape/pathCamera a standard TGE path (the one you can build using the editor), but you're free to make build paths dynamically based on your own criteria.
#5
It just so happens that I reinvented the wheel on this one.
I looked at the source for pathshape, and I found that its the exact same for what I made.
The only difference is that my vehicle must be rotated to point the right direction.
PathShape uses ITickable, and so does mine, but I havn't figured out how to interpolate between the ticks. Now, with that resource, I can finish off my class.
-Griff
Thanks a bunch
05/02/2006 (8:24 pm)
Wow,It just so happens that I reinvented the wheel on this one.
I looked at the source for pathshape, and I found that its the exact same for what I made.
The only difference is that my vehicle must be rotated to point the right direction.
PathShape uses ITickable, and so does mine, but I havn't figured out how to interpolate between the ticks. Now, with that resource, I can finish off my class.
-Griff
Thanks a bunch
Torque Owner Cinder Games
Script is called every like 32ms or something, which might not be every frame. Iv'e been unable to get smooth movement of static meshes via script this way.
Why don't you just make the vehicle a type of AI Vehicle, so you can set a setmovedestination?