public override void produceBody() { TinkerBox.Specs spec = new TinkerBox.Specs(rootUnit.origin + new Vector3(0, .5f, 0), new Vector3(0, 0, 0), new Vector3(.8f, .8f, .8f)); GameObject floater = TinkerBox.createShape(PrimitiveType.Sphere, spec, "Floater", Color.red); TinkerBox.addMass(floater, 5); floater.GetComponent <Rigidbody>().useGravity = false; parts.Add(floater); floater.transform.parent = gameObject.transform; pointsensor xGoal = TinkerBox.addRelay(floater, rootUnit.controller, typeof(pointsensor), "x") as pointsensor; xGoal.setVoyeuree(rootUnit.environment.members[1]); pointsensor zGoal = TinkerBox.addRelay(floater, rootUnit.controller, typeof(pointsensor), "z") as pointsensor; zGoal.setVoyeuree(rootUnit.environment.members[1]); pointsensor xBall = TinkerBox.addRelay(floater, rootUnit.controller, typeof(pointsensor), "x") as pointsensor; xBall.setVoyeuree(rootUnit.environment.members[2]); pointsensor zBall = TinkerBox.addRelay(floater, rootUnit.controller, typeof(pointsensor), "z") as pointsensor; zBall.setVoyeuree(rootUnit.environment.members[2]); TinkerBox.addRelay(floater, rootUnit.controller, typeof(jet), "+x"); TinkerBox.addRelay(floater, rootUnit.controller, typeof(jet), "-x"); TinkerBox.addRelay(floater, rootUnit.controller, typeof(jet), "+z"); TinkerBox.addRelay(floater, rootUnit.controller, typeof(jet), "-z"); setInitialState(); }
//====== HELPER FUNCTIONS ======// public GameObject createSegment(Vector3 positionInput, int index, float max, float min) { // Main Body TinkerBox.Specs shape = new TinkerBox.Specs(new Vector3(0, .5f, 0) + positionInput, new Vector3(0, 0, 0), new Vector3(.5f, .2f, .3f)); GameObject model = TinkerBox.createShape(PrimitiveType.Cube, shape, "centibody" + rootUnit.id.ToString(), Color.red); TinkerBox.addMass(model, 1); parts.Add(model); // Leg 1 shape = new TinkerBox.Specs(new Vector3(0, .5f, -.35f) + positionInput, new Vector3(90, 0, 0), new Vector3(.1f, .2f, .1f)); GameObject up = TinkerBox.createShape(PrimitiveType.Cylinder, shape, "Left High" + rootUnit.id.ToString(), Color.yellow); TinkerBox.addMass(up, 1); parts.Add(up); shape = new TinkerBox.Specs(new Vector3(0, .25f, -.55f) + positionInput, new Vector3(0, 0, 0), new Vector3(.1f, .25f, .1f)); GameObject down = TinkerBox.createShape(PrimitiveType.Cylinder, shape, "Left Low" + rootUnit.id.ToString(), Color.yellow); TinkerBox.addMass(down, 1); parts.Add(down); TinkerBox.createHinge(up, model, new Vector3(0, 1, 0), new Vector3(0, 0, -.5f), new Vector3(1, 0, 0)); TinkerBox.createHinge(down, up, new Vector3(0, 1, 0), new Vector3(0, -1, 0), new Vector3(1, 0, 0)); TinkerBox.addLimitsToHinge(up, max, min); TinkerBox.addLimitsToHinge(down, max, min); TinkerBox.addRelay(up, rootUnit.controller, typeof(motor), ""); TinkerBox.addRelay(down, rootUnit.controller, typeof(motor), ""); TinkerBox.addRelay(down, rootUnit.controller, typeof(touchsensor), "Plane"); down.tag = "Lower"; // Leg 2 shape = new TinkerBox.Specs(new Vector3(0, .5f, .35f) + positionInput, new Vector3(90, 0, 0), new Vector3(.1f, .2f, .1f)); GameObject up2 = TinkerBox.createShape(PrimitiveType.Cylinder, shape, "Right High" + rootUnit.id.ToString(), Color.yellow); TinkerBox.addMass(up2, 1); parts.Add(up2); shape = new TinkerBox.Specs(new Vector3(0, .25f, .55f) + positionInput, new Vector3(0, 0, 0), new Vector3(.1f, .25f, .1f)); GameObject down2 = TinkerBox.createShape(PrimitiveType.Cylinder, shape, "Right Low" + rootUnit.id.ToString(), Color.yellow); TinkerBox.addMass(down2, 1); parts.Add(down2); TinkerBox.createHinge(up2, model, new Vector3(0, -1, 0), new Vector3(0, 0, .5f), new Vector3(1, 0, 0)); TinkerBox.createHinge(down2, up2, new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(1, 0, 0)); TinkerBox.addLimitsToHinge(up2, max, min); TinkerBox.addLimitsToHinge(down2, max, min); TinkerBox.addRelay(up2, rootUnit.controller, typeof(motor), "negative"); TinkerBox.addRelay(down2, rootUnit.controller, typeof(motor), "negative"); TinkerBox.addRelay(down2, rootUnit.controller, typeof(touchsensor), "Plane"); down.tag = "Lower"; return(model); }
public void createCup(Vector3 tableOrigin) { // Creates the cup TinkerBox.Specs cupSpec = new TinkerBox.Specs(new Vector3(0, 1, 0) + tableOrigin, new Vector3(0, 0, 0), new Vector3(.1f, .1f, .1f)); cup = addMember(TinkerBox.createShape(PrimitiveType.Cylinder, cupSpec, "cup", Color.blue)); TinkerBox.addMass(cup, 1); cup.tag = "Ball"; cup.AddComponent <PositiveCollision>(); cup.transform.position = new Vector3(0, 1.15f, 0) + tableOrigin; Rigidbody rb = cup.GetComponent <Rigidbody>(); //rb.isKinematic = true; rb.useGravity = false; }
public void createPlane(Vector3 planeSize) { // extremely simple create function to make the plane most environments include TinkerBox.Specs spec = new TinkerBox.Specs(rootUnit.origin, new Vector3(0, 0, 0), planeSize); GameObject plane = addMember(TinkerBox.createShape(PrimitiveType.Plane, spec, "Plane", Color.white)); TinkerBox.addMass(plane, 1); Rigidbody rb = plane.GetComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = true; plane.GetComponent <Renderer>().material = Resources.Load <Material>("CheckerPattern"); plane.GetComponent <Collider>().material = Resources.Load <PhysicMaterial>("BasicFriction"); plane.tag = "Plane"; }
public override void initializeEnvironment() { base.initializeEnvironment(); createPlane(new Vector3(2, 1, 2)); TinkerBox.Specs goalSpec = new TinkerBox.Specs(rootUnit.origin, new Vector3(0, 0, 0), new Vector3(.5f, .5f, .5f)); addMember(TinkerBox.createShape(PrimitiveType.Cube, goalSpec, "Goal", Color.green)); members[1].GetComponent <Collider>().material = Resources.Load <PhysicMaterial>("BasicFriction"); members[1].tag = "Goal"; TinkerBox.Specs ball = new TinkerBox.Specs(rootUnit.origin, new Vector3(0, 0, 0), new Vector3(.5f, .5f, .5f)); addMember(TinkerBox.createShape(PrimitiveType.Cube, goalSpec, "Moved", Color.blue)); TinkerBox.addMass(members[2], 1); members[2].GetComponent <Collider>().material = Resources.Load <PhysicMaterial>("HighFriction"); members[2].tag = "Ball"; setInitialState(); }
public override void produceBody() { TinkerBox.Specs teleSpec = new TinkerBox.Specs(new Vector3(0, 2, 0) + rootUnit.origin, new Vector3(0, 0, 0), new Vector3(.5f, .5f, .5f)); GameObject telebot = TinkerBox.createShape(PrimitiveType.Capsule, teleSpec, "Telebot", Color.red); parts.Add(telebot); telebot.GetComponent <Renderer>().material = Resources.Load <Material>("Metal"); telebot.transform.parent = gameObject.transform; TinkerBox.Specs r1spec = new TinkerBox.Specs(new Vector3(0, 1.75f, 0) + rootUnit.origin, new Vector3(0, 0, 0), new Vector3(.55f, .01f, .55f)); GameObject r1 = TinkerBox.createShape(PrimitiveType.Cylinder, r1spec, "RingOne", Color.red); parts.Add(r1); r1.GetComponent <Renderer>().material = Resources.Load <Material>("Gold"); r1.transform.parent = gameObject.transform; TinkerBox.Specs r2spec = new TinkerBox.Specs(new Vector3(0, 2f, 0) + rootUnit.origin, new Vector3(0, 0, 0), new Vector3(.55f, .01f, .55f)); GameObject r2 = TinkerBox.createShape(PrimitiveType.Cylinder, r2spec, "RingTwo", Color.red); parts.Add(r2); r2.GetComponent <Renderer>().material = Resources.Load <Material>("Gold"); r2.transform.parent = gameObject.transform; TinkerBox.Specs r3spec = new TinkerBox.Specs(new Vector3(0, 2.25f, 0) + rootUnit.origin, new Vector3(0, 0, 0), new Vector3(.55f, .01f, .55f)); GameObject r3 = TinkerBox.createShape(PrimitiveType.Cylinder, r3spec, "RingThree", Color.red); parts.Add(r1); r3.GetComponent <Renderer>().material = Resources.Load <Material>("Gold"); r3.transform.parent = gameObject.transform; pointsensor xCup = TinkerBox.addRelay(rootUnit.environment.members[11], rootUnit.controller, typeof(pointsensor), "x") as pointsensor; xCup.setVoyeuree(rootUnit.environment.members[6]); pointsensor zCup = TinkerBox.addRelay(rootUnit.environment.members[11], rootUnit.controller, typeof(pointsensor), "z") as pointsensor; zCup.setVoyeuree(rootUnit.environment.members[6]); TinkerBox.addRelay(rootUnit.environment.members[11], rootUnit.controller, typeof(jet), "x"); TinkerBox.addRelay(rootUnit.environment.members[11], rootUnit.controller, typeof(jet), "y"); TinkerBox.addRelay(rootUnit.environment.members[11], rootUnit.controller, typeof(jet), "z"); setInitialState(); }
public void createCrate(Vector3 crateOrigin, Vector3 crateDimensions) { // Creates the crate at the origin specified in the dimensions specified // Creates crate bottom TinkerBox.Specs bottomSpec = new TinkerBox.Specs(new Vector3(0, .05f, 0) + crateOrigin, new Vector3(0, 0, 0), new Vector3(crateDimensions.x - .05f, .1f, crateDimensions.z - .05f)); GameObject crateBottom = addMember(TinkerBox.createShape(PrimitiveType.Cube, bottomSpec, "crateBottom", Color.blue)); crateObjects.Add(crateBottom); crateBottom.GetComponent <Renderer>().material = Resources.Load <Material>("DarkWood"); crateBottom.tag = "Goal"; // Creates the sides TinkerBox.Specs oneSpec = new TinkerBox.Specs(new Vector3(-(crateDimensions.x / 2f), .25f, 0) + crateOrigin, new Vector3(0, 0, 0), new Vector3(.05f, .5f, crateDimensions.z + .05f)); GameObject sideOne = addMember(TinkerBox.createShape(PrimitiveType.Cube, oneSpec, "sideOne", Color.white)); crateObjects.Add(sideOne); sideOne.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); sideOne.tag = "NotGoal"; TinkerBox.Specs twoSpec = new TinkerBox.Specs(new Vector3((crateDimensions.x / 2f), .25f, 0) + crateOrigin, new Vector3(0, 0, 0), new Vector3(.05f, .5f, crateDimensions.z + .05f)); GameObject sideTwo = addMember(TinkerBox.createShape(PrimitiveType.Cube, twoSpec, "sideTwo", Color.white)); crateObjects.Add(sideTwo); sideTwo.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); sideTwo.tag = "NotGoal"; TinkerBox.Specs threeSpec = new TinkerBox.Specs(new Vector3(0, .25f, -(crateDimensions.z / 2f)) + crateOrigin, new Vector3(0, 0, 0), new Vector3(crateDimensions.x - .05f, .5f, .05f)); GameObject sideThree = addMember(TinkerBox.createShape(PrimitiveType.Cube, threeSpec, "sideThree", Color.white)); crateObjects.Add(sideThree); sideThree.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); sideThree.tag = "NotGoal"; TinkerBox.Specs fourSpec = new TinkerBox.Specs(new Vector3(0, .25f, (crateDimensions.z / 2f)) + crateOrigin, new Vector3(0, 0, 0), new Vector3(crateDimensions.x - .05f, .5f, .05f)); GameObject sideFour = addMember(TinkerBox.createShape(PrimitiveType.Cube, fourSpec, "sideFour", Color.white)); crateObjects.Add(sideFour); sideFour.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); sideFour.tag = "NotGoal"; }
//====== HELPER FUNCTIONS ======// public void createTable(Vector3 tableOrigin) { // Creates the table at the origin specified // Create Table Top TinkerBox.Specs topSpec = new TinkerBox.Specs(new Vector3(0, 1, 0) + tableOrigin, new Vector3(0, 0, 0), new Vector3(1, .1f, 2)); GameObject tableTop = addMember(TinkerBox.createShape(PrimitiveType.Cube, topSpec, "tableTop", Color.white)); tableObjects.Add(tableTop); tableTop.GetComponent <Renderer>().material = Resources.Load <Material>("DarkWood"); // Create the legs TinkerBox.Specs oneSpec = new TinkerBox.Specs(new Vector3(.4f, .5f, .94f) + tableOrigin, new Vector3(0, 0, 0), new Vector3(.1f, 1, .1f)); GameObject legOne = addMember(TinkerBox.createShape(PrimitiveType.Cube, oneSpec, "legOne", Color.white)); tableObjects.Add(legOne); legOne.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); TinkerBox.Specs twoSpec = new TinkerBox.Specs(new Vector3(.4f, .5f, -.94f) + tableOrigin, new Vector3(0, 0, 0), new Vector3(.1f, 1, .1f)); GameObject legTwo = addMember(TinkerBox.createShape(PrimitiveType.Cube, twoSpec, "legTwo", Color.white)); tableObjects.Add(legTwo); legTwo.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); TinkerBox.Specs threeSpec = new TinkerBox.Specs(new Vector3(-.4f, .5f, .94f) + tableOrigin, new Vector3(0, 0, 0), new Vector3(.1f, 1, .1f)); GameObject legThree = addMember(TinkerBox.createShape(PrimitiveType.Cube, threeSpec, "legThree", Color.white)); tableObjects.Add(legThree); legThree.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); TinkerBox.Specs fourSpec = new TinkerBox.Specs(new Vector3(-.4f, .5f, -.94f) + tableOrigin, new Vector3(0, 0, 0), new Vector3(.1f, 1, .1f)); GameObject legFour = addMember(TinkerBox.createShape(PrimitiveType.Cube, fourSpec, "legFour", Color.white)); tableObjects.Add(legFour); legFour.GetComponent <Renderer>().material = Resources.Load <Material>("LightWood"); }