[英]Why does my character/camera stutter in Unity 2d?
自從我添加了這個新的相機腳本以來,我的角色(相機正試圖遵循的角色)在移動時一直口吃。 如果我保持角色靜止不動,那么它將不再結結巴巴。
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CameraFollow : MonoBehaviour
{
public Transform lookat;
private bool smooth = true;
private float smoothSpeed = 0.1f;
private Vector3 offset = new Vector3 (0, 0, -6.5f);
void LateUpdate() {
Vector3 desiredPosition = lookat.transform.position + offset;
if (smooth) {
transform.position = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed);
} else {
transform.position = desiredPosition;
}
}
}
請幫助-這讓我發瘋了! 編輯:也請忽略底部的錯誤-這是我正在處理的其他內容的一部分。
EDIT2:沒關系,在rigidbody2d中打開插值可以解決問題! 謝謝你的幫助!
function! 釘書不是由於 函數引起的!
function, you would rather use the . 口吃可能是由於函數引起的,您寧願使用 。
像這樣
transform.position = Vector3.SmoothDamp(transform.position, desiredPosition, smoothSpeed);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.