Game Development Community

Free form Motion and Damage

by ArchonLight · in Torque Game Engine · 08/18/2008 (9:57 am) · 13 replies

I created a new thread since this is a slightly different problem. My eye and cam problem is fixed, now I have a different question dealing with the orientation of the ball Im using. When I hit forward it plays the animation, however say i let go halfway through it snaps back to the idle position. Is there a way to have the ball more free form basically having the ball stay at the point at which I let go, so the motion looks a little more fluid and less blocky? Obviously this will require some engine modifications, if anyone can fill me in or provide information that would help I would greatly appreciate it.

Also Torque has a built in particle engine any pointer or walk through for it?? Im looking to do say like an object throwing out flames that does damage if the player or the "Ball" hits it.

#1
08/20/2008 (7:28 am)
Arg. I should be able to tell you how to fix this, because my Player character is doing just this (not going back to the Root animation). However, I have no idea what I broke to make it do that :P.
#2
08/20/2008 (10:18 am)
Hahaha thats awesome. Well anything you can do to help would be great, also I dont know if I mentioned it but im looking to make or setup the diagnal function, (when the player pressing w+a together it should play a diagnal animation.

thanks ^^
#3
08/20/2008 (12:26 pm)
PickActionAnimation() in player.cpp will almost always default to 'root' when a key isn't pressed. Notice near the top is a check for 'if my script called animation is still playing' to NOT override that. You could add an additional check there; 'if my velocity isn't 0', don't change. Or get fancy and pick your animation based on your velocity (forward, side, diagonal, etc), that's similar to what vehicles do...
#4
08/20/2008 (12:32 pm)
Well which do you advise doing? Whichever will make the rolling seem more realistic what I'd like to go with. Obviously I'd love to do whatever seems more natural its just Id could use some help code wise since Im new to this. I am researching as much as I can on my own and doing my best to understand it. For some reason Torque 3d seems a bit more natural and easy to use then torque 2d.

Also I just downloaded DirectX SDK and C++ so I havent gotten a chance to look at them yet. Thats where the cpp file would be right?
#5
08/20/2008 (4:41 pm)
Player.cpp/.cc is in your engine dir of TGE/TGEA. I don't know what you need, so I couldn't recommend a path to take. If it's just a ball rolling, I would probably base all my animations on the velocity. If you're new to code though, this may be beyond your abilities.
#6
08/21/2008 (10:05 am)
Well I tried searching around in Express 2008 C++ and I couldnt find the file i was looking for.

I went to VS2005 folder inside of the TGE folder and the Torque SDK file I "Opened With" Express 2008 and it had a rather large list and i did try navigating it, perhaps a finger in the right direction might send me to where i need to be. Either way I will have to face this issue. Technically I dont have to worry about this for like another 8 weeks or so, but to be truthful I would rather suffer through it now. If I could atleast be directed on how to get to the right file, the player.cpp/.cc I will do what I can to accomplish this affect on my own or atleast try doing the code on my own before asking for help.
#7
08/21/2008 (10:15 am)
Okay, for the record, I figured out what was wrong. I screwed up my syntax in a 'switch' statement that picked an appropriate root animation, so root was getting set to an action that hadn't been defined. The character, when normally playing the root animation, would simply hold the last animation frame plaed in a movement animation. I'd suggest that that's an easy way to get your functionality - use the existing Player anim code, but set the default 'root' animation to nonsense.
#8
08/21/2008 (10:27 am)
I tried that, didnt work to well, if I take out the root or just purposely make a syntax error the ball will roll forever once I push one direction. Im thinking the only way i will achieve this is by changing the engine which wont be fun but its the right way to do it.
#9
08/25/2008 (8:52 am)
/*
if (mContactTimer >= sContactTickTime) {
// Nothing under our feet
action = PlayerData::RootAnim;
}
else
{
*/
// Our feet are on something
// Pick animation that is the best fit for our current velocity.
// Assumes that root is the first animation in the list.
F32 curMax = 0.1f;
VectorF vel;
mWorldToObj.mulV(mVelocity,&vel);
for (U32 i = 1; i < PlayerData::NumMoveActionAnims; i++)
{
PlayerData::ActionAnimation &anim = mDataBlock->actionList[i];
if (anim.sequence != -1 && anim.speed) {
F32 d = mDot(vel, anim.dir);
if (d > curMax)
{
curMax = d;
action = i;
forward = true;
}
else
{
// Special case, re-use slide left animation to slide right
if (i == PlayerData::SideLeftAnim && -d > curMax)
{
curMax = -d;
action = i;
forward = false;
}
}
}
// }
}
}
setActionThread(action,forward,false,false);
}

So that is the code that I finally found, So what was tried was commenting out a section of the code as you can see, but it didn't really do anything. As a more in-depth description of what I am trying to do is basically I want the animation to stop, not return to the root and stop the animation wherever it left off so say my ball was turned half way I want it to stay turned halfway and pick up from that spot whenever I continue to move. If anyone can help me accomplish this I would appreciate it greatly.
#10
09/02/2008 (5:31 am)
Hope everyone had a good labor day weekend. Just checking in and seeing if anyone has possibly come up with anything that might assist me with this goal?
#11
09/04/2008 (11:01 am)
I got some great advice today. I wanted to hear from some of the more educated people about this idea. An instructor of mine said that I should possibly treat my player ball like a wheel on a vehicle. Because the physics of a vehicle's wheel in Torque are based off of velocity this idea to me seems within the realm of possibility.

My question is where can I find this vehicle code and when specifically concerning the "wheels" what would I have to modify to make it my ball instead of the wheel.
#12
09/04/2008 (3:12 pm)
The TDN has some good articles on how to set up a wheeled vehicle.

You should do some research on Marble Blast and see how they went about creating their player. It seems like your player has the same features as the marble in that game, and I remember a document floating around that had some info on how the developers went about designing the game.
#13
09/05/2008 (7:38 am)
Ill try giving a more thorough loo through the TDN I remember seeing one document that Garage games had on MArble Blast, but it was more of a design doc giving hints on the logic of their game but no real assistance as far as the code goes. Im pretty sure making my ball a pseudo wheel is going to be my best bet and probably something that I can actually do, but we will see.