Hey, I am having a few small problems that I am pretty much out of ideas for fixing.
here is the code before anything:
using UnityEngine;
using System.Collections;
public class Camera_beh : MonoBehaviour {
Transform target;
float zMov = 8.0f;
void Start () {
target = GameObject.Find("Player").transform;
}
void LateUpdate () {
RaycastHit hit;
if(Physics.Linecast(target.position, transform.position, out hit)){
zMov = hit.distance;
}else{
zMov = 8.0f;
}
Vector3 tempV = new Vector3(0, 0, -zMov);
transform.localPosition = tempV;
}
}
This is the script I have currently attached to my camera. The camera is a child of a child of the character. The character has a transform child (what the camera is a child of) which sits just above the character and is what i manipulate to rotate the camera in a third person environment. In other words, the camera has no movement or rotation manipulation on it, it follows its parents movement and rotation.
This is the only code I have on it and it is for detecting collision objects in front of it, then it moves in front of the collision.
The camera has no mesh collider or rigidbody attached to it.
Finally the problem I am having is that when the camera is forced into a bottom edge where a wall meets the floor, it starts to flicker. This also happens on a certain angle against a normal wall too.
My only guess could be that the camera is trying to go back to its default setting (-8.0) but I have debugged the linecast (hit.distance) to be constant and not flickering.
Thankyou