- Home /
When I lock my camera to my player I saw only my default backround please help me :(
Here is the screenshot and I have script too if you want to look. using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CameraContoller : MonoBehaviour {
public Transform Target;
public float cameraSpeed;
void Start()
{
}
void Update()
{
transform.position = new Vector3(Target.position.x, Target.position.y, Target.position.z);
}
}
Answer by CobbledGames · Jan 06, 2021 at 01:56 PM
I'd recommend offsetting the camera transform position in your new vector3.
like this: new Vector3(Target.position.x, Target.position.y, Target.position.z - 3f);
if that's wrong do this: new Vector3(Target.position.x, Target.position.y, Target.position.z + 3f);
I am quite bad at visualizing vectors sorry.
Answer by tkati · Jan 06, 2021 at 04:55 PM
when I offset camera I tend to have a variable in the class space as Vector3 offset. then in the start() it something like offset = gameObject.transform.position - Target.transform.position. Then in update you'll add the offset to the target position. i usually do it like
transform.position = Target.transform.position + offset
for camera usually done it in LateUpdate() that way it's like last thing that gets changed.
Your answer
Follow this Question
Related Questions
Make camera follow player and align direction 0 Answers
How can camera smoothly follow a jerky game object? (bouncing up and down) 1 Answer
Resetting Camera with a key input 1 Answer
Camera smooth follow behaviour 0 Answers
Camera View Problem 0 Answers