look at player and target Code + Explanation
Page 1 of 1
look at player and target Code + Explanation
Camera shown in vid
explanation(best i can do):
on the update method it places itself at the center point of the folow object determined by follow objects position and follow objects centerpoint(offset). then the camera points itself towards the target object and backs up the distance you want it to follow at.
script is pretty self-explained, if you don't understand.
- Code:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject FollowObject;
public float FollowDistance;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position = FollowObject.transform.position + FollowObject.GetComponent<Stats> ().centerPoint;
LookAtTarget ();
transform.position = transform.position - (transform.forward * FollowDistance);
}
void LookAtTarget(){
if (FollowObject.GetComponent<MechaController>().LockOn)
transform.LookAt (FollowObject.GetComponent<MechaController>().Target.transform);
else
transform.eulerAngles = FollowObject.transform.eulerAngles;
}
}
explanation(best i can do):
on the update method it places itself at the center point of the folow object determined by follow objects position and follow objects centerpoint(offset). then the camera points itself towards the target object and backs up the distance you want it to follow at.
script is pretty self-explained, if you don't understand.
InfinitasImpetum- (0%)-Lv8
- Posts : 2162
Join date : 2012-05-30
Age : 34
Similar topics
» [Tutorial] Local/Custom Battle Mode: 2-player/Multi-player Mode
» [Tutorial] How to Render an Image (Simple Explanation)
» Looking for MSGO Player
» [Tutorial] How to Render an Image (Simple Explanation)
» Looking for MSGO Player
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum