Jump to content

Position Entity with Rotation value


ParaToxic
 Share

Recommended Posts

Hey,

 

first a good new year :)

 

I have a problem with my controll for a 3rd person game.

 

I would like to rotate the camera ,which is directed with pointentity to the character,around the character with a radius of 3.5.

But I need it to do with the position not with the rotation.But I don't know how to make that.

I have only the angle in form of a float value and of curse the Character Mesh/Position...

 

Here is my professional painted picture ;)

 

pic.bmp

 

Thanks for help

Link to comment
Share on other sites

So are you trying to move the camera around your player using orbital positions rather than parenting to a pivot which is parented to your character?

 

Im not sure if that's what you mean so let me know. If that is what you mean, particularly why do you need to do that? If you give me some context I may be able to help better.

 

Regards,

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

I would like to position the camera around the Character with the angle value.

 

So I have only the Angle ,no Pivots.The Camera have to turn around the Character with the angle value.

 

post-2191-0-25037100-1325259588_thumb.png

 

 

EDIT: Better I tell you what I would do.

I made a easy controll with the following commands:

 


PositionEntity(MiddlePivot,Vec3(EntityPosition(Controller0).X,EntityPosition(Controller0).Y + 1.6,EntityPosition(Controller0).Z));

PointEntity(CameraPivot,MiddlePivot);

MoveEntity(CameraPivot,Vec3(TFormPoint(Vec3(0,1,-3),MiddlePivot,CameraPivot).X/40.0,TFormPoint(Vec3(0,1,-3),MiddlePivot,CameraPivot).Y/40.0,TFormPoint(Vec3(0,1,-3),MiddlePivot,CameraPivot).Z/40.0));

 

The Problem is if I would turn the Camera , I have to turn the MiddlePivot ,but its a very smoothlie turning because.

So I would like to add the rotation extern to CameraPivot (Camerapivot is actually the Camera self but it is in a protected class ,that i have to set the camera as a parent to the pivot).

Link to comment
Share on other sites

I did this with trigonometry.

Parented the camera to the player controller. Parented a Pivot that was about shoulder high. See my video for how this looks.

 

PositionEntity(camera,Vec3(0,1+mz*sin(atan(camrotation.X/40)),mz*cos(2*3.14-atan(camrotation.X/20))));
   PointEntity(camera,pivot);

Link to comment
Share on other sites

Thanks for the Code but I going to take my because it behaves differently.

 

I think I going to ask something else.

 

I have here the following code,but when the Pivot rotates to fast(you rotate it with the mouse) it "estimate" because of the smoothing.But I need this smoothing because I think it looks very good just this rotation problem is a problem.

 

Maybe somebody can tell me how to fix that,maybe with a "extern" Positioncoordinates for the rotation.

 

mx = MouseX() - GraphicsWidth()/2.0;
my = MouseY() - GraphicsHeight()/2.0;

PivotRotation.X += my;
PivotRotation.Y -= mx;

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);

RotateEntity(MiddlePivot,Vec3(PivotRotation.X,PivotRotation.Y/10.0,0));


PointEntity(CameraPivot,MiddlePivot);


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,-3),MiddlePivot,CameraPivot).X/40.0,TFormPoint(Vec3(0,1,-3),MiddlePivot,CameraPivot).Y/40.0,TFormPoint(Vec3(0,1,-3),MiddlePivot,CameraPivot).Z/40.0));


   PositionEntity(MiddlePivot,Vec3(EntityPosition(Controller0).X,EntityPosition(Controller0).Y + 1.6,EntityPosition(Controller0).Z));

Link to comment
Share on other sites

mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);
my=Curve(MouseY()-GraphicsHeight()/2,my,6);

PivotRotation.X += my/15;
PivotRotation.Y -= mx/15;

 

I do the curve when calculating the mx and my values. I, also, add the /15 modifier to make it not rotate as fast with the mouse in that same piece of code in my project. Of course, it could be made into a modifiable value based on user preference.

Link to comment
Share on other sites

By the way the problem is solved but I think I try to explane it again.

 

When you write PivotRotation += mx/15.0;

the Camera rotate to slow or a user will make it more intensive and put the value for exaple to PivotRotation += mx/5.0.

 

So I have the same problem as before,because if the pivot rotate ,the camera doesn't follow directly ,and when you rotate it to fast for example the pivot angle is 350° and the Cameraangle still 70° ,the camera will turn back ,because its faster to turn the other way.

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...