Esempio n. 1
0
    public void Start()
    {
        ctrlHub         = GameObject.Find("gameScenario");                                                                     //link to GameObject with script "controlHub"
        outsideControls = ctrlHub.GetComponent <controlHub>();                                                                 //to connect mulicontrol script to this one

        Vector3 setInitialTensor = GetComponent <Rigidbody>().inertiaTensor;                                                   //this string is necessary for Unity 5.3 with new PhysX feature when Tensor decoupled from center of mass

        GetComponent <Rigidbody>().centerOfMass  = new Vector3(CoM.localPosition.x, CoM.localPosition.y, CoM.localPosition.z); // now Center of Mass(CoM) is alligned to GameObject "CoM"
        GetComponent <Rigidbody>().inertiaTensor = setInitialTensor;                                                           ////this string is necessary for Unity 5.3 with new PhysX feature when Tensor decoupled from center of mass

        m_body = GetComponent <Rigidbody>();                                                                                   //seems strange, I know but three strings above strange too but necessary for PhysX ;(

        // wheel colors for understanding of accelerate, idle, brake(white is idle status)
        meshFrontWheel.GetComponent <Renderer>().material.color = UnityEngine.Color.black;
        meshRearWheel.GetComponent <Renderer>().material.color  = UnityEngine.Color.black;

        //for better physics of fast moving bodies
        m_body.interpolation = RigidbodyInterpolation.Interpolate;

        // too keep EngineTorque variable like "real" horse powers
        EngineTorque = EngineTorque * 20;

        //*30 is for good braking to keep frontBrakePower = 100 for good brakes. So, 100 is like sportsbike's Brembo
        frontBrakePower = frontBrakePower * 30;//30 is abstract but necessary for Unity5

        //technical variables
        normalRearSuspSpring  = (int)coll_rearWheel.suspensionSpring.spring;
        normalFrontSuspSpring = (int)coll_frontWheel.suspensionSpring.spring;

        baseDistance = coll_frontWheel.transform.localPosition.z - coll_rearWheel.transform.localPosition.z;// now we know distance between two wheels
    }
    private controlHub outsideControls; // making a link to corresponding bike's script



    private void Start()
    {
        ctrlHub         = GameObject.Find("gameScenario");                            //link to GameObject with script "controlHub"
        outsideControls = ctrlHub.GetComponent <controlHub>();                        // making a link to corresponding bike's script

        joystickImg     = bgImgJoyRight.transform.GetChild(0).GetComponent <Image>(); //find stick
        joystickImgLeft = bgImgJoyLeft.transform.GetChild(0).GetComponent <Image>();  //find stick
    }
Esempio n. 3
0
    controlHub outsideControls; // making a link to corresponding bike's script

    public void Start()
    {
        ctrlHub         = GameObject.Find("gameScenario");     //link to GameObject with script "controlHub"
        outsideControls = ctrlHub.GetComponent <controlHub>(); //to connect c# mobile control script to this one

        myAnimator = GetComponent <Animator>();
        lookPoint  = camPoint;//use it if you want to rider look at anything when riding

        //need to know when bike crashed to launch a ragdoll
        bikeController = bikeRideOn.GetComponent <BikeController>();
        myAnimator.SetLayerWeight(2, 0.0f); //to turn off layer with reverse animation which override all other
    }
Esempio n. 4
0
    private controlHub outsideControls; // making a link to corresponding bike's script

    // Use this for initialization
    void Start()
    {
        ctrlHub         = GameObject.Find("gameScenario");     //link to GameObject with script "controlHub"
        outsideControls = ctrlHub.GetComponent <controlHub>(); //to connect c# mobile control script to this one

        backCamera.enabled   = true;
        aroundCamera.enabled = false;
        currentCamera        = backCamera;

        if (GetComponent <Rigidbody> ())
        {
            GetComponent <Rigidbody> ().freezeRotation = true;
        }

        currentTargetAngle = cameraTarget.transform.eulerAngles.z;
    }
    //如果当前速度方向与追踪点的位置方向不一致,则进行角度补正

    // Use this for initialization
    void Start()
    {
        outsideControls = GetComponent <controlHub>();       // making a link to corresponding bike's script

        foreach (Transform child in parent)
        {
            destiantions.Add(child);
        }

        rig = GetComponent <Rigidbody> ();

        bc = GetComponent <BoxCollider> ();

        modelWidth  = bc.size.x * transform.localScale.x;
        modelHeight = bc.size.x * transform.localScale.y;

        prePointPosition = followPoint.position;

//		Debug.Log (modelWidth);
    }
    private controlHub outsideControls; // making a link to corresponding bike's script



    // Use this for initialization
    void Start()
    {
//		ctrlHub = GameObject.Find("gameScenario");//link to GameObject with script "controlHub"
        outsideControls = GetComponent <controlHub>();       // making a link to corresponding bike's script
    }