Question by
Francovanvuuren · Apr 10, 2016 at 12:33 PM ·
cs8025
Cs8025 need hepl!!!!!!!!!!!
using UnityEngine; using System.Collections;
public class cam folllow : MonoBehaviour {
public float interpVelocity;
public float minDistance;
public float followDistance;
public GameObject target;
public Vector3 offset;
Vector3 targetPos;
void Start ()
{
targetPos = transform.position;
}
void FixedUpdate ()
{
if (target)
{
Vector3 posNoZ = transform.position;
posNoZ.z = target.transform.position.z;
Vector3 targetDirection = (target.transform.position - posNoZ);
interpVelocity = targetDirection.magnitude * 5f;
targetPos = transform.position + (targetDirection.normalized * interpVelocity * Time.deltaTime);
transform.position = Vector3.Lerp( transform.position, targetPos + offset, 0.25f);
}
}
}
Comment
Answer by $$anonymous$$ · Apr 10, 2016 at 01:25 PM
Nothings wrong except change this
public class cam folllow : MonoBehaviour {
to this
public class camFolllow : MonoBehaviour {