- Home /
what to change that the camera does not move on the y-axis
using UnityEngine;
public class FollowPlayer : MonoBehaviour {
public Transform player;
public Vector3 offset;
void Update () {
transform.position = player.position + offset;
}
}
Comment
Best Answer
Answer by MonoFlauta · Oct 06, 2018 at 05:24 PM
You can do:
var targetPosition = player.position + offset;
transform.position = new Vector3(targetPosition.x, transform.position.y, targetPosition.z);
Let me know if that works for you.
Your answer
![](https://koobas.hobune.stream/wayback/20220612175901im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Possible to Output Render Texture or Camera Output to Multiple Displays? 0 Answers
2D Orthographic Main Camera and UI 0 Answers
Cinematic Playback Animation 1 Answer
Set the default 6d shake noise profile by script in Cinemachine? 0 Answers