Question by
dadadwete · Oct 02, 2016 at 03:06 PM ·
script.camera followcamera movementbegginer
Have problem with camera lerp moving
\Here's a my code.
using UnityEngine;
using System.Collections;
public class Camera_Chasing : MonoBehaviour
{
public Transform Player;
public bool Zoom_out;
public bool Waiting_room;
private Vector3 position;
private Vector3 position_2;
public float speed;
public float time;
public void Awake()
{
Zoom_out = false;
}
public void FixedUpdate()
{
if (!Zoom_out)
{
transform.position = Vector3.Lerp(transform.position, Player.position, speed * Time.fixedDeltaTime);
}
else if (Zoom_out) {}
}
}
This camera will chase the player. and it's work. but problem is camera's move.
I can't explain. As you can see, I have bad english. So I captured with gif. https://giphy.com/gifs/26ufltKY9fopBjTcA
It's like this. if player move 128, 64 to 0 , 0.
then move 1.13018301830 , -0.13081038103 like this. I don't know why.
It's okay if only camera is shaking very littel. cuz can't feel that strange move.
but that strange move ruin sprite's pixel. and it is an eyesore.
How can I fix it?
Here's a player move. maybe you need this.
switch (step)
{
case STEP.MOVE:
this.GetComponent<Transform> ().localPosition = Vector3.Lerp (Now_position, Next_position, speed);
if (this.transform.localPosition == Next_position)
{
Now_position = this.GetComponent<Transform> ().localPosition;
step = STEP.NONE;
}
break;
}
Comment