- Home /
TPS Camera Help
Hey I'm new to using Unity3d and I've tried to make my own Custom Camera but it seems to studder. Any ideas?
using UnityEngine; using System.Collections;
 
               public class CCamera : MonoBehaviour { public GameObject targetPlayer;
  private float howFarForward;
 private float howFarRight;
 private float howFarLeft;
 private float rightNowForward;
 private float rightNowLeft;
 public float tooFar;
 public float tooRight;
 public float tooLeft;
 void LateUpdate()
 {
     transform.LookAt(targetPlayer.transform);
     //howFar1 = (this.transform.position.z * -1) + targetPlayer.transform.position.z;
    //howFar2 = (targetPlayer.transform.position.z) - this.transform.position.z;
     howFarForward = (targetPlayer.transform.position.z * -1) - this.transform.position.z;
     if (howFarForward < tooFar)
     {
         rightNowForward += 1f * Time.deltaTime;
     }
     howFarLeft = targetPlayer.transform.position.x - this.transform.position.x;
     if (howFarLeft < tooLeft)
     {
         rightNowLeft += -5f * Time.deltaTime;
     }
     else if (howFarLeft > tooLeft)
     {
         rightNowLeft += 5f * Time.deltaTime;
     }
     transform.position = new Vector3(rightNowLeft, transform.position.y, rightNowForward);
     transform.Rotate(0, 0, 0, Space.World);
 }
 }  
[code] doesn't work here; just select the code and hit the code button.
Answer by spinaljack · Apr 26, 2010 at 05:40 AM
you can smooth your movement over several frames with vector3 lerp
You can tweak the effect with a bit of slack, just add an if statement that only updates position after the camera is greater than a certain distance from the target
Your answer
 
 
             Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
my third person controller dose not have a camera. 1 Answer
throwing a ball camera position changes 0 Answers
Switch camera with mouse 2 Answers
move the object where camera look 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                