Game Development Community

Weapon help

by Rojalee · in Torque Game Engine · 03/17/2007 (4:01 pm) · 8 replies

First off, let me say I that I know there are previous posts on this issue, but I cant find them, I searched under weapon, weapon.cs, weapon help, weapon pack help and weapon tutorial.

Now here is my question. (sort of)

I have made a weapon, and I have put a bounding box on it (for collision purposes).
I have exported it in DTS format with the texture.

I have put it in the game as a shape, and it looks wonderful.

Now how can I add it as the Players weapon?

right now all I want to do is have it there. I will work on the animations, etc later.
Just now all I want to do is have it show up as the players weapon.

Thanks in advance.
Robert

#1
03/18/2007 (12:55 am)
You'll need to add nodes to it, in hatever pogram you're using to create the weapon. If you look up TDN, it gives you a list of what to name your nodes (not just for weapons). Then when you have that exported, you're ready to script it. If you want a quick way to use it, go into crossbow.cs (SDK/example/starter.fps/server/scripts), and scroll down until you find
Quote://--------------------------------------------------------------------------
// Weapon Item. This is the item that exists in the world, i.e. when it's
// been dropped, thrown or is acting as re-spawnable item. When the weapon
// is mounted onto a shape, the CrossbowImage is used.
In the block ofcode under that, find
Quote:shapeFile = "~/data/shapes/crossbow/weapon.dts";
Change the part in quotation marks to the file directory of wherever you've stored your .dts file.
Then scroll down a little, and do the same in the next reference to shapeFile you find, in the code block named
Quote://--------------------------------------------------------------------------
// Crossbow image which does all the work. Images do not normally exist in
// the world, they can only be mounted on ShapeBase objects.
This should replace the default crossbow in starter.fps with your model.
#2
03/18/2007 (4:14 am)
Why would I need to add nodes to it?
#3
03/18/2007 (5:42 am)
You need to add a node to tell Torque where you want your player to hold your weapon (called mountPoint) and another node to tell it where to spawn the weapon's projectile (called muzzlePoint).

The key to weapons is an object called a StaticShapeImageData. This datablock defines how your weapon behaves. Once you've written the datablock for your weapon, you can mount the image to your player using the mountImage method. The player then holds your weapon and can fire it.

--Amr
#4
03/18/2007 (8:09 am)
Hmm, there was a really good reasource for adding weapons that you could pick up and swich to.

I can't seem to find it anymore though, it doesn't seem to exist anymore.
#5
03/18/2007 (8:11 am)
Ok, I just checked my bookmarks and I had it bookmarked!

Here it is:

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5907


Hope that helps!
#6
03/18/2007 (8:18 am)
Quote:Why would I need to add nodes to it?
Nodes are how Torque knows what to do with a weapon (and specifically, where to do it). For example, the mountPoint node tells Torque where the player should hold onto the weapon. muzzlePoint is where the bullet will be emitted. Et cetera.
#7
03/18/2007 (9:02 am)
Where you adding them two nodes go ahead and add the ejectpoint. Put this node where the shell eject from the gun.
#8
03/19/2007 (4:23 am)
So for a melee weapon, I only need the mountPoint node?

And for projectile weapons, 3 nodes. mountPoint, muzzlePoint, ejectPoint ?

That tut link is for Cycling Weapons....I just want to add them to the player as the default weapon.

(trying to learn one thing at a time)