hi, im using a custom rigidbody movement script, and it works fine, it moves well and interacts with physics perfectly, but one problem, i can climb up walls witch i dont want, how do i fix that? this is the script, it in javascript:
var forwardSpeed = 10;
var backwardSpeed = 5;
var strafeSpeed = 8;
function FixedUpdate () {
// Step1: Get your input values
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
// Step 2: Limit the movement on angles and then multiply those results
// by their appropriate speed variables
percentofpercent = Mathf.Abs(horizontal) + Mathf.Abs(vertical) - 1.0;
if (percentofpercent > 0.1) {
// if we're here, then we're not moving in a straight line
// my math here might be kinda confusing and sloppy...so don't look!
percentofpercent = percentofpercent * 10000;
percentofpercent = Mathf.Sqrt(percentofpercent);
percentofpercent = percentofpercent / 100;
finalMultiplier = percentofpercent * .25;
horizontal = horizontal - (horizontal * finalMultiplier);
vertical = vertical - (vertical * finalMultiplier);
}
if (vertical > 0) {
vertical = vertical * forwardSpeed;
}
if (vertical < 0) {
vertical = vertical * backwardSpeed;
}
horizontal = horizontal * strafeSpeed;
// Step 3: Derive a vector on which to travel, based on the combined
// influence of BOTH axes
tubeFinalVector = transform.TransformDirection (Vector3(horizontal,0,vertical));
// Step 4: Apply the final movement in world space
rigidbody.velocity.z = tubeFinalVector.z;
rigidbody.velocity.x = tubeFinalVector.x;
}
function Awake () {
rigidbody.freezeRotation = true;
}