1

I am new to unity, I searched for this problem but couldn't find satisfactory answer.

I have cube as player with rigidbody (gravity deactivated) attached

and few other big cubes as buildings and camera attached to player.

When I move player with arrow keys, it moves smoothly but all other objects vibrates, as I increase the speed of player ground and buildings stars vibrating more and more.


My Player Script:-

    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] My camera script:-

    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;
}
}
  • In camera I tried Update(), FixedUpdate() and LateUpdate() but effect was nearly same and not smooth.

How can I make gound and other object move smoothly??

Makarand
  • 983
  • 9
  • 27
  • Use AddForce instead of changing velocity if you want Physics to work properly (possibly will help with your current issue as well). On top of that, go for SmoothDamp (with moving the cam). If still not perfect, check drag values and Debug.Log velocity changes; my assumption would be you have an imperfect "slide" of the two surface but you "keep pushing hard" the cube –  Nov 22 '16 at 07:47
  • As a rule you cannot set the velocity of an object in Unity. Simply experiment with "AddForce". – Fattie Jan 25 '17 at 15:40

1 Answers1

0

You can avoid player from vibrating by changing the Bounce-Threshold value in physics settings b (edit > project-settings > physics > Bounce-Threshhold) to something like 8

DevHawk
  • 23
  • 8