Hi!
I’ve been looking everywhere for this but cant find anything…
Basically, My Player is located in the center of the screen. but I want him to be further down on the Y axis.
Something like, .y axis - 50… So I get more space above him… Make sense?
My current script… I dont know what to write or where to put it :S
Thanks in advance!
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour {
[SerializeField]
private float xMax;
// Update is called once per frame
void LateUpdate()
{
transform.position = new Vector3(Mathf.Clamp(target.position.x, xMin, xMax), Mathf.Clamp(target.position.y, yMin, yMax), transform.position.z);
}
}
Now, to your question… Suppose you set an offset (height, in this case). You then add that to the target position, and make sure the yMin and yMax accomodate it, too.
You can do this like:
Vector3 offset = new Vector3(0,target.position.y - 2,0);
// Now, use 'offset.y' instead of target.position.y in your position assignment
Im a Unity beginner and cant get around unless I watch Tutorials… Where am I supposed to put this script?
The ““transform.position = new Vector3(Mathf…”” is to make sure the camera don’t go outside the level.
So I guess Im not gonna put your script in there?
I want to make sure that my character is located in the bottom of the screen… So I guess “player” is the “target”? And I have to add your script around there? But how?
Thansk in advance if you have an answer for my noob question
I went back and checked again and the warning is gone. I think my “max y,x Min y,x” number was reset so the camera was wining about that. Sooo,.,… basically its all god now!