Unity3D Camera jittering when dragging -


i'm making game in want able drag camera across scene. wrote following code:

// when dragging     if(touchdetection.touchdragging && introbusy == false)     {         if(dragactive == false)         {             dragstartpos = touchdetection.touchpositionwp;             camerastartpos = camera.main.transform.position;             dragactive = true;             camerafollowingplayer = false;         }          vector2 temp = touchdetection.touchpositionwp - dragstartpos;         camera.main.transform.position = camerastartpos - new vector3(temp.x, temp.y, 0);     }     if(touchdetection.touchdragging == false)     {         dragactive = false;     } 

during drag, however, camera move, has jitter while moving. further away drag, bigger jitter becomes.

i've spent hours searching problem, have still not found solution.

a couple of points
1. it's practice move cameras in lateupdate rather in update. allows camera render after bodies have been moved.
2. rather setting transform.position directly, use vector3.movetowards or vector3.lerp set camera's position.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -