The setup:
-
Player moves freely in x,y. Follows mouse or touch input using ScreenToWorldPoint.
-
Camera pans gradually faster as player object moves closer to edge, using WorldToScreenPoint.
-
If camera script is in LateUpdate, the player jitters on screen. The pan itself seems fine, it’s the player jumping to world point.
-
If camera script is in FixedUpdate, the player does NOT jitter, and pan also seems fine.
-
The above is with player set to Update, as a CharacterController. If set to FixedUpdate (should I decide to use RigidBody) the player lags behind in a weird way.
So the only way I am getting correct tracking is with the Player script in Update, and Camera script in FixedUpdate.
Since FixedUpdate is for physics, that can’t be right…right?
There are many people asking how to have a camera pan follow an object without any jumping jitters. There’s an answer here that might be a clue in how to solve this, but I don’t yet understand it:
Any help is greatly appreciated!
Is there ever a time when having a camera script in FixedUpdate makes sense? Like above? I mean…it’s working…
(don’t know if that will cause issues later, first game ever)
Added projectiles, and confirmed camera movement must be in LateUpdate, w/ player movement in FixedUpdate, for shots to fire from player.
The way I had it, there was no player lag, but shots lagged (rigidbodies)
What I’m trying to achieve:
- Player follow mouse & touch using ScreenToWorldPoint, just like a top down arcade shooter, but in xy
- Camera pan as player nears edge, just like a top down arcade shooter, but in xy (gradually faster from center to edge)
Problem:
- Player jitters and lags as camera pans.
Any help (or clues on what to research) is appreciated, but I will post the answer here when I figure it out.
Examples:
Gemini Strike
Air Attack (I need more pan than this, but it’s a kickass game!)
Just realized Gemini Strike does something different than my script.
Every touch point on screen is mapped to a larger overall scene. (there’s only mapped along x, below is xy)
Where ever you touch or swipe, the character and camera move to that respective point in the scene. Aside from a smooth transition (no teleport), the player is always under the touch.
Feels nice as you fly around the scene. More homework 