Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

Move camera at certain speed to the right but follow player in Y ?

$
0
0
The player is only moving to the right as well and the speed of the camera varies depending on the player actions. Ex: public float CameraScrollSpeed() { float speed = 9.4f;//default speed if (isClimbing) return 2.5f; else if (isRunning) return 7.0f; else if (isDashing) speed = 20.0f; //Screen pos is players position ralative to screen if (screenPos.x > Screen.width * 0.4f) speed = 20; return speed; } The default speed is normally faster than the player movement, the thing is I need the camera to have a limit when the player is too far to the right while still advancing. I tried making a simple camera follow while using MoveTowards() to move camera, but the camera stutters badly when the player reaches the limit public void CameraMove(){ float speed = CameraScrollSpeed(); transform.Translate(Vector3.right * speed * Time.deltaTime); playerPos.x = transform.position.x; transform.position = Vector3.Slerp(transform.position, playerPos, SmoothFactor); } Any ideas?

Viewing all articles
Browse latest Browse all 536

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>