Skip to content

Instantly share code, notes, and snippets.

@moyashipan
Last active December 17, 2015 11:09
Show Gist options
  • Save moyashipan/5600216 to your computer and use it in GitHub Desktop.
Save moyashipan/5600216 to your computer and use it in GitHub Desktop.
script for "non-gravity racing game prototype"
public var forwardSpeed:Number;
public var steerAngle:Number;
public var rotationT:float = 0.25;
function FixedUpdate () {
var x:Number = Input.GetAxis("Horizontal");
var y:Number = Input.GetAxis("Vertical");
if (HitTestWithRoad()) {
}
this.rigidbody.velocity += y * transform.forward * forwardSpeed;
this.rigidbody.AddTorque(transform.up * x * steerAngle, ForceMode.Acceleration);
}
function OnCollisionEnter(collision:Collision) {
if (collision.gameObject.tag == 'roadWall') {
//var contact:ContactPoint = collision.contacts[0];
//this.gameObject.transform.position += contact.normal * 0.2;
}
}
function HitTestWithRoad() {
/* See http://gist.github.com/1271157 */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment