Swords
by Skylar Kelty · in Torque Game Engine · 12/11/2005 (2:23 am) · 5 replies
Hi,
How do i get the player to swing the sword instead of launching it?
I believe there was a melee thread on how to do it but I cant find it now.
How do i get the player to swing the sword instead of launching it?
I believe there was a melee thread on how to do it but I cant find it now.
About the author
#2
12/11/2005 (2:36 am)
I have the medieval weapons pack
#3
If that don't work let me know. I pasted that from source to my melee code but I had some additional code in there for teams that I removed for simplicity, it should work though.
To animate the character when you swing you would need some animations and to put them into your sequences (yourdir/data/shapes/player/player.cs for example) like so:
Then in the swing block you'd have to play the animation. If it's afull body animation you would do something like so in the same imagestate script that you use at the start (onfire or whatnot):
If it is an armthread or a blended animation then it requires a bit more work, but there are other threads on that. Hopefully this gets you going.
12/11/2005 (2:49 am)
The search feature has been borked the past two days, it isn't searching anything but TDN, which doesn't have enough content to be useful yet. To do a quick and dirty check to see if someone is in range of you and if they are then damage them you would do something like this in your onfire or whatever you have it called for when the trigger is pressed.%player = %obj.client.player;
%eye = %player.getEyeVector();
%vec = vectorScale(%eye, 3); // distance we can hit from
%start = %player.getEyeTransform();
%end = VectorAdd(%start,%vec);
%found = ContainerRayCast (%start, %end, $TypeMasks::PlayerObjectType, %player);
if(%found)
{
%found.applydamage(%this.damage);
%mypos = %obj.getposition();
%theirpos = %found.getposition();
%vector = VectorSub(%theirpos, %mypos);
%vector = VectorNormalize(%vector);
%found.getDataBlock().damage(%found, %obj, %vector, %this.damage, "Melee");
}If that don't work let me know. I pasted that from source to my melee code but I had some additional code in there for teams that I removed for simplicity, it should work though.
To animate the character when you swing you would need some animations and to put them into your sequences (yourdir/data/shapes/player/player.cs for example) like so:
sequence17 = "./swing.dsq swing";
Then in the swing block you'd have to play the animation. If it's afull body animation you would do something like so in the same imagestate script that you use at the start (onfire or whatnot):
%obj.setActionThread("swing");If it is an armthread or a blended animation then it requires a bit more work, but there are other threads on that. Hopefully this gets you going.
#4
If you have the old RealmWars Comunit Project sources at hand you can check this out yourself. It even has three swing animations and two meele weapons.
While you do not see these animations in 1st person view, you may want to switch to 3rd person view for meele weapons.
Detecting collisions with meele weapons is far harder, if you want to go beyond a simple estimation and hurt anyone that is within a given range.
-- Markus
12/11/2005 (3:10 am)
As J.C. said, the first thing is you need to have a swig animation, that animates the weapon mount node of your player. Then you need to play this animation in your onFire callback.If you have the old RealmWars Comunit Project sources at hand you can check this out yourself. It even has three swing animations and two meele weapons.
While you do not see these animations in 1st person view, you may want to switch to 3rd person view for meele weapons.
Detecting collisions with meele weapons is far harder, if you want to go beyond a simple estimation and hurt anyone that is within a given range.
-- Markus
#5
same problem all the time:
says i dont have correct version of game cuz it cant find art....
if it ever loads the player is looking at the sky head spinning and then it crashes
12/11/2005 (9:00 am)
I have spent hours trying to get decent melee code working from realmwars and from another thread based on the realm wars code, it wont work.same problem all the time:
says i dont have correct version of game cuz it cant find art....
if it ever loads the player is looking at the sky head spinning and then it crashes
Torque 3D Owner Thomas Shaw