Ejemplo n.º 1
0
	void SetComponent(){
		drivetrain = GetComponent<Drivetrain>();
		cardynamics = GetComponent<CarDynamics>();
		forceFeedback= GetComponent<ForceFeedback>();
		physicMaterials =GetComponent<PhysicMaterials>();
		arcader= GetComponent<Arcader>();
		aerodynamicResistance= GetComponent<AerodynamicResistance>();
		axles= GetComponent<Axles>();
		axisCarController = GetComponent <AxisCarController>();
		mouseCarController = GetComponent <MouseCarController>();
		mobileCarController = GetComponent <MobileCarController>();		
		fuelTanks=GetComponentsInChildren<FuelTank>();
		wings=GetComponentsInChildren<Wing>();
	}
Ejemplo n.º 2
0
 void Awake()
 {
     body = GetComponent <Rigidbody>();
     originalCenterOfMass = body.centerOfMass;
     myTransform          = transform;
     drivetrain           = GetComponent <Drivetrain>();
     axisCarController    = GetComponent <AxisCarController>();
     mouseCarcontroller   = GetComponent <MouseCarController>();
     mobileCarController  = GetComponent <MobileCarController>();
     brakeLights          = GetComponent <BrakeLights>();
     dashBoard            = myTransform.GetComponentInChildren <DashBoard>();
     steeringWheel        = transform.GetComponentInChildren <SteeringWheel>();
     soundController      = GetComponent <SoundController>();
     SetController(controller.ToString());
     axles = GetComponent <Axles>();
     //frontWheels=axles.frontAxle.wheels;
     //rearWheels=axles.rearAxle.wheels;
     //otherWheels=axles.otherWheels;
     //axles.allWheels=axles.axles.allWheels;
     invAllWheelsLength     = 1f / axles.allWheels.Length;
     fixedTimeStepScalar    = 0.02f / Time.fixedDeltaTime;
     invFixedTimeStepScalar = 1 / fixedTimeStepScalar;
 }
Ejemplo n.º 3
0
    public void SetController(string strcontroller)
    {
        axisCarController   = GetComponent <AxisCarController>();       // to make this function works with SaveSetup()
        mouseCarcontroller  = GetComponent <MouseCarController>();      // to make this function works with SaveSetup()
        mobileCarController = GetComponent <MobileCarController>();     // to make this function works with SaveSetup()
        if (strcontroller == Controller.axis.ToString())
        {
            if (axisCarController == null)
            {
                axisCarController = transform.gameObject.AddComponent <AxisCarController>();
            }
            axisCarController.enabled = true;
            carController             = axisCarController;
            if (drivetrain != null)
            {
                drivetrain.carController = axisCarController;
            }
            if (brakeLights != null)
            {
                brakeLights.carController = axisCarController;
            }
            if (dashBoard != null)
            {
                dashBoard.carController = axisCarController;
            }
            if (steeringWheel != null)
            {
                steeringWheel.carController = axisCarController;
            }
            if (soundController != null)
            {
                soundController.carController = axisCarController;
            }
            if (mouseCarcontroller != null)
            {
                mouseCarcontroller.enabled = false;
            }
            if (mobileCarController != null)
            {
                mobileCarController.enabled = false;
            }
            controller = Controller.axis;
        }
        else if (strcontroller == Controller.mouse.ToString())
        {
            if (mouseCarcontroller == null)
            {
                mouseCarcontroller = transform.gameObject.AddComponent <MouseCarController>();
            }
            mouseCarcontroller.enabled     = true;
            mouseCarcontroller.smoothInput = false;
            carController = mouseCarcontroller;
            if (drivetrain != null)
            {
                drivetrain.carController = mouseCarcontroller;
            }
            if (brakeLights != null)
            {
                brakeLights.carController = mouseCarcontroller;
            }
            if (dashBoard != null)
            {
                dashBoard.carController = mouseCarcontroller;
            }
            if (steeringWheel != null)
            {
                steeringWheel.carController = mouseCarcontroller;
            }
            if (soundController != null)
            {
                soundController.carController = mouseCarcontroller;
            }
            if (axisCarController != null)
            {
                axisCarController.enabled = false;
            }
            if (mobileCarController != null)
            {
                mobileCarController.enabled = false;
            }
            controller = Controller.mouse;
        }
        else if (strcontroller == Controller.mobile.ToString())
        {
            if (mobileCarController == null)
            {
                mobileCarController = transform.gameObject.AddComponent <MobileCarController>();
            }
            mobileCarController.enabled = true;
            carController = mobileCarController;
            if (drivetrain != null)
            {
                drivetrain.carController = mobileCarController;
            }
            if (brakeLights != null)
            {
                brakeLights.carController = mobileCarController;
            }
            if (dashBoard != null)
            {
                dashBoard.carController = mobileCarController;
            }
            if (steeringWheel != null)
            {
                steeringWheel.carController = mobileCarController;
            }
            if (soundController != null)
            {
                soundController.carController = mobileCarController;
            }
            if (axisCarController != null)
            {
                axisCarController.enabled = false;
            }
            if (mouseCarcontroller != null)
            {
                mouseCarcontroller.enabled = false;
            }
            controller = Controller.mobile;
        }

        else if (strcontroller == Controller.external.ToString())
        {
            if (mouseCarcontroller != null)
            {
                mouseCarcontroller.throttle = drivetrain.throttle = 0; mouseCarcontroller.enabled = false;
            }
            if (axisCarController != null)
            {
                axisCarController.throttle = drivetrain.throttle = 0; axisCarController.enabled = false;
            }
            if (mobileCarController != null)
            {
                mobileCarController.throttle = drivetrain.throttle = 0; mobileCarController.enabled = false;
            }
            controller = Controller.external;
        }
    }
