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??