public void SetupShip() { // Create rigidbody shipBody = gameObject.AddComponent <Rigidbody>(); shipBody.useGravity = false; shipBody.drag = 0; shipBody.angularDrag = 20; shipBody.constraints = RigidbodyConstraints.FreezeRotationY; // Create physics material shipPhysicsMaterial = new PhysicMaterial(); shipPhysicsMaterial.bounciness = 0; shipPhysicsMaterial.staticFriction = 0; shipPhysicsMaterial.dynamicFriction = 0; shipPhysicsMaterial.bounceCombine = PhysicMaterialCombine.Minimum; shipPhysicsMaterial.frictionCombine = PhysicMaterialCombine.Minimum; // Create ship axis shipAxis = new GameObject("Ship Axis"); shipAxis.transform.parent = transform; shipAxis.transform.localPosition = Vector3.zero; // Load ship GameObject ShipObject = Instantiate(Resources.Load("Ships/Test/LoadMe") as GameObject) as GameObject; ShipObject.transform.parent = shipAxis.transform; ShipObject.transform.localPosition = Vector3.zero; // Get ship settings settings = ShipObject.GetComponent <ShipSettings>(); // Create ship collider GameObject ShipCollider = new GameObject("Ship Collider"); ShipCollider.transform.parent = transform; ShipCollider.transform.localPosition = Vector3.zero; ShipCollider.AddComponent <BoxCollider>(); ShipCollider.GetComponent <BoxCollider>().size = settings.physColliderSize; ShipCollider.GetComponent <BoxCollider>().material = shipPhysicsMaterial; // Create controller controller = gameObject.AddComponent <ShipController>(); controller.controller = inputControl; // Camera if (bShipHasCameraControl) { shipCamera = Camera.main.gameObject; } // Attach forcefeedback manager vibrationManager = gameObject.AddComponent <FFManager>(); // Attach Audio/Visual Manager gameObject.AddComponent <ShipAVManager>(); }
public void SetupShip() { // Create rigidbody shipBody = gameObject.AddComponent<Rigidbody>(); shipBody.useGravity = false; shipBody.drag = 0; shipBody.angularDrag = 20; shipBody.constraints = RigidbodyConstraints.FreezeRotationY; // Create physics material shipPhysicsMaterial = new PhysicMaterial(); shipPhysicsMaterial.bounciness = 0; shipPhysicsMaterial.staticFriction = 0; shipPhysicsMaterial.dynamicFriction = 0; shipPhysicsMaterial.bounceCombine = PhysicMaterialCombine.Minimum; shipPhysicsMaterial.frictionCombine = PhysicMaterialCombine.Minimum; // Create ship axis shipAxis = new GameObject("Ship Axis"); shipAxis.transform.parent = transform; shipAxis.transform.localPosition = Vector3.zero; // Load ship GameObject ShipObject = Instantiate(Resources.Load("Ships/Test/LoadMe") as GameObject) as GameObject; ShipObject.transform.parent = shipAxis.transform; ShipObject.transform.localPosition = Vector3.zero; // Get ship settings settings = ShipObject.GetComponent<ShipSettings>(); // Create ship collider GameObject ShipCollider = new GameObject("Ship Collider"); ShipCollider.transform.parent = transform; ShipCollider.transform.localPosition = Vector3.zero; ShipCollider.AddComponent<BoxCollider>(); ShipCollider.GetComponent<BoxCollider>().size = settings.physColliderSize; ShipCollider.GetComponent<BoxCollider>().material = shipPhysicsMaterial; // Create controller controller = gameObject.AddComponent<ShipController>(); controller.controller = inputControl; // Camera if (bShipHasCameraControl) { shipCamera = Camera.main.gameObject; } // Attach forcefeedback manager vibrationManager = gameObject.AddComponent<FFManager>(); // Attach Audio/Visual Manager gameObject.AddComponent<ShipAVManager>(); }