ParaToxic Posted December 31, 2011 Share Posted December 31, 2011 Hello folks, yesterday I wrote my little control for a 3rd person game and I wanted to ask whether it is good or whether I could improve something. Thanks Quote Link to comment Share on other sites More sharing options...
Roland Posted December 31, 2011 Share Posted December 31, 2011 I think it works just great. One tiny tweak though. In the example you have to move the mouse quite much to rotate, that could be tweaked a bit to get somewhat better response. But again, good work, so all thumbs up from me Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
DaDonik Posted December 31, 2011 Share Posted December 31, 2011 Normally i have my mouse set to extremely sensitive, but it's very slow in your game. Nothing serious though, just make an option for that later. I can't help it, but it looks funny when you strafe and walk at the same time. Apart from that i like it Quote (Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI) Link to comment Share on other sites More sharing options...
ParaToxic Posted December 31, 2011 Author Share Posted December 31, 2011 Ok thanks for trying The problem with the rotation is ,that I TFormPoint and when the pivot the rotates to fast the camera doesn't follow ,so when the angle of the pivot is for example 350 ° and the Camera has still 90° than the Camera turns back the other way. See : Character.exe (Only the exe ,you have to download the zip before and copy that) Ok I think the problem is solved because I made it a little bit more faster and set a min,max to it. Character2.exe Quote Link to comment Share on other sites More sharing options...
Roland Posted December 31, 2011 Share Posted December 31, 2011 Yes. Now its better. Some questions: Is it c++? Did you parent the camera to the character? Anything that you are going to share, because its quite good Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
ParaToxic Posted December 31, 2011 Author Share Posted December 31, 2011 Thanks Yes I use C++ .I use Pivots for that.The Pivot CameraPivot is the camera but I have 3 other Classes above and this section of class is privat ,so I use that and use EntityParent later. The other Pivot is Middlepivot ,which is positioned in the middle or at the head and you turn that pivot with the X/Y of the Mouse,and the Camera is moved to a position ,which is created by TFormPoint between the Middlepivot and the camera self. I have here the code for somebody who needs. UpdateController(Controller0,ControllerAngle,Move,Strafe,0,35.0,1,K_Crouch); //Update Controller with the Controllerangle,move,strafe and the K_Crouch ///////////////Mouse////////////////////////// mx = MouseX() - GraphicsWidth()/2.0; my = MouseY() - GraphicsHeight()/2.0; //mz = MouseZ(); DrawText(0,120,"mx = %f my = %f",mx,my); mx = max(mx,-150.0); mx = min(mx,150.0); /*mz = min(mz,6.0); mz = max(mz,-6.0); if(mz > 6.0) { mz = 6.0; } if(mz < -6.0) { mz = -6.0; } */ PivotRotation.X += my/5.0; PivotRotation.Y -= mx/5.0; MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); RotateEntity(MiddlePivot,Vec3(PivotRotation.X,PivotRotation.Y/5.0,0)); //Rotate the middlepivot PointEntity(CameraPivot,MiddlePivot); //Point the cmaera to the middlepivot,so its better to position middlepivot in the near of the head PivotRotation.X = Curve(max(PivotRotation.X,-20.0),PivotRotation.X,2.0); PivotRotation.X = Curve(min(PivotRotation.X,23.0),PivotRotation.X,2.0); MoveEntity(CameraPivot,Vec3(TFormPoint(Vec3(0,1,-2),MiddlePivot,CameraPivot).X/30.0,TFormPoint(Vec3(0,1,-2),MiddlePivot,CameraPivot).Y/30.0,TFormPoint(Vec3(0,1,-2),MiddlePivot,CameraPivot).Z/30.0)); //The main position command PositionEntity(MiddlePivot,Vec3(EntityPosition(Controller0).X,EntityPosition(Controller0).Y + 1.6,EntityPosition(Controller0).Z)); Quote Link to comment Share on other sites More sharing options...
Roland Posted December 31, 2011 Share Posted December 31, 2011 Great and thanks for sharing. I'm still refining my animations classes (will be available when done) and next in my queue is ThirdPerson controller. Any good starting point is a great help, so your code will be great to start with. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
ParaToxic Posted December 31, 2011 Author Share Posted December 31, 2011 No problem Quote Link to comment Share on other sites More sharing options...
scotty0351 Posted December 31, 2011 Share Posted December 31, 2011 I downloaded the “The Game” zip file and replaced the exe with the character2 file and I’m still moving the mouse too much unless I did something wrong. I also think strafing moving distance needs to be toned down meaning if I strafe right the character should only move a few steps to the right. I also think it would be better if the camera didn’t zoom out as much when I start moving but this probably depends on the type of game your making. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted January 3, 2012 Author Share Posted January 3, 2012 Ok now after a little pause I optimized the controll a little bit and solved the problem with the camerarotation and something else. The Code is: UpdateController(Controller0,ControllerAngle,Move,Strafe,0,35.0,1,K_Crouch); mx = Curve(MouseX() - GraphicsWidth()/2.0,mx,5.0); my = MouseY() - GraphicsHeight()/2.0; DrawText(0,120,"mx = %f my = %f",mx,my); mx = max(mx,-150.0); mx = min(mx,150.0); my = min(my,30); my = max(my,-30); PivotRotation.X += my/10.0; PivotRotation.Y -= mx/4.0; MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); RotateEntity(MiddlePivot,Vec3(PivotRotation.X,PivotRotation.Y/5.0,0)); PointEntity(CameraPivot,MiddlePivot); PivotRotation.X = Curve(max(PivotRotation.X,-30.0),PivotRotation.X,2.0); PivotRotation.X = Curve(min(PivotRotation.X,23.0),PivotRotation.X,2.0); MoveEntity(CameraPivot,Vec3(TFormPoint(Vec3(0,1,-2),MiddlePivot,CameraPivot).X/5.0,TFormPoint(Vec3(0,1,-2),MiddlePivot,CameraPivot).Y/25.0,TFormPoint(Vec3(0,1,-2),MiddlePivot,CameraPivot).Z/5.0)); PositionEntity(MiddlePivot,Vec3(EntityPosition(Controller0).X,EntityPosition(Controller0).Y + 1.6,EntityPosition(Controller0).Z)); And the exe for testing is here(the same way as before,donwload the game.zip and replace the exe)Character.exe Quote Link to comment Share on other sites More sharing options...
Clackdor Posted January 4, 2012 Share Posted January 4, 2012 Thanks for posting this. It was useful to take some of your methods and adapt my own. I will need to post my 3rd person controller here soon. Quote 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.