darrenc182 Posted January 17, 2010 Share Posted January 17, 2010 Has anyone been able to get crouching to work with the Player Controller (TController)? If you have been able to could you state how you went about doing this? Quote Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5. Link to comment Share on other sites More sharing options...
Rick Posted January 18, 2010 Share Posted January 18, 2010 There is no crouching state for the controller. You can't scale it on the fly and make it work currently. For now I would suggest storing 2 separate character controller at different heights. One for standing and one for crouching. Then swap them when you need them. I wouldn't create them on the fly either. Create them up front and swap them in when needed. It'll be faster and doesn't really use that much memory. Quote Link to comment Share on other sites More sharing options...
darrenc182 Posted January 19, 2010 Author Share Posted January 19, 2010 There is no crouching state for the controller. You can't scale it on the fly and make it work currently. For now I would suggest storing 2 separate character controller at different heights. One for standing and one for crouching. Then swap them when you need them. I wouldn't create them on the fly either. Create them up front and swap them in when needed. It'll be faster and doesn't really use that much memory. That was suggested earlier, but was wondering if anyone had gotten it working or if there was a way of doing easily through the engine. I'm sure Josh said that he was going to look into this, but I guess he has chosen not to at this point. I did start with the implementation that you suggested above and I will revisit it very soon. Quote Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5. Link to comment Share on other sites More sharing options...
wh1sp3r Posted January 19, 2010 Share Posted January 19, 2010 yes, i got it working .. this is my old demo: http://pavelrydl.cz/software/char_v12.rar in new version, there is a bug with velocity, so, it has strange behaviour, when you are falling and crouching, lol Quote -= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=- Website: http://www.flamewarestudios.com Link to comment Share on other sites More sharing options...
darrenc182 Posted January 19, 2010 Author Share Posted January 19, 2010 yes, i got it working .. this is my old demo: http://pavelrydl.cz/software/char_v12.rar in new version, there is a bug with velocity, so, it has strange behaviour, when you are falling and crouching, lol hey wh1sp3r, thanks for the demo. I did get my preliminary implementation done late last night. here are two sets of code, one for the initialization and one the function being called by the crouching event: bool dhPlayer::Init(TVec3 pos) { TMaterial alphatest_mat, ammo_sample_mat; std::vector<int> weapon_list; str str_alphatest; if(m_vStartPosition.X == 0.0 && m_vStartPosition.Y == 0.0 && m_vStartPosition.Z == 0.0) m_vStartPosition = pos; // Create(m_vStartPosition); PositionEntity(fw.GetMain().GetCamera(), m_vStartPosition); standing = CreateController(flt(PLAYER_STANDING_HEIGHT), 12.0f, 35.0f); crouching = CreateController(flt(PLAYER_CROUCHING_HEIGHT), 12.0f); EntityType(standing, 0); SetBodyMass(standing, 85); SetBodyGravityMode(standing, 1); SetBodyDamping(standing, 50.0f, 50.0f); SetBodyFriction(standing, 50.0f, 50.0f); EntityType(crouching, 0); SetBodyMass(crouching, 85); SetBodyGravityMode(crouching, 1); SetBodyDamping(crouching, 50.0f, 50.0f); SetBodyFriction(crouching, 50.0f, 50.0f); m_iPlayerStatus = PLAYER_STANDING; player = standing; PositionEntity(player, EntityPosition(fw.GetMain().GetCamera())); EntityType(player, COLLISION_PLAYER); SetEntityKey(player, "name", "player"); luabind::module(myLuaState) [ luabind::class_<dhLuaWeaponScript>("dhLuaWeaponScript") .def(luabind::constructor<>()) .def("SetWeaponModel", &dhLuaWeaponScript::SetWeaponModel) .def("SetWeaponPosition", &dhLuaWeaponScript::SetWeaponPosition) .def("SetWeaponRotation", &dhLuaWeaponScript::SetWeaponRotation) .def("SetWeaponFireSpot", &dhLuaWeaponScript::SetWeaponFireSpot) .def("SetAttackSound", &dhLuaWeaponScript::SetAttackSound) .def("SetReloadSound", &dhLuaWeaponScript::SetReloadSound) .def("SetUseSound", &dhLuaWeaponScript::SetUseSound) .def("SetWeaponType", &dhLuaWeaponScript::SetWeaponType) .def("SetAttackAnimFunc", &dhLuaWeaponScript::SetAttackAnimFunc) .def("SetGeneralAnimFunc", &dhLuaWeaponScript::SetGeneralAnimFunc) .def("SetMaxClipSize", &dhLuaWeaponScript::SetMaxClipSize) .def("SetMaxAmmo", &dhLuaWeaponScript::SetMaxAmmo) .def("SetStartAmmoAmount", &dhLuaWeaponScript::SetStartAmmoAmount) .def("SetStartClipAmmoAmount", &dhLuaWeaponScript::SetStartClipAmmoAmount) .def("PrintWeaponMessage", &dhLuaWeaponScript::PrintWeaponMessage) .def("SetReloadDOF", &dhLuaWeaponScript::SetReloadDOF) .def("SetReloadDOFStrength", &dhLuaWeaponScript::SetReloadDOFStrength) .def("SetFireRate", &dhLuaWeaponScript::SetFireRate) ]; luabind::module(myLuaState) [ luabind::class_<dhLuaPlayerScript>("dhLuaPlayerScript") .def(luabind::constructor<>()) .def("LoadWeapon", &dhLuaPlayerScript::LoadWeapon) ]; LoadPlayerScript("abstract::player.lua"); LoadPlayersWeapon(WEAPON_FISTS); weapon_list = PlayerScript.GetWeaponList(); for(int i=0;i<weapon_list.size();i++) { LoadPlayersWeapon(weapon_list[i]); } activation_timer.Initialize(); activation_timer.AddItem(100); // For turning flashlight on and off. activation_timer.AddItem(100); // For switching light (in this case) on and off g_tCrossHair = LoadTexture("abstract::crosshairb.dds"); // new_gun.weapon_type = WEAPON_PISTOL; // m_tGunList.push_back(new_gun); // GUIHealthGroup = LoadTexture("abstract::health_group.dds"); // GUIHealthUnits[0] = LoadTexture("abstract::trans_test.dds"); // DrawImage(GUIHealthGroup, 400, 400, 156, 104); //--g_Renderer.SetCurWorld(WLD_FOREGROUND); --// // fgcam.Create(Vec3(0.0f, 0.0f, 0.0f)); // alphatest=CreatePlane(); fw.GetTransparency().SetWorld(); CreateAmmoHUD(); CreateHealthHUD(); fw.GetMain().SetWorld(); // RotateMesh(alphatest, Vec3(-90.0f, 0.0f, 0.0f)); // RotateMesh(alphatest, Vec3(0.0f, 0.0f, 90.0f)); // PositionEntity(alphatest,Vec3(1.5, -1.7, 2.5)); // ScaleEntity(alphatest,Vec3(0.5)); // alphatest_mat = LoadMaterial("abstract::alphatest.mat"); // PaintEntity(alphatest,alphatest_mat); // HideEntity(alphatest); //--g_Renderer.SetCurWorld(WLD_MAIN);--// SetEntityCallback(player, (byte*)EntityCollisionCallback,ENTITYCALLBACK_COLLISION); SetEntityCallback(player, (byte*)MessageReceiveCallback, ENTITYCALLBACK_MESSAGERECEIVE); SetEntityCallback(player, (byte*)UpdateMatrixCallback,ENTITYCALLBACK_UPDATEMATRIX); m_sJump = LoadSound("abstract::jump1.wav"); m_sGrenExplode = LoadSound("abstract::impexp_03.wav"); campivot=CreatePivot(); CreateFlashLight(); PositionEntity(campivot, EntityPosition(fw.GetMain().GetCamera())); return true; } void dhPlayer::Crouch(void) { if(m_iPlayerStatus == PLAYER_STANDING) { TVec3 pos = EntityPosition(player); m_iPlayerStatus = PLAYER_CROUCHING; player = crouching; PositionEntity(player, pos); EntityType(player, COLLISION_PLAYER); EntityType(standing, 0); SetBodyGravityMode(standing, 0); } else if(m_iPlayerStatus == PLAYER_CROUCHING) { TVec3 pos = EntityPosition(player); m_iPlayerStatus = PLAYER_STANDING; player = standing; PositionEntity(player, pos); EntityType(player, COLLISION_PLAYER); EntityType(crouching, 0); SetBodyGravityMode(crouching, 0); } SetEntityKey(player, "name", "player"); SetBodyGravityMode(player, 1); } The behaviour I am getting is not desirable. I can crouch the first time just fine but standing back up doesn't work very well. The camera slides back down to the crouching position sometimes. I was wondering if any one could suggest a better method or can see something in my code that would create a problem. Thanks in advance. Quote Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5. Link to comment Share on other sites More sharing options...
wh1sp3r Posted January 20, 2010 Share Posted January 20, 2010 try turn debug mode to find it out, what happends Quote -= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=- Website: http://www.flamewarestudios.com Link to comment Share on other sites More sharing options...
Chiblue Posted February 8, 2010 Share Posted February 8, 2010 Just out of curiousity, could you use one controller and then use the ScaleEntity function on the Y axis to scale the entity to the appropriate crouch or standing, for example when the player crouches could you scaleentity to say 50% of the current y... then scale 200% to go back to standing? Not sure if this would upset the collisions? This is how I did this in GDK, for the Dark Physics controller.. Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Mumbles Posted February 8, 2010 Share Posted February 8, 2010 I don't think you can scale physics bodies Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Niosop Posted February 8, 2010 Share Posted February 8, 2010 You can't, which is the biggest gripe about using Newton. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Paul Thomas Posted February 8, 2010 Share Posted February 8, 2010 function Player() local player = {} player.activeHeight = 1.8 player.height = 1.8 player.crouch = 0.8 player.radius = 0.45 player.stepHeight = 0.25 player.maxSlope = 45.0 player.mass = 10.0 player.iteractions = 45.0 player.jump = 0.0 player.jumpHeight = 6.0 function player:Create() player.controller = CreateController(player.height, player.radius, player.stepHeight, player.maxSlope, player.iteractions) player.controller:SetCollisionType(COLLISION_CHARACTER, 0) player.controller:SetMass(player.mass) player.controller:SetPosition(fw.main.camera.position) end function player:Free() player.controller:Free() end return player end player = Player() player:Create() while KeyHit(KEY_ESCAPE) == 0 do if KeyHit(KEY_C) == 1 then if player.crouching == true then player.crouching = false player.controller:SetScale(Vec3(player.controller.scale.x, player.height / 2, player.controller.scale.z)) player.activeHeight = player.height else player.crouching = true player.controller:SetScale(Vec3(player.controller.scale.x, player.crouch / 2, player.controller.scale.z)) player.activeHeight = player.crouch end end player.controller:Update(yaw, move, strafe, jump, 40, 10) end You'll have to fill in the rest. I had retyped this so I apologize for any mistakes. Setting the controller scale works for me. At least it looks like it Quote Link to comment Share on other sites More sharing options...
Rick Posted February 8, 2010 Share Posted February 8, 2010 I think collisions can give unpredictable results if you scale bodies though. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted February 8, 2010 Share Posted February 8, 2010 Yeah it's best to recreate the controller. But, you can indeed scale it, lol. Quote Link to comment Share on other sites More sharing options...
Rick Posted February 8, 2010 Share Posted February 8, 2010 I still think it's best to just create 2 controllers of different size and swap them in and out. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 8, 2010 Share Posted February 8, 2010 Crouching behavior will be included in 2.31. It will detect whether the player can stand up or not, so it will be 100% good and usable. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Paul Thomas Posted February 8, 2010 Share Posted February 8, 2010 Awesome. What about prone? Quote Link to comment Share on other sites More sharing options...
Mumbles Posted February 8, 2010 Share Posted February 8, 2010 That would invlove scaling forwards / backwards too, wouldn't it? (Forwards and backwards being relative to the controller) Or just tipping the controller on its front... Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Paul Thomas Posted February 8, 2010 Share Posted February 8, 2010 Yeah, definitely. Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 8, 2010 Share Posted February 8, 2010 Yes and no, actually just scaling the controller to a prone size would be more realistic, since people in prone position are able to turn around in a small corridor, which would not be the case if the controller was laying flat. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Mumbles Posted February 8, 2010 Share Posted February 8, 2010 If for whatever reason, I was flat on the floor (playing dead maybe?) and I wanted to turn round, I'd probably come off my belly, go into a crouched ball, turn round like that, then lie back down again... Maybe it's just me. Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Canardia Posted February 8, 2010 Share Posted February 8, 2010 Yeah, that would work if you're athletic enough for such manouver I would just turn on my side, and try to squeeze my head to the other side, and then the legs. Of course it also depends if the corridor is more broad than high. If the corridor is quite small in both dimensions, you'd use the diagonal space and squeeze your head, and one leg at a time to the other side. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Chiblue Posted February 8, 2010 Share Posted February 8, 2010 It's funny, I was reading through this thread, and thinking well I am looking at a minimum of 3 controllers... maybe more if your character is say a biped thatn walk 2 legs, 4 legs, crouch, prone, etc... Having the ability to set different controller modes and associated X Y Z dimensions would be very helpful... So I guess the next question is, When is 2.31 going to be available Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
darrenc182 Posted February 11, 2010 Author Share Posted February 11, 2010 How do you use the ControllerCrouched function? I know it is similar to the ControllerAirborne function, but with the ControllerAirborne you can apply a force to the controller to get the player to jump, but what do you have to do to the controller when the ControllerCrouched passes 0 back to the calling function? Quote Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5. Link to comment Share on other sites More sharing options...
Josh Posted February 11, 2010 Share Posted February 11, 2010 UpdateController() takes an extra parameter to make the controller crouch. He will only uncrouch when there is nothing in the way of him standing up. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Canardia Posted February 11, 2010 Share Posted February 11, 2010 Could the crouchmode be a float instead of int, so I could say how much it should crouch, and don't need to recreate the controller for different heights? Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Chiblue Posted February 11, 2010 Share Posted February 11, 2010 Yes a float for the the new height would be cool, although if this is availabe next thing you will need is to change controller orientation... crouching is not so much an issue, but to make prone realistic you would need to basically rotate the controller mesh by 90degrees to simulate lying down.. I know this is growing outside scope but height and orientation would be nice... so for crouch you can set the height, but for prone you can set the height normal but set the rotation to 90... or 1 for 90 degree rotation, I am sure this will create a whole bunch of issues but it was just a suggestion... Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.