I designed the following code based upon what I read in a book on physics. However, it is not working properly. The code is for the Torque 3D game engine with the Bullet Physics engine integrated. I'm in the process of replacing the vehicle physics...the right way this time. Lets just say my first try a couple years ago was less than good.
*********Code removed*************
The following are the datablock entries that the code refers to:
mass = 200
floatingThrustFactor = 2.0
idealHoverHeight = 4.0
Additionally, the word gravity is set to -20 as is stock with Torque 3D.
I was hoping someone might have a quick look at this and see if they can see what error I've done with my calculations Thank you in advance..
Hovercraft code problems
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Hovercraft code problems
Last edited by RJNelson68 on Wed Oct 03, 2012 6:15 am, edited 4 times in total.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: Hovercraft code problems
I already discovered that using addForce works better. However, the formula is still failing.
The entire purpose of the formula is to start at the max force to reach the ideal hover height without exceeding the maximum hover velocity variable. As it approaches the ideal hover height, it tapers off the added force to a maintaining level.
The entire purpose of the formula is to start at the max force to reach the ideal hover height without exceeding the maximum hover velocity variable. As it approaches the ideal hover height, it tapers off the added force to a maintaining level.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: Hovercraft code problems
Nevermind, I figured out my mistake, the simple fact that I multiplied when I should have divided was all there was to it. However, the object rises now and then falls after it rises higher than the ideal height.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: Hovercraft code problems
OK I've updated the code above with all of the stuff I have tried up to this point. I've tried physics formulas, and I've tried small increments in force adjusted by the percentage of height to ideal height and right now they all have pretty much the same result. The hovercraft goes up higher than it supposed to then comes crashing back down and the cycle begins again.
I'm stumped, the small increment idea seemed like it should have worked, but it just keeps overshooting the target then falling back down. I've even tried setting the ideal hover height and floating thrust factor to very low numbers. What I got was the same thing just MUCH slower.
I could really use some help, maybe point out what I'm doing wrong or offer alternatives, either way I would welcome it. Thanks in advance.
I'm stumped, the small increment idea seemed like it should have worked, but it just keeps overshooting the target then falling back down. I've even tried setting the ideal hover height and floating thrust factor to very low numbers. What I got was the same thing just MUCH slower.
I could really use some help, maybe point out what I'm doing wrong or offer alternatives, either way I would welcome it. Thanks in advance.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: Hovercraft code problems
It has been brought to my attention that I need to apply spring damping. Any suggestions before I spend a few hours reading through my physics books....again?
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: Hovercraft code problems
Code update using the correct physics formula for vertical acceleration and my attempt at spring damping.
It has reduced the over shooting the ideal height, but still rises and falls as before.
While I'm at it, what is the setting to force a rigidbody to try to remain upright? I could find it eventually, but you guys can probably spout it from the tops of your heads.
It has reduced the over shooting the ideal height, but still rises and falls as before.
While I'm at it, what is the setting to force a rigidbody to try to remain upright? I could find it eventually, but you guys can probably spout it from the tops of your heads.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: Hovercraft code problems
Muddled my way through this on my own with a physics book after a few days. Code removed cause it was too much work to just give it away