First problem is whenever i pass through the bridge i got this shaking movement on my car and it inclined to the left.
Second, I placed box colliders on each side of the bridge so that the car wont fall. Once the car collide on this colliders sideways it works but I can pass through it if I intentionally go to it perpendicularly.
Can someone help me?
Rigidbodies don't like it when their mass is over about 10- try scaling back the masses of everything to reduce unexpected behaviour! Remember that all units are dimensionless- rigidbody.mass is not measured in kilograms.
You have to rescale all your values, don't just make it lighter. As I said, rigidbodies start to act funny above a mass of about 20 or so- and your car weighs over 75 times that! You need to apply less force in your driving functions- then it won't fly so much.
Based on the comments above, I’d venture to say that your problem is applying transforms to the car rather than using the rigidbody. Collisions won’t work correctly if you transform the object. Instead, use rigidbody.MovePosition()
If you look at the docs, it shows you what input type is expected: function MovePosition (position : Vector3) : void So your code would be changed to: rigidbody.MovePosition (Vector3(forwardSpeed*Input.GetAxis("Player1Forward"))/800,0,0));
I am trying to work on rigidbody script i removed the issues on the floats and ints though i have another error
Object reference not set to an instance of an object
here is the script
var target : Transform;
private var speed = 1;
function Update ()
{
var forward = Vector3(speed*Input.GetAxis("Player1Forward")/800,0,0);
var back = Vector3(0,Input.GetAxis("Player1Back")/200,0);
var slow = Vector3(speed*Time.deltaTime*1/10,0,0);
rigidbody.MovePosition (rigidbody.position + forward);
rigidbody.MovePosition (rigidbody.position + slow);
rigidbody.MovePosition (rigidbody.position + back);
transform.Rotate (0,0,Input.GetAxis ("Player1Horizontal"));
}
The first thing I'd check is to make sure your object has a rigidbody. But if you look at the details of the error in the console, it will tell you the line number in your script where the error is occurring, which provides a lot more info on what could be missing.
Rigidbodies don't like it when their mass is over about 10- try scaling back the masses of everything to reduce unexpected behaviour! Remember that all units are dimensionless- rigidbody.mass is not measured in kilograms.
– syclamothYou have to rescale all your values, don't just make it lighter. As I said, rigidbodies start to act funny above a mass of about 20 or so- and your car weighs over 75 times that! You need to apply less force in your driving functions- then it won't fly so much.
– syclamothHonestly depends on how your car is controlled. If it's being moved with Rigidbody.Move, not Addforce, then it'll naturally want to climb like that!
– syclamothJustify which car script are you using from which tutorial?
– Meltdowntransform.Translate doesn't use physics! Why does your car have a rigidbody on it at all in that case?
– syclamoth