[Tutorial] FIX Bouncy Helicopters, flying zombies and rapid takeoff

Results 1 to 4 of 4
  1. #1
    Valued Member obamabf2 is offline
    MemberRank
    Jan 2014 Join Date
    Parnamirim (RioLocation
    123Posts

    thumbs up [Tutorial] FIX Bouncy Helicopters, flying zombies and rapid takeoff

    When securing the helicopter was noticed with a BUG, the zombies were not serious and come out flying ... I edited this bug and improved the ascent and descent of the helicopter.


    Code Base >>> https://forum.ragezone.com/f791/tuto...pters-1079759/


    Search:
    Code:
    void obj_Vehicle::HelicopterPhysx()
    Change for:
    Code:
    void obj_Vehicle::HelicopterPhysx() // controls of helicopter
    {
        if (isHelicopter == true)
        {
            const float fTimePassed = r3dGetFrameTime();
            PxTransform pose = vd->vehicle->getRigidDynamicActor()->getGlobalPose();
            r3dVector angles;
            r3dPoint3D position(0,0,0);
            PxVec3 HeliGravity(0,-9.81,0);//Edited by Jailson Mendes
            PxVec3 NormGravity(0,9.81,0);
    
    
    
    
            if (HasDriver() && HSpeed > 70)
            {
                if (Keyboard->IsPressed(kbsRight)) // Rotate Left
                {
                    if (!(Keyboard->IsPressed(kbsW) || Keyboard->IsPressed(kbsS)))
                        HelyX+=0.5f;
                }
                else if (Keyboard->IsPressed(kbsLeft)) // rotate Right
                {
                    if (!(Keyboard->IsPressed(kbsW) || Keyboard->IsPressed(kbsS)))
                        HelyX-=0.5f;
                }
                if (Keyboard->IsPressed(kbsW) && distanceFromGround>=5) // move front
                {
                    HeliGravity = PxVec3(0,-1.0,0);
                    if (HelyY<15.0f)
                        HelyY+=0.5f;
                    //HelyUp=-0.1f;
    
    
    
    
                    if (HelyFB>1 && FB>=0)
                        FB=HelyFB-=0.25f;
                }
                else {
                    if (FB >0 && HelyFB<20)
                        FB=HelyFB+=0.05f;
    
    
    
    
                    if (HelyY>0)
                    {
                        HelyY-=0.5f;
                        if (HelyY<0) HelyY = 0;
                    }
                }
                if (Keyboard->IsPressed(kbsS) && distanceFromGround>=5) // Move back
                {    
                    if (HelyY>-15.0f)
                        HelyY-=0.5f;
                    
                    if (HelyFB>5 && FB<=0)
                        FB=abs(HelyFB-=0.5f)*-1;
                }
                else {
                    if (FB <0 && HelyFB<20)
                        FB=abs(HelyFB+=0.05f)*-1;
                    if (HelyY<0)
                    {
                        HelyY+=0.5f;
                    }
                }
                if (Keyboard->IsPressed(kbsD) && distanceFromGround>=10) // move Right
                {
                    if (HelyZ>-30.0)
                        HelyZ-=0.5f;
    
    
    
    
                    if ((Keyboard->IsPressed(kbsW) || Keyboard->IsPressed(kbsS)))
                    {
                        HelyX+=0.5f;
                    }
                    else {
                        if (HelyLR>5 && LR>=0)
                            LR=HelyLR-=0.5f;
                    }
                }
                else {
                    if (LR >0 && HelyLR<20)
                        LR=HelyLR+=0.1f;
                    if (HelyZ<0)
                    {
                        HelyZ+=0.5f;
                    }
                }
    
    
    
    
                if (Keyboard->IsPressed(kbsA) && distanceFromGround>=10) // move Left
                {
                    
                    if (HelyZ<30.0)
                        HelyZ+=0.5f;
    
    
    
    
                    if ((Keyboard->IsPressed(kbsW) || Keyboard->IsPressed(kbsS)))
                    {
                        HelyX-=0.5f;
                    }
                    else {
                        if (HelyLR>5 && LR<=0)
                            LR=abs(HelyLR-=0.5f)*-1;
                    }
    
    
    
    
                }
                else {
                    if (LR <0 && HelyLR<20)
                        LR=abs(HelyLR+=0.1f)*-1;
    
    
    
    
                    if (HelyZ>0)
                    {
                        HelyZ-=0.5f;
                        if (HelyZ<0) HelyZ = 0;
                    }
                }
                if (Keyboard->IsPressed(kbsQ) && HSpeed > 70) // move up Velocidade minima para subir voo, se se colocar 50 ao chegar em 50 MPH começa a decolar
                {
                    //r3dOutToLog("###### distanceFromGround %f\n",distanceFromGround);
                    //if (distanceFromGround<100)
                        //HelyUp=0.1f;
                    HeliGravity = PxVec3(0,8,0); //m70b1jr gravity Edited By Jailson Mendes
                }
                else if (Keyboard->IsPressed(kbsZ)) // Move down
                {
                    HeliGravity = PxVec3(0,-5,0);
                    //HelyUp=-0.1f;
                }
            }
            else {
                
                if (distanceFromGround>0)
                {
                    if (HSpeed < 50 || !CheckFuel())
                    {
                        //r3dOutToLog("######## HSpeed: %f\n",HSpeed);
                        HeliGravity = PxVec3(0,-9.81f,0);
                        if (HelyUp>0)
                            HelyUp=-0.1f;
                    }
                }
            }
            pose.p.y+=HelyUp;
            if (HelyFB>=20)
                FB=0;
            if (HelyLR>=20)
                LR=0;
            //r3dOutToLog("######## HelyFB: %f FB: %f\n",HelyFB,FB);
            position = r3dPoint3D(pose.p.x,pose.p.y,pose.p.z) + (GetvForw() / FB) + (GetvRight() / LR);
                    if (HelyUp<0)
                    {
                        HelyUp+=0.001f;
                    }
                    else if (HelyUp>0)
                    {
                        HelyUp-=0.001f;
                        if (HelyUp<0) HelyUp = 0;
                    }
            if (isHelicopter == true)
            {
            g_pPhysicsWorld->PhysXScene->setGravity(HeliGravity); // m70 test NormGravity
            }
            else if (isHelicopter != true)
            {
                g_pPhysicsWorld->PhysXScene->setGravity(NormGravity);
            }
            
            
            D3DXMATRIX RotateMatrix,RotateMatrix2,toOrigin,fromOrigin,boneTransform;
            D3DXMatrixTranslation(&toOrigin, -GetPosition().x, -GetPosition().y, -GetPosition().z);
            D3DXMatrixTranslation(&fromOrigin, pose.p.x, pose.p.y, pose.p.z);
            
            D3DXMatrixRotationYawPitchRoll(&RotateMatrix,R3D_DEG2RAD(HelyX),R3D_DEG2RAD(HelyY),R3D_DEG2RAD(HelyZ));
            D3DXMatrixMultiply(&boneTransform, &fromOrigin, &RotateMatrix);
    
    
    
    
            D3DXMatrixMultiply(&boneTransform, &boneTransform, &toOrigin);
    
    
    
    
            PxMat33 orientation(PxVec3(boneTransform._11, boneTransform._12, boneTransform._13),
                            PxVec3(boneTransform._21, boneTransform._22, boneTransform._23),
                            PxVec3(boneTransform._31, boneTransform._32, boneTransform._33));
            pose.q = PxQuat(orientation);
    
    
    
    
            /*D3DMATRIX m = GetRotationMatrix();*/
            pose.p.x=position.x;//HelyFB;
            pose.p.z=position.z;//HelyLR;
            
            /*HelyLR=position.z;
            HelyFB=position.x;*/
            vd->vehicle->getRigidDynamicActor()->setGlobalPose(pose);
            SetPosition(r3dPoint3D(position.x,pose.p.y,position.z)); //Another test
            r3dPoint3D vel = GetVelocity();
            vel.x *= pose.p.x;
            vel.y *= pose.p.y;
            vel.z *= pose.p.y;
            if(vel.Length() < 0.001f) vel = r3dPoint3D(0, 0, 0);
            SetVelocity(vel);
        }
    }

    Credist base code @m70b1jr

    Credits Edit and fix flying zombies it's me
    Last edited by obamabf2; 10-10-16 at 01:53 PM.


  2. #2
    Proficient Member GMkidink is offline
    MemberRank
    Apr 2012 Join Date
    152Posts

    Re: [Tutorial] FIX Bouncy Helicopters, flying zombies and rapid takeoff

    a really good contribution but someone know the function part to increase de gravity when the helicopter is falling? because going down too fast

  3. #3
    ☆Dying Dawn☆ Bombillo is offline
    MemberRank
    Jan 2012 Join Date
    ValhallaLocation
    977Posts

    Re: [Tutorial] FIX Bouncy Helicopters, flying zombies and rapid takeoff

    this doesn't work coz is -9.81 gravity to down in the helicopter same of 9.81 to up and the heli go down insanely fast idk if my way works but one way would be put an gravity function for the zombies when they die so the zombies get gravity instead using the heli gravity
    Last edited by Bombillo; 02-12-15 at 02:12 AM.

  4. #4
    Member Thiago Costa is offline
    MemberRank
    Sep 2013 Join Date
    51Posts

    Re: [Tutorial] FIX Bouncy Helicopters, flying zombies and rapid takeoff

    Quote Originally Posted by obamabf2 View Post
    When securing the helicopter was noticed with a BUG, the zombies were not serious and come out flying ... I edited this bug and improved the ascent and descent of the helicopter.


    Code Base >>> https://forum.ragezone.com/f791/tuto...pters-1079759/




    Credits Edit and fix flying zombies it's me

    It has a bug in the code. Add to correct the post.

    FIX

    void obj_Vehicle::HelicopterPhysx() // controls of helicopter
    {


    ​:D



Advertisement