- Home /
smooth Camera Follow On Y Axis Only !!Please HELP!!
Hi, I was wondering a way I can get my camera to only be able to go up Smooth on the y axis and not on the x-axis. This is for a mobile doodle jump like game. Here is the code I'm using.
 public class camerafollow : MonoBehaviour
 {
     public float dampTime = 0.15f;
     public Vector3 offeset;
     private Vector3 velocity = Vector3.zero;
     public Transform target;
 private void FixedUpdate()
     {
         Vector3 mpos = target.position + offeset;
         transform.position = Vector3.SmoothDamp(transform.position, mpos, ref velocity, dampTime);
     }
 
Answer by Harry_Drew · Jun 05, 2021 at 01:02 PM
Try this:
     void Update()
     {
         Vector3 targetPosition = target.position + offeset;
         Vector3 smoothedPosition = Vector3.MoveTowards(transform.position, targetPosition, smoothSpeed * Time.deltaTime);
         smoothedPosition.x = targetPosition.x;
         transform.position = smoothedPosition;
     }
It should be smooth on the Y axis but not on the X-Axis. If your wanting to make a game like doodle jump try using a deadzone so the camera only moves once the player moves more than the jump height.
Your answer
 
 
             Follow this Question
Related Questions
Make camera follow player and align direction 0 Answers
When I lock my camera to my player I saw only my default backround please help me :( 2 Answers
Rotate camera a set amount of degrees around Player 0 Answers
How can I put a maximum/min range for the Y axis of my freelockcamera ? 0 Answers
Make a camera to Follow two players 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                