Jump to content

My 3rd person Controller


ParaToxic
 Share

Recommended Posts

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 ;)

(Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)

Link to comment
Share on other sites

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

 

:D

Link to comment
Share on other sites

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));



Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...