Hi,
So i try to fly this prop(the yellow object) in midair just a little above player head as shown in the pic.
I apply thrust F1 to push it upward to counter the gravity W1 and keep its height D1 static in midair. Its work.
The problem is when i decrease or increase the F1 value just a fraction to make it animating like it loosing and gaining its altitude(up and down), its start to bounce like Pong game and gradually accelerating non stop.
If anyone have any idea on how can i cancel or counter the velocity so it stop at desired altitude/height without Teleporting?
* I v turned alliedmodders page front to back searching for an answer.. now i m stuck.
* Or at least point me to the right direction or external link. One that without wind force in the equation.
sorry for the poor image editing
For the Loard in Haven, stop downloading the pictures.
They are the same as above.
A backup picture.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
Last edited by GsiX; 11-06-2020 at 12:02.
Reason: Saying my prayer for those who downloaded the picture.
Hi there fine gentleman, good day to you handsome Sir.
There is no code.. i just attach "phys_thruster" to the object and tweak the force bit by bit until it stay in place. That the center line i desired D1.
Then if the object bounce away from the D1 line, i grab the distance value by how much and then multiply it with the F1 force. The further it travel the bigger the opposite value it gets. That cause the object accelerating further to the opposite direction and so on.
Roughly, this is what i v done before i give it up, code below is rewrite as proximation.
Spoiler
PHP Code:
#define FORCE_UPWARD 200 #define FORCE_LIFT 10 #define FORCE_FALL 2 void Think_Lifting( int entity, float pos_entity[3], float pos_owner[3] ) { // center is the position on top of player head. // Let say player top = 60.0, total height we hoover = 60.0 + 20.0 float center = 20.0;
// actual distance from player head to the object float distance = pos_entity[2] - pos_owner[2];
// we allow this much of distance clearance float tolerance = 5.0;
// positive value apply force push downward // negative value apply force push upward float direction = distance - center;//<< may resault in zero if the object didnt change height since it spawn.
// we dont direct compare direction with value zero as we might not catch the exact number. // therefor we allow small error clearance. if( direction > (tolerance * -1.0 ) && direction < tolerance ) { // force_fall = 2, fraction of force needed to make object slowly go down // we are closer to the center, so just hoover and slowly go down. direction = float( FORCE_FALL ); } else { // we are far away from center, calculate the total counter force direction = float( FORCE_LIFT ) * direction; }
// if direction is negative, flip it positive to make lifting // if direction is positive, flip it to negative to create fall. int force = RoundToCeil( float( FORCE_UPWARD ) - direction ); // force_upward 200 is the exact value to counter the gravity
// no special code, just apply the value we calculate to the thruster force. SetThrusterForce( entity, g_iThruster, force );