Tank Physics and resources
by NUTS! · in Torque Game Builder · 11/16/2006 (10:52 pm) · 6 replies
I am a rather new owner with TGB I have been messing around with a lot of the tutorials and found them very helpfull. I just started messing with the tank physics one and have some questions. My first questions is how the heck do I get that thing to shoot? I tried doing what I learned from the scroller demo, did not help. Couldn't figure out a way to add missileSpeed,etc, when its (tankTurret) is being added and mounted by script. Which leads me to the second question, when pulling stuff from the resource folder were do you make changes with the scripts, in the resource folder? Is it possible to use the mounting function in TGB and have it seperate the turret from tankChassis or can that only be done with a script.
About the author
#2
Thanks for the info. That was pretty much the conclusion I was coming too. I am not to much of a scripter, but I think I should be able to handle this.
11/18/2006 (12:35 pm)
@TankDorkThanks for the info. That was pretty much the conclusion I was coming too. I am not to much of a scripter, but I think I should be able to handle this.
#3
This is what my scrpt looks like now :
11/27/2006 (4:14 pm)
I was able to get everything to work. Except for one thing. My bullets only go "up". I can get the turret to move and all that but when it fires the bullets they only go in one direction (to the top of the page). Is it possible to get the bullets to fire at your mouse? Additionally, how do you change it so the bullets come out of the turret barrels instead of just the middle of the turret.This is what my scrpt looks like now :
function shoot() {
%tankPosition = turret.getposition();
%mousePostion = sceneWindow2D.getMousePosition();
%difference = t2dVectorSub(%mousePosition, %tankPosition);
%dx = getWord(%difference, 0);
%dy = getWord(%difference, 1);
%shotAngle = mRadToDeg(mAtan(%dy, %dx));
%bullet = new t2dStaticSprite() { scenegraph = sceneWindow2D.getSceneGraph(); };
%bullet.setPosition( %tankPosition );
%bullet.setImageMap( "ggLogoImageMap" );
%bullet.setSize = "8 8";
%bullet.setLinearVelocityPolar( %shotAngle, 150 );
$nextScheduledShot = schedule(250, 0, "shoot");
#4
12/13/2006 (5:05 pm)
I must admit, where is this tank demo? I would like to check it out after reading this thread...
#6
12/13/2006 (5:37 pm)
Sweet thanks :)
Torque Owner Tank Dork
Edit: resources.. I dug into them a little deeper.. built one of my mini games into a build and discovered that it will import into your game just fine.. just make sure to delete the .cs files and leave the .dso.. the build doesn't zap them. :/
Resources are a way to add stuff to your game in a modular way.. a good resource should be very narrow in scope so as not to interfer with anything besides what its adding.. such as the tank, car, or boat physics ones on TDN.. all the resource does is sets up the parameters in TGB for the object it adds (makes datablock, sets "type", and size, etc).. when you build your project TGB will make a "resources" folder in your game with the info.. They seem to be great for small projects or as mini-tutorials that set it all up nice and neat for you... but in the long run I think striping the meat out and making your own scripts and datablocks would be easier.