Jump to content

force and friction for camera movement


Rick
 Share

Recommended Posts

I'm playing around with a physics camera for an RTS style (top/down angled). I'm setting a high friction value but that still doesn't seem to make the camera stop smoothly when I release the keys that move the camera. Any ideas on how to get a smooth start/stop using a physics camera? When I let go of the keys I'd want maybe 1-2 seconds of small movement in the same direction from the point at which I let go of the keys.

 

Also I'm just adding force while the keys are down so it gets faster and faster. I like the idea of acceleration but only to a point where I'd want to maintain that velocity and never go over it.

Link to comment
Share on other sites

Does the SetFriction() function even work? The value I pass to the keneticfriction param (the one that as I understand stops the physics body when I stop applying force) is 50000000 but no matter how many more zeros I add the body still slides way too long after I let go, and I was able to cap the velocity of movement so it's not moving that fast.

Link to comment
Share on other sites

Isn't linear and angular damping different from friction? Friction is applied when a body interacts with another body. Dampening occurs over time.

 

Just a thought. Not sure what you're doing with your camera.

 

edit: Oh I just looked at the Leadwerks 3 commands, are there any commands for setting linear and angular dampening like you can in LE2 using SetBodyDamping()? It's not obvious to me.

 

edit2: I guess you could just multiply the velocity of the body by a value less than 1.0 in an UpdatePhysics() callback. That would do it.

  • Upvote 1

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

If you can do what Josh says, that's the easy option. If that fails you don't need to apply opposite forces. Just multiply it's own force by a smaller value than 1.0

 

psudo code...

 

 cameraBody->SetVelocity( cameraBody->GetVelocity() * (0.9 * appspeed()) );

 

Do that when not moving the camera.

 

Might want to add commands to set the dampening values to the suggestion box.

 

I suspect AddForce is not what I think it is. It reads like it's additive rather than absolute. BUT if you have write access to the velocity properties (can't test atm) it should be easy to multiply those values by 0.9 every frame to reduce them close to zero over time.

 

You don't notice missing commands until you try and do something that needs them.

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

I just want to see if I can get this working with physics now :)

 

I'll check out setting velocity directly to slow it to zero when not pressing a key down. If not opposite force should basically do the same thing although I have a feeling I'll always get more sliding than I want when trying to stop :-/

Link to comment
Share on other sites

It's possibly not working because my psudo code above didn't take into account that GetVelocity returns a vector. You need to multiply the returned velocity.

Vec3( 0.9 * Time::GetSpeed() , 0.9 * Time::GetSpeed() , 0.9 * Time::GetSpeed() )

 

You can't multiply a Vec3 by a single value and expect a Vec3 in return. If your code is LUA you're passing a weird value and that's why it's coming to a halt.

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

Yeah, I did a little debugging but because it's tied to key presses it's a pain to do normal breakpoints and step through because code runs when no key is pressed which stops it completely. I will need to print values out but I was lazy last night and just watched a movie instead :) I'll see what my motivation is like tonight. Thanks for the help.

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