• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Camera Smooth Factor - basic questions

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
So I've already made a custom map with my own missile and flying system. Somehow I never knew about the Camera action "Smooth Factor."

I put it into my map and set it to 10, and all of a sudden that jumpy scrolling at the sides of the map suddenly became smooth! Unfortunately, as my camera is locked on a unit at the center of the map, and that unit is moved every .03 seconds with a trigger... the unit suddenly becomes jittery. It seems I can have smooth scrolling or a smooth tracking of your primary unit, but not both.

Is this tradeoff correct? Is there some way of having smooth scrolling and smooth tracking?
 
Level 14
Joined
Aug 30, 2004
Messages
909
That is interesting. I can see the basic effect with a smooth value as low as about .06. I think my problem is unavoidable: I am moving my units with their own custom movement system which moves units every .03 seconds. A smooth panning camera will show that as jumpy I guess. Where as a more jumpy camera can be locked onto the unit.

What I need is one of those SC2 commands that smoothly moves a unit over a stretch of time, but I'm afraid that's too much to ask for.

Thanks anyway.
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
Why do you need CameraSmoothing if you want to follow a unit anyway? Just lock the camera to the unit?

0.03 second displacement intervals equal to 33 FPS. That should be smooth enough. The human eye might still tell the difference between camera scrolling on 33 FPS and camera scrolling on 60 FPS. But you can interpolate manually here.

Just compare the new position of the unit to the position of the last iteration cycle to get it's dx and dy values. Then, between each unit movement cycle, just move the camera to the last X and y + dx/2 and dy/2.

Notice that the GetCameraTargetPositionX() natives only get updated like once every 0.05 seconds. If you need to rely on those, you will never get a real smooth movement.
 
Level 6
Joined
Jan 17, 2014
Messages
166
If you know the path and the speed of the unit, you can program the camera to move from point A to point B in X seconds.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Why do you need CameraSmoothing if you want to follow a unit anyway? Just lock the camera to the unit?

0.03 second displacement intervals equal to 33 FPS. That should be smooth enough. The human eye might still tell the difference between camera scrolling on 33 FPS and camera scrolling on 60 FPS. But you can interpolate manually here.

Just compare the new position of the unit to the position of the last iteration cycle to get it's dx and dy values. Then, between each unit movement cycle, just move the camera to the last X and y + dx/2 and dy/2.

Notice that the GetCameraTargetPositionX() natives only get updated like once every 0.05 seconds. If you need to rely on those, you will never get a real smooth movement.

I do usually lock the camera to a unit and it follows the unit smoothly. The problem (which is minor) is that in the corners of the screen the camera doesn't seem to move very smoothly. When I raise the smoothing factor the corners look smoother, but the unit is jumpy.

When I get home I'll try moving the camera between movement cycles. I don't know much about the internal non-GUI portions of the editor though. My movement trigger fires every .03 seconds. Can I move the player's camera every .01 seconds to track the unit?
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
My movement trigger fires every .03 seconds. Can I move the player's camera every .01 seconds to track the unit?
Yes, but it will make no difference, as it basicly repeats the same position three times in that case. You need to interpolate the unit movement to kind of get a "virtual" position of the unit between each position change to pan the camera to.

Why don't you just use PanCameraTimed instead of SetCameraSmoothingFactor? The duration for PanCameraTimed should be the timer interval.
 
If your unit appears jumpy when moved through a script, it might also be because it is trying to move away from its current position. If a unit still has movement speed and is moved using SetUnitX/Y, then it will try to move back to the last position to which it was ordered. The solution to this is to either remove the movement speed, or use SetUnitPosition.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Yes, but it will make no difference, as it basicly repeats the same position three times in that case. You need to interpolate the unit movement to kind of get a "virtual" position of the unit between each position change to pan the camera to.

Why don't you just use PanCameraTimed instead of SetCameraSmoothingFactor? The duration for PanCameraTimed should be the timer interval.

EDIT: Please ignore the trigger below, I see the problem with it...

