Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Contract
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    2. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    3. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    4. Bugs*

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    6. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

Smooth camera transitions


Recommended Posts

Is there a way to interpolate camera smoothly using script hook?


Lets say the goal is to make a custom orbiting camera around your player character/current vehicle that you can control with a mouse.


AttachTo works nice when the character is moving, but it lags if you change offset.

Changing position of a detached camera to follow your character also lags.

Link to comment
Share on other sites

  • 1 month later...

The way I did it in my camera mod was using a method I have used for years... literally 30 years. When you move the camera, that creates a desired rotation position. You take the distance between the current rotation and subtract that from the desired rotation, that leaves you the difference. You then divide that difference by maybe 10 or 20, and then add that value to the current rotation and store it for next time round. That will accelerate the camera towards the desired rotation position and will naturally slow down as the distance between the two decreases. I use it a lot for scrolling things into and out of view, like panels etc...


If you want to keep a lid on the maximum value, then just do a Math.Min(CameraMoveValue, .1f) or something similar. That means that it will take the smallest value of either what you have calculated, or .1f. So the .1f becomes the maximum amount the camera can move in a single move-step.


I use the same technique in my mod for two situations, one is an orbiting cam that is always trying to maintain a fixed position relative to the player. The other is with a rising or falling camera that is moving towards a fixed point. It doesn't cater for acceleration though, so if you want that, then you'll need to implement an acceleration function into it.


Here's the short piece of code I use for the orbiting camera function. GetShortestAngle and Wrap are two separate functions for dealing with angles. The acceleration is not clamped in this function.

if (TrackTargetRotation){	float _difference = GetShortestAngle(OrbitRotationAngle, Rotation.Z);	float _inertialModifier = _difference / 20;	float _newOrbitRotation = Wrap(OrbitRotationAngle + _inertialModifier, -180, 180);	OrbitRotationAngle = _newOrbitRotation;}

For my falling camera, which is clamped, I use this... the rising one uses a slightly different clamp value but it's essentially the same thing.

case "Falling":	_riseVal = Position.Z - RiseFallTargetHeight;	_riseAmount = Math.Min(_riseVal, .7f);	Position.Z -= _riseAmount * fTimeModifier;	break;

It's quick, easy, easily customisable and avoids the need of setting up multiple cameras, if you only want something simple. If you want true interpolation though, what unknown modder posted is the best bet.

Link to comment
Share on other sites

  • 7 months later...

If you're wanting a camera interpolation, I'd suggest this


It involves creating a second camera where you want the destination


Works fine for me.


1. Create 1st camera and place it

2. Create 2nd camera and place it

3. Activate 1st camera and then use SET_CAM_ACTIVE_WITH_INTERP to 2nd cam from 1st. Do not forget to deactivate 1st camera

4. ?????

5. PROFIT!!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.