コード例 #1
0
 private void OnCollisionEnter2D(Collision2D c)
 {
     if (c.gameObject.tag == "Track")
     {
         body.transform.position = startPos;
         body.transform.rotation = Quaternion.identity;
         body.GetComponent <Rigidbody2D>().velocity           = Vector3.zero;
         body.GetComponent <Rigidbody2D>().angularVelocity    = 0;
         Wheel_b.GetComponent <Rigidbody2D>().angularVelocity = 0;
         Wheel_f.GetComponent <Rigidbody2D>().angularVelocity = 0;
     }
 }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey("d"))
     {
         Wheel_f.AddTorque(-power);
         Wheel_b.AddTorque(-power);
     }
     if (Input.GetKey("a"))
     {
         Wheel_f.AddTorque(power);
         Wheel_b.AddTorque(power);
     }
 }