Making sword weapon swing
by Rushh · in Technical Issues · 12/29/2007 (10:58 pm) · 10 replies
I have created a sword weapon and created the codes for attacking players. But how do i make the sword swing? Do I have to include an animation in the dts file of the sword? If its true, how do i implement it with my player?
Thanks!!!!
Thanks!!!!
#2
12/30/2007 (1:46 am)
Ok...lets say i make the hand swing...so the sword mounted on the hand will follow also?
#3
12/30/2007 (2:22 am)
Yes, your sword will follow any movement of it's mount node.
#4
12/30/2007 (3:23 am)
There is a catch though, if you're looking for melee. PlayThread animations aren't actually animated on the server, on the client only. This means you'll have to enable this (rather easy to do) if you want to detect collisions with your sword server side.
#5
Thanks 4 the help...
12/30/2007 (9:43 pm)
Erm...is there any easy reference or website in garagegames that shows how to do the sword melee? I have a vague idea of doing it..I am stuck at the swinging part and collision with the player if it hit the player with the sword....Thanks 4 the help...
#6
I toyed with these resources a bit, took the same concept but made it a bit cleaner and flexible in it's implementation. A rough outline would be the following.
1) Subclass shapbase for the weapons, instead of using a shapeimage.
2) Animate the player on the server.
3) Fix the bug where playthread animations don't automatically reset.
4) Whip up some simple functions to determine if an animation thread is playing or not.
5) In the subclass's processtick(), check for collisions only when the sword is animating.
*Edit: Torque code removed. Noticed this isn't a private forum.
12/31/2007 (1:16 am)
There's a few resources around. They all tend rely upon a raycast down the length of the weapon that intersects with the bounding box of the player, but not the player itself. So the collisions won't be incredibly accurate.I toyed with these resources a bit, took the same concept but made it a bit cleaner and flexible in it's implementation. A rough outline would be the following.
1) Subclass shapbase for the weapons, instead of using a shapeimage.
2) Animate the player on the server.
3) Fix the bug where playthread animations don't automatically reset.
4) Whip up some simple functions to determine if an animation thread is playing or not.
5) In the subclass's processtick(), check for collisions only when the sword is animating.
*Edit: Torque code removed. Noticed this isn't a private forum.
#7
If export as .dsq, I want the animation to show swinging when i click the fire on the mouse (triggering). In the code how to implement it?
I saw the codes below. So do i place the .dsq codes here?
01/01/2008 (1:04 am)
Lets say i make an animation of the player hand swing (in MilkShape 3D 1.8.2). So after doing that I need to export as dsq file or dts file or both? I am a it bit confused as the difference between .dts and .dsq..If export as .dsq, I want the animation to show swinging when i click the fire on the mouse (triggering). In the code how to implement it?
I saw the codes below. So do i place the .dsq codes here?
// Load dts shapes and merge animations
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "~/data/shapes/player/player.dts";
sequence0 = "~/data/shapes/player/player_root.dsq root";
sequence1 = "~/data/shapes/player/player_forward.dsq run";
sequence2 = "~/data/shapes/player/player_back.dsq back";
sequence3 = "~/data/shapes/player/player_side.dsq side";
sequence4 = "~/data/shapes/player/player_fall.dsq fall";
sequence5 = "~/data/shapes/player/player_land.dsq land";
sequence6 = "~/data/shapes/player/player_jump.dsq jump";
sequence7 = "~/data/shapes/player/player_standjump.dsq standjump";
sequence8 = "~/data/shapes/player/player_lookde.dsq look";
sequence9 = "~/data/shapes/player/player_head.dsq head";
sequence10 = "~/data/shapes/player/player_headside.dsq headside";
sequence11 = "~/data/shapes/player/player_celwave.dsq celwave";
sequence12 = "~/data/shapes/player/player_dieknees.dsq die";
};
#8
Think of .dts as the skinned character and the .dsq as the animation sequence for that character. As for the reason they are separated, if the bone structure is configured in a similar manner, you can then use the same .dsq file for multiple models. For example, a male and female character swinging the sword. You would obviously need two .dts files but only a single .dsq to generate the animation for both.
tdn.garagegames.com/wiki/DTS/Getting_Started
Have a look through that section on TDN. As is usually the case with TDN, there will be a lot of missing information. But your questions are at such a base level it's likely to help. I would also go looking around in the artist forum. There will undoubtedly be a thread or two there about exporting and animating milkshape characters. Your query really is an more of an art one and less of a programming one.
01/01/2008 (2:37 am)
Oh, that's a far more fundamental question than the code I had posted was geared to answer.Think of .dts as the skinned character and the .dsq as the animation sequence for that character. As for the reason they are separated, if the bone structure is configured in a similar manner, you can then use the same .dsq file for multiple models. For example, a male and female character swinging the sword. You would obviously need two .dts files but only a single .dsq to generate the animation for both.
tdn.garagegames.com/wiki/DTS/Getting_Started
Have a look through that section on TDN. As is usually the case with TDN, there will be a lot of missing information. But your questions are at such a base level it's likely to help. I would also go looking around in the artist forum. There will undoubtedly be a thread or two there about exporting and animating milkshape characters. Your query really is an more of an art one and less of a programming one.
#9
01/04/2008 (8:32 pm)
I took some dsq file and made the swing action using playthread. It works but it keeps repeating the animation without stopping. So i have to do manually in codes to stop it? How do i check for the collision when the swing is animated? Any hint to start with? Thanks.
#10
There's a bug with non-cyclic animations which caused them not to be reset. You could only use them once as the engine thought they were still running. I'm not sure if the fix was rolled into torque, haven't looked at that code in ages. Look at the link below.
garagegames.com/mg/forums/result.thread.php?qt=60472
I can't quite help you much in terms of melee collision here. As I mentioned in my post above, it requires code and this is not a private forum. There are a couple of resources around that could give you some ideas.
01/04/2008 (10:40 pm)
I'm guessing you created it as a cyclic animation.There's a bug with non-cyclic animations which caused them not to be reset. You could only use them once as the engine thought they were still running. I'm not sure if the fix was rolled into torque, haven't looked at that code in ages. Look at the link below.
garagegames.com/mg/forums/result.thread.php?qt=60472
I can't quite help you much in terms of melee collision here. As I mentioned in my post above, it requires code and this is not a private forum. There are a couple of resources around that could give you some ideas.
Torque Owner Michael Bacon
Default Studio Name