Kotov72rus Posted December 10, 2012 Share Posted December 10, 2012 Hello. Show you how to rotate the camera around the object? Tried to fix this code: //Camera looking Player.mx=Curve(MouseX()-GraphicsWidth()/2,Player.mx,6); Player.my=Curve(MouseY()-GraphicsHeight()/2,Player.my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); Player.camrotation.X=Player.camrotation.X+Player.my/10.0; Player.camrotation.Y=Player.camrotation.Y-Player.mx/10.0; RotateEntity(Camera,Player.camrotation); but nothing Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted December 10, 2012 Share Posted December 10, 2012 you need a pivot. create the pivot with CreatePivot(character) parent the pivot to the character parent the camera to the pivot it looks like you have everything else right, just need a pivot. I assume this is a third person cam, so make sure the camera position is far from the character it's self. Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted December 10, 2012 Share Posted December 10, 2012 oh and after your frameworks update, set your pivot rotation to like...1 should look like: fw:Update() controllerPivot:SetRotation(camRotation,1) fw:Render() Quote Link to comment Share on other sites More sharing options...
Kotov72rus Posted December 10, 2012 Author Share Posted December 10, 2012 Thanks for the help 1 Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted December 10, 2012 Share Posted December 10, 2012 welcome 1 Quote Link to comment Share on other sites More sharing options...
Kotov72rus Posted December 11, 2012 Author Share Posted December 11, 2012 Works #pragma once #include "engine.h" #include "string" using namespace std; const int COLLISION_NONE = 0; const int COLLISION_PROP = 1; const int COLLISION_SCENE = 2; const int COLLISION_CHARACTER = 3; const int COLLISION_TRIGGER = 4; const int COLLISION_AILINEOFSIGHT = 5; class TPlayer { private: public: flt X,Y,Z; TCamera Camera; TMesh mesh; TEntity CameraPivot; float mx; float my; TVec3 camrotation; TController Controller; TMesh PlayerMesh; float move; float strafe; float Angle; void CreatePlayer(flt X, flt Y, flt Z); void Update(); }; TPlayer Player; //Global class void TPlayer::CreatePlayer(flt X, flt Y, flt Z) { Player.X = X; Player.Y = Y; Player.Z = Z; //Create player Controller = CreateController(2,0.3,0.5,45.01); EntityType(Controller,COLLISION_CHARACTER); PositionEntity(Controller,Vec3(X,Y,Z)); SetBodyDamping(Controller,0.0); SetWorldGravity(Vec3(0,-10,0)); SetBodyMass(Controller,50); //Set look camera position PositionEntity(Camera,Vec3(0,1,-4)); //Camera pivot CameraPivot=CreatePivot(); EntityParent(Camera, CameraPivot); //Load player mesh PlayerMesh = LoadMesh("abstract::crawler.gmf"); EntityType(PlayerMesh,COLLISION_CHARACTER); RotateEntity(PlayerMesh,Vec3(0,-180,0)); HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); Angle = -180; } void TPlayer::Update() { //Camera look mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.Y=camrotation.Y-mx/9.0; camrotation.X=camrotation.X+my/9.0; //Limit the viewing angle in the vertical camrotation.X=min(camrotation.X,60); //Look Up camrotation.X=max(camrotation.X,-10); //Look Down //Rotate Camera RotateEntity(CameraPivot,camrotation); //Position Camera PositionEntity(CameraPivot,EntityPosition(Controller)); //Player movement move=(KeyDown(KEY_W)-KeyDown(KEY_S))*4; strafe=(KeyDown(KEY_D)-KeyDown(KEY_A))*4; //Set controller input UpdateController(Controller,camrotation.Y,move,strafe,0,45); //Player mesh position and rotation PositionEntity(PlayerMesh,EntityPosition(Controller)); RotateEntity(PlayerMesh,Vec3(0,camrotation.Y+Angle,0)); } Add to main: #include "Player.h" Player.Camera = GetLayerCamera(GetFrameworkLayer(0)); Player.CreatePlayer(0,9,0); Add to main loop: Player.Update(); http://youtu.be/YCm9-y1E7kI 1 Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted December 12, 2012 Share Posted December 12, 2012 sweet, I like the red dot site and the effect you have on there... 1 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.