I don't want the blues coming out when the camera follows the player.,how do I destroy the blue background in my camera tracking
Hi ı'm new unity user. I don't want to see the blue in the back when the camera follows the player. While my game is playing the camera goes right down. and Cameram follows my player. But I don't want the background blues to appear. I would appreciate it if you could help.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class kamer : MonoBehaviour {
public Transform player;
public Vector3 offset;
void Update ()
{
transform.position = new Vector3 (player.position.x + offset.x, player.position.y + offset.y, offset.z); // Camera follows the player with specified offset position
}
} ,Hi , im new to unity and using unity. the player has the following camera. I don't want the background blue to appear when playing games and watching the camera player. I would appreciate it if you could help.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class kamer : MonoBehaviour {
public Transform player;
public Vector3 offset;
void Update ()
{
transform.position = new Vector3 (player.position.x + offset.x, player.position.y + offset.y, offset.z); // Camera follows the player with specified offset position
}
}
Answer by Hellium · Jan 08, 2019 at 10:11 AM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class kamer : MonoBehaviour
{
public Transform player;
public Vector3 offset;
// Specify the min and max position of the camera:
// x = min value on x axis
// y = min value on y axis
// z = max value on x axis
// w = max value on y axis
public Vector4 bounds;
void Update ()
{
// Camera follows the player with specified offset position
transform.position = new Vector3 (
Mathf.Clamp( player.position.x + offset.x, bounds.x, bounds.z ),
Mathf.Clamp( player.position.y + offset.y, bounds.y, bounds.w ),
offset.z
);
}
}
Are you SURE you have specified correct values in the bounds
variable?
(Obviously, bounds.z
must be greater than bounds.x
and bounds.w
must be greater than bounds.y
)
I'm new and I don't understand how to write the boundaries. I would appreciate if you write a sample.
As I indicated in the code, you have to change the values of the Boundaries
vector to prevent the camera from going too far to the left / the right. YOU have to choose the values according to your level.
X
is the LEFT boundary (`-2` for instance)Y
is the BOTTO$$anonymous$$ boundary (give it a negative value like-999999
if your player goes downwards)Z
is the RIGHT boundary (`2` for instance)W
is the TOP boundary (`50` for instance)
but it works. the camera is not going downwards. my game is a downward game.