Hey,
I noticed in the Unity3 assets the smooth follow is gone along with the assets that went with the island demo.
Is there a suitable replacement I could use?
Thanks.
Hey,
I noticed in the Unity3 assets the smooth follow is gone along with the assets that went with the island demo.
Is there a suitable replacement I could use?
Thanks.
I wrote this, you can use it all you want.
using UnityEngine;
using System.Collections;
public class CameraControl: MonoBehaviour
{
public Transform followTransform;
public Vector3 offset = new Vector3(0f, 2.5f, -5f);
public float moveSpeed = 1;
public float turnSpeed = 1;
Vector3 goalPos;
//Quaternion goalRot;
// Use this for initialization
void Start()
{
if(!followTransform)
followTransform = GameObject.FindGameObjectWithTag("Player").transform;
if(!followTransform)
this.enabled = false;
}
void FixedUpdate()
{
goalPos = followTransform.position + followTransform.TransformDirection(offset);
transform.position = Vector3.Lerp(transform.position, goalPos, Time.deltaTime * moveSpeed);
transform.rotation = Quaternion.Lerp(transform.rotation, followTransform.rotation, Time.deltaTime * moveSpeed);
}
}
It will auto follow an object tagged Player if you forget to set the transform, otherwise will disable the script. The offset is how far from the object to stop.
Also, the scripts are in Scripts.unityPackage in Unity\Editor\Standard Packages\
it doesn’t work it says:unexected char ‘u’
and they don’t show the case ‘target’