首页 文章

游戏中的所有物体在移动玩家时来回振动(摇晃) . 我怎样才能让它顺利?

提问于
浏览
1

我是团结的新手,我搜索了这个问题,但找不到满意的答案 .

我有立方体作为玩家与刚体(重力停用)附加

还有很少的其他大型立方体作为建筑物和相机附加到玩家 .

当我用箭头键移动玩家时,它会平滑移动,但所有其他物体会振动,因为我会增加玩家地面的速度,而建筑物的星星会越来越振动 .


我的播放器脚本: -

using UnityEngine;
using System.Collections;

public class playerController : MonoBehaviour {

public Rigidbody player;
public float speed;
private Vector3 vect;

// Use this for initialization
void Start () {

    player = GetComponent<Rigidbody> ();
}


void  Update () {
    float moveH = Input.GetAxis ("Horizontal");
    float moveV = Input.GetAxis ("Vertical");
    vect = new Vector3 (moveH,0.0f,moveV);   
}

void FixedUpdate () {
    player.velocity = vect*speed;
}

}

2]我的相机脚本: -

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

public Transform player;
public  GameObject cameraa;
private Vector3 offset;
public float speed;


void Start () {

    //calculating offset
    offset = cameraa.transform.position - player.position;
}

// Update is called once per frame
void    FixedUpdate () {

    cameraa.transform.position = player.position + offset;
}
}
  • 在相机中我尝试了Update(),FixedUpdate()和LateUpdate(),但效果几乎相同且不平滑 .

如何让gound和其他物体顺利移动?

1 回答

  • 0

    您可以通过将物理设置中的Bounce-Threshold值(编辑>项目设置>物理> Bounce-Threshhold)更改为类似8来避免玩家振动

相关问题