Example of Crossbow use on shapebase object
by Demolishun · in Torque Game Engine · 10/11/2005 (9:34 pm) · 5 replies
Does anyone have a barebones use of the crossbow on a shapebase object using the inventory from 1.3 and firing using a trigger or "think" function?
Edit:
Let me explain what I need help with.
I cannot tell where the crossbow code begins and ends. Is it in the client a server code? I also cannot tell how to properly setup using the inventory that the crossbow uses. Where are all the calls for it as well and what do the datablocks need to look like? I have tried trial and error with no progress. I even checked the C++ code to see if there was stuff that needed to be in there and could not find anything. I would like to be able to mount weapons in a "standard" way to get things working and then change as needed.
Thanks,
Frank
Edit:
Let me explain what I need help with.
I cannot tell where the crossbow code begins and ends. Is it in the client a server code? I also cannot tell how to properly setup using the inventory that the crossbow uses. Where are all the calls for it as well and what do the datablocks need to look like? I have tried trial and error with no progress. I even checked the C++ code to see if there was stuff that needed to be in there and could not find anything. I would like to be able to mount weapons in a "standard" way to get things working and then change as needed.
Thanks,
Frank
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
#2
character.mountimage(weapon,slot)
I dont have any reference in front of me so you should check that function before you use it.
in order to mount an image onto a particular part(slot) on a shapebase object, you need to export the object with a "mount#" node where # is any number from 0-7. when you make a call to mountimage the slot number corresponds to the mount number you want it attached to. so in order to have the crossbow oriented to the muzzle of the turret, you could export the turret with a node called "mount0" at the muzzle and then call:
turret.mountimage(crossbow,0) because you want the crossbow at mount0.
10/14/2005 (7:02 am)
Frank what you need to do is mount the crossbow to the turret. the code handling inventory, mounting, activation and weapon characteristics are spread out in multiple files but, in general, using a weapon in the standard way involves mounting a shapebaseimage(crossbow) onto a shapebase object. this is done with a call to: character.mountimage(weapon,slot)
I dont have any reference in front of me so you should check that function before you use it.
in order to mount an image onto a particular part(slot) on a shapebase object, you need to export the object with a "mount#" node where # is any number from 0-7. when you make a call to mountimage the slot number corresponds to the mount number you want it attached to. so in order to have the crossbow oriented to the muzzle of the turret, you could export the turret with a node called "mount0" at the muzzle and then call:
turret.mountimage(crossbow,0) because you want the crossbow at mount0.
#3
I actually got that far, but now I am having some very interesting problems. The crossbow does point where the turret points because it is properly mounting at mount0 point. However when the crossbow fires it shoots from where it originally was pointing before the turret just animated. Now to add some really strange behavior I tried substituting the calls to:
%muzzleVector = %obj.getMuzzleVector(%slot);
%muzzlePoint = %obj.getMuzzlePoint(%slot);
with:
%muzzleTrans = %obj.getSlotTransform(%slot);
%vec[0] = " 0 1 0";
%vec[0] = MatrixMulVector( %muzzleTrans, %vec[0]);
%muzzleVector = %vec[0];
%muzzlePoint = getWords(%muzzleTrans,0,2);
Seems to be almost correct. It still shoots above my head, but that could be that bug in the math for the turret manifesting itself. I will look into that part later. What really bugs me is that the original code is what the crossbow uses with the player and it works perfectly. Maybe there is something in the source code different between the player and turret that is messing this up. It almost acts as though some variables are not getting updated somewhere.
10/14/2005 (8:56 am)
Thanks Sean,I actually got that far, but now I am having some very interesting problems. The crossbow does point where the turret points because it is properly mounting at mount0 point. However when the crossbow fires it shoots from where it originally was pointing before the turret just animated. Now to add some really strange behavior I tried substituting the calls to:
%muzzleVector = %obj.getMuzzleVector(%slot);
%muzzlePoint = %obj.getMuzzlePoint(%slot);
with:
%muzzleTrans = %obj.getSlotTransform(%slot);
%vec[0] = " 0 1 0";
%vec[0] = MatrixMulVector( %muzzleTrans, %vec[0]);
%muzzleVector = %vec[0];
%muzzlePoint = getWords(%muzzleTrans,0,2);
Seems to be almost correct. It still shoots above my head, but that could be that bug in the math for the turret manifesting itself. I will look into that part later. What really bugs me is that the original code is what the crossbow uses with the player and it works perfectly. Maybe there is something in the source code different between the player and turret that is messing this up. It almost acts as though some variables are not getting updated somewhere.
#4
www.garagegames.com/mg/forums/result.thread.php?qt=35623
10/14/2005 (11:26 am)
I have a solution to this, but I am having a hard time understanding why it works. However since this requires a C++ mod I am moving this thread to here:www.garagegames.com/mg/forums/result.thread.php?qt=35623
#5
01/02/2006 (11:17 pm)
I am not able to open the "Crossbow.max" in 3dmax5. It shows me an error message "an error has occurred and the application will now close". So can any one tell me the problem. And this is made with which version?
Torque Owner Demolishun
DemolishunConsulting Rocks!