private void AddRearWheel(GameObject body, Vector3 position) { carElements[1] = new GameObject(); //build rear wheel CircleMesh rearWheelScript = carElements[1].AddComponent <CircleMesh>(); float radius = Random.Range(0.2f, 1f); int sides = Random.Range(15, 30); rearWheelScript.Build(radius, sides, true, material); carElements[1].transform.position = position; //add pasive hinge rearWheelScript.AddHingeJoint(new JointMotor2D { motorSpeed = 0, maxMotorTorque = 0 }, body.GetComponent <Rigidbody2D>()); rearWheelScript.C_MR.material.color = Color.black; rearWheelScript.SetPhysicsMaterialProperties(0, 10f); }
// Use this for initialization void Start() { script = this.gameObject.AddComponent <CircleMesh>(); script.Build(1, 30, true, material); }