Why not do melee like this?
by Nathan · in Torque Game Engine · 02/29/2008 (7:32 am) · 8 replies
Hi all. All the melee resources look like you have to make engine changes and stuff. Why not just have a check in script to see if the colliding object is playing it's melee animation, and if so apply damage?
TIA,
Nathan
TIA,
Nathan
#2
I then check to see if the bot is playing attack animation when player collides with the fist object and it works PERFECTLY!
So Nathan, I've had this working for the past 9 months! You're idea is perfect (as it was when I came up with it last Summer). :P
Make sure you mount a "fist object" to EACH hand! (Unless you are doing an actual melee weapon like sword, club, etc) you can even have a shield item in the one hand and if the player's melee item collides with the shield item.... whatever you want (reduce damage, no damage, damage the shield itself, etc)
Enjoy!
02/29/2008 (1:51 pm)
I have successfully mounted an OBJECT to a bot and checked for collision with the object and the player and it definitely works for Melee. The object was the size of the bot's fist and mounted to the bot's fist center.I then check to see if the bot is playing attack animation when player collides with the fist object and it works PERFECTLY!
So Nathan, I've had this working for the past 9 months! You're idea is perfect (as it was when I came up with it last Summer). :P
Make sure you mount a "fist object" to EACH hand! (Unless you are doing an actual melee weapon like sword, club, etc) you can even have a shield item in the one hand and if the player's melee item collides with the shield item.... whatever you want (reduce damage, no damage, damage the shield itself, etc)
Enjoy!
#3
Thanks!!
02/29/2008 (2:14 pm)
Kingdutka, can you post a bit of code as an example? I'd love to get an idea on how to implement this.Thanks!!
#4
Make sense?
Can anyone give a reason why this is inferior to the resources that require extensive engine modifications?
Nathan
02/29/2008 (3:04 pm)
What we're saying is attach an object (like a weapons or dummy fists) to your player model, then when the player model plays it's attack animation just use the ::onCollision() method for the weapon/dummy object to inflict damage on whatever it hits.Make sense?
Can anyone give a reason why this is inferior to the resources that require extensive engine modifications?
Nathan
#5
You're also limited to colliding with the player's bounding box, which is far from perfect for fisticuffs melee. For example you mentioned shields. Usually the shield's bounding box would be enclosed by the player's. It would be hard to get something like Mount&Blade's combat into torque.
02/29/2008 (4:55 pm)
I rolled a new class to handle melee weapons, based on shapebase. It did work out far better than using shapeImage, with less and cleaner code. Remember though if you want it server side, by default none of the thread animations occur on the server. Turning them back on is easy enough.You're also limited to colliding with the player's bounding box, which is far from perfect for fisticuffs melee. For example you mentioned shields. Usually the shield's bounding box would be enclosed by the player's. It would be hard to get something like Mount&Blade's combat into torque.
#6
datablock staticshapeData(swordShape)
{
shapeFile = "~/data/shapes/sword/sword.dts";
};
function swordShape::onCollision(%this,%obj,%col)
{
echo("SWORD COLLISION!");
}
function makesword( %position )
{
%newSHAPENAME = new staticshape(sword1)
{
datablock = swordShape;
position = %position;
static = true;
rotate = true;
}; //after making the static shape i manually mount it to my player thru the console
}
Unfortunately I get no echo in the console regardless of how I touch my dummy targets.It's a big sword, so I'm pretty sure it extends beyond the player's hit box. Any help would be great!
05/14/2009 (12:31 pm)
I love this idea, but for some reason I have having some issues getting to work. For a test I made a new static shape dropped it into my scene, mounted it to the player then attempted to play my swing sword animation. All I want at the moment is to make sure the hits are being registered, so in the sword's datablock I have:datablock staticshapeData(swordShape)
{
shapeFile = "~/data/shapes/sword/sword.dts";
};
function swordShape::onCollision(%this,%obj,%col)
{
echo("SWORD COLLISION!");
}
function makesword( %position )
{
%newSHAPENAME = new staticshape(sword1)
{
datablock = swordShape;
position = %position;
static = true;
rotate = true;
}; //after making the static shape i manually mount it to my player thru the console
}
Unfortunately I get no echo in the console regardless of how I touch my dummy targets.It's a big sword, so I'm pretty sure it extends beyond the player's hit box. Any help would be great!
#7
05/14/2009 (2:22 pm)
I'm pretty sure that onCollision is only called when other objects collide with an object. Try leaving your static shape unmounted and running the player into it - you should get a callback. I don't know how other people managed to get this working.
#8
05/16/2009 (9:39 am)
Hmm didn't know that, I'll try your suggestion. Thanks!
Torque 3D Owner Edward