[Tutorial] FIX Bouncy Helicopters
Hey guys! Fixed the helicopters in codex's source.
Replace this function
Code:
void obj_Vehicle::HelicopterPhysx()
For mine
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,0,0);
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
{
//r3dOutToLog("###### distanceFromGround %f\n",distanceFromGround);
//if (distanceFromGround<100)
//HelyUp=0.1f;
HeliGravity = PxVec3(0,2,0); //m70b1jr gravity
}
else if (Keyboard->IsPressed(kbsZ)) // Move down
{
HeliGravity = PxVec3(0,-1,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);
}
}
Fixed.
Current bugs: Even when not in the helicopter, it gains altitude. Will be fixing here in a bit.
Re: [Tutorial] FIX Bouncy Helicopters xD
good job dude..gonna try this
Re: [Tutorial] FIX Bouncy Helicopters xD
Changing this code, the zombies to die are flying and the cars do not leave the place ... That's what I could see so far!
Re: [Tutorial] FIX Bouncy Helicopters xD
Quote:
Originally Posted by
italofialho
Changing this code, the zombies to die are flying and the cars do not leave the place ... That's what I could see so far!
Yup, I'm now noticing this now. On the DEV map, this isn't happening.
- - - Updated - - -
Right now I'm seeing if there is a way to make it a local variable only, and not a global scope so it doesn't affect everything.
EDIT: This only happens once a player enters the helicopter.
- - - Updated - - -
Edited function in thread.
Re: [Tutorial] FIX Bouncy Helicopters xD
Honestly guys, I'm lost here, I've even been reading the PhysX Documentation.
- - - Updated - - -
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,0,0);
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
{
//r3dOutToLog("###### distanceFromGround %f\n",distanceFromGround);
//if (distanceFromGround<100)
//HelyUp=0.1f;
HeliGravity = PxVec3(0,2,0); //m70b1jr gravity
}
else if (Keyboard->IsPressed(kbsZ)) // Move down
{
HeliGravity = PxVec3(0,-1,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);
}
}
Fixed.
Re: [Tutorial] FIX Bouncy Helicopters xD
Hey move up limit please ? (KbsQ)
Re: [Tutorial] FIX Bouncy Helicopters xD
I myself would like to put a height limit on mine..where do I look m70b1jr?
Re: [Tutorial] FIX Bouncy Helicopters xD
Quote:
Originally Posted by
dNi3L
I myself would like to put a height limit on mine..where do I look
m70b1jr?
There should be a thing called distancefromground or something. In the kbsW Function, make it look something like this
if (distancefromground>500)
LOWERALTTITUDEFROM KBSZ
Also, Left Shift is for the turret on the tanks.
Re: [Tutorial] FIX Bouncy Helicopters xD
Excellent you are my hero..now to figure out how to get rid of the annoying car brake squeals and we may have a winner..great work dude
Re: [Tutorial] FIX Bouncy Helicopters
flying zombie, player, car (don't working.)
Re: [Tutorial] FIX Bouncy Helicopters
Good work , no work 100 %
1 Attachment(s)
Re: [Tutorial] FIX Bouncy Helicopters
Good job
SHOULD BE GOOD IDEAS FOR THIS LIKE:
1.Make non dismount during flying with a Advertence notice "Can't Dismount During flight" coz have many bugs if this not work or make parachutes lol
2.Make flashlight under helicopter to show the downstair areas in the night when you gonna landing
3.Remove the break car sound
4.Make red and white lights in the helicopter to see it in the night
5.Can Change the control keys in the option control menu
6.Expand the slot of seat from 2 to 6 and show the characters inside the helicopter
7.Static camera and rotate camera with mous like gta
and many more, then do UFO for egg easter !
Re: [Tutorial] FIX Bouncy Helicopters
helicopter driving 10-20 seconds to crash ?
Re: [Tutorial] FIX Bouncy Helicopters
Quote:
Originally Posted by
Ownii
helicopter driving 10-20 seconds to crash ?
I'm not crashing.
- - - Updated - - -
Guys, I'm pretty sure I got a permanent solution, Just testing now.
Re: [Tutorial] FIX Bouncy Helicopters
ha ha I'm test bug flying zombie, player, car
not work for me :)