Problem with rigidbody
I have a tank-shaped object. I want to move it using AddForce, but I just can't seem to set the values correctly. Most of the time the object just flips over or reaches ridiculous speed. I want it to move realistically. Here is my entire project.
i download your project working good.the only problem is with your cameraController script.write the follow camera code in LateUpdate() ins$$anonymous$$d of Update(). Tank not goes to the ridiculous speed. tank move smoothly but camera not following smoothly to your tank.
Answer by Crumbler · Mar 30, 2017 at 04:29 PM
i download your project working good.the only problem is with your cameraController script.write the follow camera code in LateUpdate() instead of Update(). Tank not goes to the ridiculous speed. tank move smoothly but camera not following smoothly to your tank.
Dear @sohail_786. The problem isn't related to the camera. The problem is in the player's tank object. After moving in 1 direction for about 10 or more seconds the tank starts flipping over. Not only that, but it also slides like if it were on ice. The tank also falls too slow.
Answer by SohailBukhari · Mar 30, 2017 at 04:57 PM
@username You was using quaternions to rotate your object. i made some changes to rigidbody component. I modified your LocalTankController script to move forward your tank. You can Use its Horizontals to move left or right. You can see values of rigidbody component are changed set as it is to your component. Set LocalTankController class moveforwardforce in the inspector.
using UnityEngine;
public class LocalTankController : MonoBehaviour {
public float moveforwardforce;
private Rigidbody _rb;
private void Start()
{
_rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void LateUpdate () {
if (Input.GetAxis("Vertical") > 0)
{
_rb.MovePosition(transform.position + transform.forward * Time.deltaTime*moveforwardforce);
}
}
}