Ejemplo n.º 1
0
    /// <summary>
    /// Provides initialization
    /// </summary>
    private void Start()
    {
        if (!enabled)
            return;

        shipAttributes = GetComponent<ShipAttributesOnline>();
        objRigidBody = GetComponent<Rigidbody>();

        //Store initial position and rotation
        Vector3 initialPosition = transform.position;
        Quaternion initialRotation = transform.rotation;

        //Reset object's position and rotation
        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;

        Bounds bounds = GetComponent<Collider>().bounds;

        GenerateVoxels(bounds); //Generate buoyancy points

        objRigidBody.centerOfMass = FindCenterPoint(bounds, centerOfMassShiftY); //Get bounding box center, with applied Y axis offset and assign it as center of mass
        centerOfMass = objRigidBody.centerOfMass;
        boundingBoxCenter = FindCenterPoint(bounds, 1f); //Get bounding box center

        objVolume = GetObjectVolume(bounds); //Calculate approximate volume of an object
        objDensity = objRigidBody.mass / objVolume; //Calculate it's density

        //Set initial position and rotation back
        transform.position = initialPosition;
        transform.rotation = initialRotation;

        buoyancyMagnitude = (objRigidBody.mass * Mathf.Abs(Physics.gravity.y * gravityModifier));
        buoyancyForce = new Vector3(0f, buoyancyMagnitude, 0f);
        UpdateTotalBuoyancy();
    }
Ejemplo n.º 2
0
    void Start()
    {
        onlineRef = GameObject.Find("OnlineSceneReferences").GetComponent<OnlineSceneReferences>();
        shipAttributes = GetComponent<ShipAttributesOnline>();
        objRigidBody = GetComponent<Rigidbody>();

        //Store initial position and rotation
        Vector3 initialPosition = transform.position;
        Quaternion initialRotation = transform.rotation;
        //Reset object's position and rotation
        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;

        objBounds = GetComponent<Collider>().bounds;

        //Set initial position and rotation back
        transform.position = initialPosition;
        transform.rotation = initialRotation;

        onlineInput = GetComponent<OnlinePlayerInput>();
        customOnlinePlayer = GetComponent<CustomOnlinePlayer>();
        playerRespawn = GetComponent<PlayerRespawn>();

        rightCannons = rightSide.GetComponent<CannonGroup>();
        leftCannons = leftSide.GetComponent<CannonGroup>();
        rightLR = rightSide.GetComponent<LineRenderer>();
        leftLR = leftSide.GetComponent<LineRenderer>();

        SetupCamera();

        SetupControls();

        ResetShootAndMovement();
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     shipAttributes = transform.parent.GetComponent<ShipAttributesOnline>();
     ship = transform.parent;
     shipScript = ship.GetComponent<ShipScript>();
     lineRenderer = GetComponent<LineRenderer>();
     currentCharge = transform.childCount;
     cannonsCount = transform.childCount;
 }