簡體   English   中英

為什么我的角色/相機在Unity 2d中口吃?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM