Rick Posted September 11, 2010 Share Posted September 11, 2010 I'm using some spectator code that I found around the forum that uses a body sphere to move the camera around. I like this because I want totally free camera movement, but I would prefer more precise movement. Currently the sphere takes awhile to come to a rest. When I let go of the movement key I would prefer it instantly stop. How can I achieve that? // setup code TBody spectator = CreateBodySphere(); SetBodyMass(spectator, 50); SetBodyGravityMode(spectator, 0); // disable gravity for this body SetBodyDamping(spectator, 500.0); EntityType(spectator, 3); SetBodyBuoyancyMode(spectator, 1); PositionEntity(spectator,Vec3(0,5,-10)); mx=Curve(MouseX()-GraphicsWidth()/2,mx,5); my=Curve(MouseY()-GraphicsHeight()/2,my,5); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); // main loop code camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(cam,camrotation); move=KeyDown(KEY_W)-KeyDown(KEY_S); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); TVec3 force = Vec3(strafe * 200.0,0,move * 200.0); force = TFormVector(force, cam, 0); AddBodyForce(spectator, force); PositionEntity(cam,EntityPosition(spectator)); Quote Link to comment Share on other sites More sharing options...
Canardia Posted September 11, 2010 Share Posted September 11, 2010 You can add a active break system and adjust the break factor: if( (move==0 && strafe==0 && jump==0 && autobrake) || KeyDown() ) { TVec3 vel=GetBodyVelocity( pla->body ); vel.X=-vel.X*2; vel.Y=-vel.Y*2; vel.Z=-vel.Z*2; AddBodyForce( pla->body, vel ); } 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...
Rick Posted September 11, 2010 Author Share Posted September 11, 2010 Sweet that works! Thanks. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted September 11, 2010 Share Posted September 11, 2010 Don't move the camera by "Forces" .... Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Rick Posted September 11, 2010 Author Share Posted September 11, 2010 Don't move the camera by "Forces" .... To get the physics to work with collisions on bodies (which is something I want) I have to move the bodies by forces don't I? I can't use anything else or it'll break the physics right? That's my understanding of it anyway. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted September 11, 2010 Share Posted September 11, 2010 what exactly are you trying to do? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Rick Posted September 11, 2010 Author Share Posted September 11, 2010 Move the camera around, but have it collide with bodies. I just needed the camera to stop faster because I dislike the sliding movement that was happening. Lumooja's code solved the issue though so it's all good. 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.