Plan for Gonzo T. Exterminator
by Gonzo T. Clown · 10/24/2004 (3:44 am) · 17 comments
How good is too good? Are you as good as you think you are? Or are you too good for your own damn good? Am I fooling myself? I feel like a noob.
Amazing the thoughts that come to your mind when you solve a major problem. "Major problem? You should be proud." Yeah, well, you might not think so when you find out why I'm writing this. For months I had seen others wrestle with the hover aspect of the flying vehicles. Many persons had failed to get them to act the way they were supposed to act. It's a very frustrating thing to not be able to get hours worth of moddeling and/or coding work to perform properly. So one day I decided I would see if I could tackle the problem. I love to challenge myself, in fact, it seems I love it just a little to much.
My first mistake was to assume I was in for a major challenge of debugging and analyzing the full aspect of the function and its performance. Scrutinizing the details of the Math and the operational aspects that are branched into various parts of the engine. Pouring piece by piece, line by line trying to get a fully functioning model in my head of exactly what the function was doing, so I could see exactly where the flaw in someones logic was and fix it. Days and days later I was no closer to a hovering flyer than I was when I started. It just didn't make sense. I couldn't see the flaw in the logic. My mind was screaming at me "There has to be a flaw, it doesn't work right, if you can't find it, then you're just as flawed as it is." Frustration and self doubt sets in.
Finally, I gave in. My skills in doubt, my esteem shot. I had to give it up. My only comfort was that I was not the only guy to fail, but that didn't make me feel any better. That would have been the end of this story except by chance Martin "Muerte" Schultz sends me an email asking me if I ever managed to solve the issue. Like many others he had most likely assumed that since the thread went dead, a solution was found. After searching and not finding that solution, he mailed me. I can't say I was happy to answer his question(I hate to fail), so I took a very deep breath and popped open the FlyingVehicle.cc file and started to look at it again.
WHAM!!!!! Like a brick to the head I was knocked silly when the answer just jumped right out at me as if I been mailed the answer from the heavens above. I was dumbfounded by the fact that I could have, and should have seen this type of mistake in a matter of minutes, and in some cases, even seconds. I was instantly newbiefied. I felt so stupid for letting myself believe that the problem was harder than it was before I even started on it. I knew damn well that a problem is only as hard as you make it, and I made this one my toughest ever. No excuse for it. Arrogance, complacency, and illogical assumptions had led me to basically abandon all the skills I not only prided myself on, but needed and depended on to do the job right. That main skill was to look for the obvious first before going into the detail.
I cannot stress enough, that no matter what your skill level when coding, things will only be as hard as you make them. Too much thinking and too much analyzing can be just as bad as not enough.
"So what's the fix Gonzo?" Glad you asked, here it is....
In FlyingVehicle.cc, at line 523 in the FlyingVehicle::getHeight() function, replace this line....
if(!mContainer->castRay(sp, ep, 0, &collision) == true)
with this line...
if(!mContainer->castRay(sp, ep, ~TerrainObjectType, &collision) == true)
then recompile and bask in the glory of a hovering flyer that sits at exactly the height above the ground that you always wished for it to. Then, jump in, push the nose into the ground and watch it raise itself back up and level out. It's a wonderful thing, I swear.
"Not much of a plan Gonzo."
For me it is, I 'plan' to never let myself make this kind of mistake again. Learn, don't burn.
Important EDIT:(Thanks to Stefan Lundmark for asking)
While my intent was to solve the problem of hovering above terrain, you can adjust this as follows.....
To hover above everything(Boxes, trees, buildings, etc...) change the line to....
if(!mContainer->castRay(sp, ep, sClientCollisionMask, &collision) == true)
If asked, I would recommend that line for addition to the HEAD. And if you like, you can also add in the players and make a vehicle hover over your head till you walk out from under it and then it will settle down to the terrain....
if(!mContainer->castRay(sp, ep, sClientCollisionMask & ~PlayerObjectType, &collision) == true)
Enjoy!
Amazing the thoughts that come to your mind when you solve a major problem. "Major problem? You should be proud." Yeah, well, you might not think so when you find out why I'm writing this. For months I had seen others wrestle with the hover aspect of the flying vehicles. Many persons had failed to get them to act the way they were supposed to act. It's a very frustrating thing to not be able to get hours worth of moddeling and/or coding work to perform properly. So one day I decided I would see if I could tackle the problem. I love to challenge myself, in fact, it seems I love it just a little to much.
My first mistake was to assume I was in for a major challenge of debugging and analyzing the full aspect of the function and its performance. Scrutinizing the details of the Math and the operational aspects that are branched into various parts of the engine. Pouring piece by piece, line by line trying to get a fully functioning model in my head of exactly what the function was doing, so I could see exactly where the flaw in someones logic was and fix it. Days and days later I was no closer to a hovering flyer than I was when I started. It just didn't make sense. I couldn't see the flaw in the logic. My mind was screaming at me "There has to be a flaw, it doesn't work right, if you can't find it, then you're just as flawed as it is." Frustration and self doubt sets in.
Finally, I gave in. My skills in doubt, my esteem shot. I had to give it up. My only comfort was that I was not the only guy to fail, but that didn't make me feel any better. That would have been the end of this story except by chance Martin "Muerte" Schultz sends me an email asking me if I ever managed to solve the issue. Like many others he had most likely assumed that since the thread went dead, a solution was found. After searching and not finding that solution, he mailed me. I can't say I was happy to answer his question(I hate to fail), so I took a very deep breath and popped open the FlyingVehicle.cc file and started to look at it again.
WHAM!!!!! Like a brick to the head I was knocked silly when the answer just jumped right out at me as if I been mailed the answer from the heavens above. I was dumbfounded by the fact that I could have, and should have seen this type of mistake in a matter of minutes, and in some cases, even seconds. I was instantly newbiefied. I felt so stupid for letting myself believe that the problem was harder than it was before I even started on it. I knew damn well that a problem is only as hard as you make it, and I made this one my toughest ever. No excuse for it. Arrogance, complacency, and illogical assumptions had led me to basically abandon all the skills I not only prided myself on, but needed and depended on to do the job right. That main skill was to look for the obvious first before going into the detail.
I cannot stress enough, that no matter what your skill level when coding, things will only be as hard as you make them. Too much thinking and too much analyzing can be just as bad as not enough.
"So what's the fix Gonzo?" Glad you asked, here it is....
In FlyingVehicle.cc, at line 523 in the FlyingVehicle::getHeight() function, replace this line....
if(!mContainer->castRay(sp, ep, 0, &collision) == true)
with this line...
if(!mContainer->castRay(sp, ep, ~TerrainObjectType, &collision) == true)
then recompile and bask in the glory of a hovering flyer that sits at exactly the height above the ground that you always wished for it to. Then, jump in, push the nose into the ground and watch it raise itself back up and level out. It's a wonderful thing, I swear.
"Not much of a plan Gonzo."
For me it is, I 'plan' to never let myself make this kind of mistake again. Learn, don't burn.
Important EDIT:(Thanks to Stefan Lundmark for asking)
While my intent was to solve the problem of hovering above terrain, you can adjust this as follows.....
To hover above everything(Boxes, trees, buildings, etc...) change the line to....
if(!mContainer->castRay(sp, ep, sClientCollisionMask, &collision) == true)
If asked, I would recommend that line for addition to the HEAD. And if you like, you can also add in the players and make a vehicle hover over your head till you walk out from under it and then it will settle down to the terrain....
if(!mContainer->castRay(sp, ep, sClientCollisionMask & ~PlayerObjectType, &collision) == true)
Enjoy!
About the author
#2
10/24/2004 (4:59 am)
I like the term "newbiefied". Its got a ring to it :)
#3
10/24/2004 (5:11 am)
Hehehe, gotta love those stupid and simple mistakes in TGE that takes hours to figure out. Good job Gonzo :)
#4
The hovering issue aside, your point about how to tackle a problem is well made and applies to just every aspect of life (not to mention gamecreation).
Keep'em coming !
10/24/2004 (5:15 am)
Wonderful plan there Gonzo, a very nice read indeed.The hovering issue aside, your point about how to tackle a problem is well made and applies to just every aspect of life (not to mention gamecreation).
Keep'em coming !
#5
Will this fix make it harder to dive into the ground, or does it only apply when the flying vehicle is created? Nevertheless, great fix.
10/24/2004 (5:40 am)
I might as well ask this too:Will this fix make it harder to dive into the ground, or does it only apply when the flying vehicle is created? Nevertheless, great fix.
#7
10/24/2004 (7:14 am)
Would this work for hovering over water? or just terrain and objects?
#8
10/24/2004 (9:48 am)
Yes it will Chris as 'WaterObjectType' is in the movemask.
#9
Hopefully GG adds this fix to HEAD - surely lot's of other developers need this fix.
Best,
Martin
indies@work
10/24/2004 (9:53 am)
Gonzo - you rock man! Your name will definately make it into my game's credit notes! :-)Hopefully GG adds this fix to HEAD - surely lot's of other developers need this fix.
Best,
Martin
indies@work
#10
if (!mContainer->castRay(sp,ep,-1,&collision))
NOTE: This is what was used in Tribes 2
10/24/2004 (11:11 am)
In the origional release of the source code that line was:if (!mContainer->castRay(sp,ep,-1,&collision))
NOTE: This is what was used in Tribes 2
#11
@ Nauris - it's mine, keep away, lol.
@ Xavier - Amen. Thanks
@ Jorgen - Thanks, and I gotta say, I got a chill when I read your profile. Had we not been separated by thousands of miles I would have said we grew up as twins. I could not believe how much of your life mirrored my own. If we ever met I'll bet we would get along great.
@ Ian - Tell it to GG, lol. It's their code, I only wanted it fixed, not perfected.
@ Chris - Westy is correct.
@ Martin - Much thanks dude. It was your email that made this happen.
@ Harold - Although it's been so long now that I can't positively remember, I'm pretty sure I tried the -1 without success. I suppose I could try it again but at this point, it's functioning perfectly as is so I'm not inclined to waste any more time on it myself. I kinda want to forget I ever did this, lol. But I will note that none of the other ray casts in the engine use the -1, all of them are after a certain mask.
10/24/2004 (4:04 pm)
@ Stefan - Thanks. In theory it would help just slightly because you would have a brief bit of help resisting the terrain impact due to the getHeight function notifying the code to increase the verticle force to move the craft away from the terrain. But I'm unsure as to how much help this is overall. I'm positive it won't make things worse though. The getHeight function is always checked during updateForces no matter what the situation is.@ Nauris - it's mine, keep away, lol.
@ Xavier - Amen. Thanks
@ Jorgen - Thanks, and I gotta say, I got a chill when I read your profile. Had we not been separated by thousands of miles I would have said we grew up as twins. I could not believe how much of your life mirrored my own. If we ever met I'll bet we would get along great.
@ Ian - Tell it to GG, lol. It's their code, I only wanted it fixed, not perfected.
@ Chris - Westy is correct.
@ Martin - Much thanks dude. It was your email that made this happen.
@ Harold - Although it's been so long now that I can't positively remember, I'm pretty sure I tried the -1 without success. I suppose I could try it again but at this point, it's functioning perfectly as is so I'm not inclined to waste any more time on it myself. I kinda want to forget I ever did this, lol. But I will note that none of the other ray casts in the engine use the -1, all of them are after a certain mask.
#12
10/24/2004 (4:58 pm)
I'll be taking a peek at this!
#13
10/25/2004 (3:35 am)
Sometimes it is good to not look at the code for a while. Fresh eyes/brain tends to look at simplicity first. I can't tell you how much of my code I looked at months down the road and ask myself what the hell was I thinking. I could have just done such and such.
#14
www.garagegames.com/mg/forums/result.thread.php?qt=22455
if someone searches for the solution via the forums and not via the resources (where this .plan will be found).
10/25/2004 (7:02 am)
I made a cross post in the forums herewww.garagegames.com/mg/forums/result.thread.php?qt=22455
if someone searches for the solution via the forums and not via the resources (where this .plan will be found).
#15
11/02/2004 (8:36 am)
I noticed that if you get inverted the hoverHieght pushes you down instead of up.
#16
11/17/2004 (2:53 pm)
maybe if you did a mix of the two you could go down and it could go up simoultaniously. I actually found this looking for the AI pack plan where is that??
#17
also not sure if it makes a difference but my original did not look like
if(!mContainer->castRay(sp, ep, 0, &collision) == true)
it looked like this:
if (!mContainer->castRay(sp,ep,0,&collision))
02/10/2005 (1:12 pm)
I tried this out and now my vehicle floats down to the ground slowly. I want it to fall like a rock when it is not powered up by a player being inside. Also what is more disturbing is that my vehicle anoyingly slowly glides along the terrain and you cannot enter it until it is at a complete stop. then when you do get in it will not move. I will see if I can find out what is wrong. thanks for the plan though.also not sure if it makes a difference but my original did not look like
if(!mContainer->castRay(sp, ep, 0, &collision) == true)
it looked like this:
if (!mContainer->castRay(sp,ep,0,&collision))

Torque Owner Stefan Lundmark
Cool to see that someone new to programming can get these fixes going, good eye.