Ejemplo n.º 4
0
	public void SetController(string strcontroller){
		axisCarController = GetComponent <AxisCarController>(); // to make this function works with SaveSetup()
		mouseCarcontroller = GetComponent <MouseCarController>(); // to make this function works with SaveSetup()
		mobileCarController = GetComponent <MobileCarController>(); // to make this function works with SaveSetup()
		if (strcontroller==Controller.axis.ToString() ) {
			if (axisCarController==null){
				axisCarController=transform.gameObject.AddComponent<AxisCarController>();
			}
			axisCarController.enabled=true;
			carController=axisCarController;
			if (drivetrain!=null) drivetrain.carController=axisCarController;
			if (brakeLights!=null) brakeLights.carController=axisCarController;
			if (dashBoard!=null) dashBoard.carController=axisCarController;
			if (steeringWheel!=null) steeringWheel.carController=axisCarController;
			if (soundController!=null) soundController.carController=axisCarController;
			if (mouseCarcontroller!=null) mouseCarcontroller.enabled=false;
			if (mobileCarController!=null) mobileCarController.enabled=false;
			controller=Controller.axis;
		}	
		else if (strcontroller==Controller.mouse.ToString()){
			if (mouseCarcontroller==null){
				mouseCarcontroller=transform.gameObject.AddComponent<MouseCarController>();
			}
			mouseCarcontroller.enabled=true;
			mouseCarcontroller.smoothInput=false;
			carController=mouseCarcontroller;
			if (drivetrain!=null) drivetrain.carController=mouseCarcontroller;
			if (brakeLights!=null) brakeLights.carController=mouseCarcontroller;
			if (dashBoard!=null) dashBoard.carController=mouseCarcontroller;
			if (steeringWheel!=null) steeringWheel.carController=mouseCarcontroller;
			if (soundController!=null) soundController.carController=mouseCarcontroller;
			if (axisCarController!=null) axisCarController.enabled=false;
			if (mobileCarController!=null) mobileCarController.enabled=false;
			controller=Controller.mouse;
		}
 		else if (strcontroller==Controller.mobile.ToString()){
			if (mobileCarController==null){
				mobileCarController=transform.gameObject.AddComponent<MobileCarController>();
			}
			mobileCarController.enabled=true;
			carController=mobileCarController;
			if (drivetrain!=null) drivetrain.carController=mobileCarController;
			if (brakeLights!=null) brakeLights.carController=mobileCarController;
			if (dashBoard!=null) dashBoard.carController=mobileCarController;
			if (steeringWheel!=null) steeringWheel.carController=mobileCarController;
			if (soundController!=null) soundController.carController=mobileCarController;
			if (axisCarController!=null) axisCarController.enabled=false;
			if (mouseCarcontroller!=null) mouseCarcontroller.enabled=false;
			controller=Controller.mobile;
		}
	
		else if (strcontroller==Controller.external.ToString() ){
			if (mouseCarcontroller!=null) {mouseCarcontroller.throttle=drivetrain.throttle=0;mouseCarcontroller.enabled=false;}
			if (axisCarController!=null) {axisCarController.throttle=drivetrain.throttle=0;axisCarController.enabled=false;}
			if (mobileCarController!=null) {mobileCarController.throttle=drivetrain.throttle=0;mobileCarController.enabled=false;}
			controller=Controller.external;
		}		
	}
Ejemplo n.º 5
0
	void Awake(){
		body=rigidbody;
		originalCenterOfMass=body.centerOfMass;
		myTransform=transform;
		drivetrain= GetComponent<Drivetrain>();
		axisCarController = GetComponent <AxisCarController>();
		mouseCarcontroller = GetComponent <MouseCarController>();
		mobileCarController = GetComponent <MobileCarController>();
		brakeLights=GetComponent <BrakeLights>();
		dashBoard = myTransform.GetComponentInChildren <DashBoard>();
		steeringWheel = transform.GetComponentInChildren <SteeringWheel>();
		soundController=GetComponent<SoundController>();
		SetController(controller.ToString());
		axles=GetComponent<Axles>();
		//frontWheels=axles.frontAxle.wheels;
		//rearWheels=axles.rearAxle.wheels;
		//otherWheels=axles.otherWheels;
		//axles.allWheels=axles.axles.allWheels;
		invAllWheelsLength=1f/axles.allWheels.Length;
		fixedTimeStepScalar=0.02f/Time.fixedDeltaTime;
		invFixedTimeStepScalar=1/fixedTimeStepScalar;		
	}