I've come back to this problem after fixing some other stuff. I still haven't got the game to be smooth looking unfortunately. I attempted Zwiebelchen's solution above. Here is the trigger (note that "Fliers[1]" is the player's ship; and FlierSpeed[1] is the distance the ship is moved every .03 seconds):

  • cameraTEST Repeat
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set testPOINT2 = (Position of Fliers[1])
      • Set testPOINT = (testPOINT2 offset by (FlierSpeed[1] / 3.00) towards (Facing of Fliers[1]) degrees)
      • Camera - Pan camera for Player 1 (Red) to testPOINT over 0.01 seconds
      • Camera - Set Player 1 (Red)'s camera Distance to target to CameraDistance[1] over 0.00 seconds
      • Custom script: call RemoveLocation(udg_testPOINT)
      • Custom script: call RemoveLocation(udg_testPOINT2)
It does follow the player's ship as intended, but it's extremely choppy. There are times when it seems to work slightly better than others, but I can't seem to predict these. I've tried it at varying speed levels, with various camera smoothing factors, and with different pan times (.01 and .00).

I'm worried this is impossible. Has anyone made a custom missile system with a really smooth camera?

p.s. Fingolfin, that is a clever idea. It is not the case here though; I paused the unit and it still has a choppy camera. It also appears when the unit is by itself and has not been given any move orders.
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
Turn off camera smoothing if you use Camera Panning.

This is what you want to do in pseudo-code:

Code:
Every 0.03 seconds:
- Move the unit around
- Store the content of "CurrentX" and "CurrentY" variables into "LastX" and "LastY" variables ... these are the variables that hold the data of the last iteration cycle
- Store the current position of the unit into "CurrentX" and "CurrentY" variables to get a new fresh set of data
- Calculate the XY speed of the unit:
SpeedX = CurrentX - LastX
SpeedY = CurrentY - LastY
- Pan the camera within 0.03 seconds to "CurrentX+SpeedX" and "CurrentY+SpeedY"

If this looks choppy then the solution is plain and simple: the game performance is just bad in general.
Optimize your code to make the game less choppy, then the camera will be smoother aswell.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Turn off camera smoothing if you use Camera Panning.

This is what you want to do in pseudo-code:

Code:
Every 0.03 seconds:
- Move the unit around
- Store the content of "CurrentX" and "CurrentY" variables into "LastX" and "LastY" variables ... these are the variables that hold the data of the last iteration cycle
- Store the current position of the unit into "CurrentX" and "CurrentY" variables to get a new fresh set of data
- Calculate the XY speed of the unit:
SpeedX = CurrentX - LastX
SpeedY = CurrentY - LastY
- Pan the camera within 0.03 seconds to "CurrentX+SpeedX" and "CurrentY+SpeedY"

If this looks choppy then the solution is plain and simple: the game performance is just bad in general.
Optimize your code to make the game less choppy, then the camera will be smoother aswell.

Thanks so much, I'll try that. I had something like it working nicely (though I'm not sure if I remembered to turn off the camera smoothing). It looked very much as it did when I just locked the camera to the unit.

The choppiness isn't terrible; it's the same as the map I released years ago. No one commented on it, so perhaps we're all just used to it in these types of games, but it still looks odd to me. I'll see if I can make demo map to illustrate my point.


EDIT:

I've made a test map to illustrate what I mean:

http://www.hiveworkshop.com/forums/pastebin_data/u2ax47/_files/camera choppiness.w3x

The griffon will fly around just fine with the camera looked on him. The griffon looks really good and smooth, but if you stare at a grassy patch or a tree, it looks really choppy.

Now if you press the UP ARROW key, the camera smoothing factor will be set to 1. Now the tree and grass patch look smooth, but the flier looks awful. Press DOWN ARROW to switch back.

Obviously what I'm looking for is a smooth camera that makes both look good. If you (or anyone) could do this on this test map I'll be more than grateful! I'm worried it's impossible.
 
Last edited:
Status
Not open for further replies.
Top