Пример #1
0
    void  SetUpSkidmarks()
    {
        if (FindObjectOfType(typeof(Skidmarks)))
        {
            skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks));
            skidSmoke = skidmarks.GetComponentInChildren <ParticleEmitter>();
        }
        else
        {
            Debug.Log("No skidmarks object found. Skidmarks will not be drawn");
        }

        skidmarkTime = new float[4];
        for (int i = 0; i < 4; i++)
        {
            skidmarkTime[i] = 0.0f;
        }
    }
    public void Awake()
    {
        print("Game Awake");
        InitValues();
        enabled = _Loader.menuLoaded;
        //if (!online || PhotonNetwork.room != null)
        //    OnJoinedRoom();
        bounds      = GetLevelBounds();
        skidmarks   = GetComponentInChildren <Skidmarks>();
        m_skidSmoke = skidmarks.GetComponentInChildren <ParticleEmitter>();

        if (!_Loader.menuLoaded)
        {
            hostRoom      = new Room("", null);
            room.gameType = settings.gameType;
            _Loader.Connect();
        }
        else
        {
            Destroy(GameObject.Find("_test"));
        }
        Awake3();
    }
Пример #3
0
	void Start(){
		myTransform=transform;
		
		trs = myTransform.parent;
		while (trs != null && trs.rigidbody == null) trs = trs.parent;
		if (trs != null) body = trs.rigidbody;
		
		trs = myTransform.parent;
		while (trs.GetComponent<PhysicMaterials>() == null)  {if (trs.parent) trs = trs.parent; else break;}
		physicMaterials = trs.GetComponent<PhysicMaterials>();

		trs = myTransform.parent;		
		while (trs.GetComponent<CarDynamics>() == null)  trs = trs.parent;
		cardynamics = trs.GetComponent<CarDynamics>();
		drivetrain = trs.GetComponent<Drivetrain>();
		axles = trs.GetComponent<Axles>();
		
		localScale=1/(trs.localScale.y*myTransform.localScale.y);
		
		layerMask=1<<trs.gameObject.layer | 1<<myTransform.gameObject.layer;//LayerMask.NameToLayer("Wheel");
		layerMask=~layerMask;	
		
		radiusLoaded=radius;
		if (rimRadius==0) rimRadius=radius*0.735f;
		sidewallHeight=radius - rimRadius;

		if (mass<50*cardynamics.invFixedTimeStepScalar) mass=50*cardynamics.invFixedTimeStepScalar;
		if (rotationalInertia==0 || rotationalInertia<(mass/2)*radius*radius) rotationalInertia=(mass/2)*radius*radius;
		originalMass=mass;
				
		if (model==null) {
			model = new GameObject("temp_model");
			model.transform.parent=transform;
			model.transform.localPosition=new Vector3(0,0,0);
			model.transform.localRotation=Quaternion.identity;
			Debug.LogWarning("UnityCar: wheel model in " + wheelPos + " is missing. Using empty object" + " (" +trs.name+ ")");
		}
		
		modelTransform=model.transform;
		if (caliperModel!=null) caliperModelTransform=caliperModel.transform;
	
		skidmarks = cardynamics.skidmarks;
		if (skidmarks) skidSmoke = skidmarks.GetComponentInChildren(typeof(ParticleEmitter)) as ParticleEmitter;
		
		suspensionLineRenderer=gameObject.GetComponent<LineRenderer>();
		if (suspensionLineRenderer==null) suspensionLineRenderer = gameObject.AddComponent<LineRenderer>();
		suspensionLineRenderer.material = new Material(Shader.Find("Diffuse"));
		suspensionLineRenderer.material.color = Color.yellow;
		suspensionLineRenderer.SetWidth(0.01f,0.1f);
		suspensionLineRenderer.useWorldSpace = false;
		suspensionLineRenderer.castShadows = false;
	
		camber*=1; // to avoid never assigned warning
		if (camber==0){
			up = myTransform.up;
		}
		else{
			camberRotation = Quaternion.AngleAxis(-camber,forwardNormal);
			up = camberRotation*myTransform.up;
		}			
		
		SetTireStiffness();
	}
    public void Awake()
    {
        print("Game Awake");
        InitValues();
        enabled = _Loader.menuLoaded;
        //if (!online || PhotonNetwork.room != null)
        //    OnJoinedRoom();
        bounds = GetLevelBounds();
        skidmarks = GetComponentInChildren<Skidmarks>();
        m_skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>();

        if (!_Loader.menuLoaded)
        {
            hostRoom = new Room("", null);
            room.gameType = settings.gameType;
            _Loader.Connect();
        }
        else
            Destroy(GameObject.Find("_test"));
        Awake3();
    }
Пример #5
0
    void SetUpSkidmarks()
    {
        if(FindObjectOfType(typeof(Skidmarks)))
        {
            skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks));
            skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>();
        }
        else
            Debug.Log("No skidmarks object found. Skidmarks will not be drawn");

        skidmarkTime = new float[4];

        for(int i = 0 ; i < 4 ; i++){
            skidmarkTime[i] = 0.0f;
        }
    }
Пример #6
0
    void Start()
    {
        myTransform = transform;

        trs = myTransform.parent;
        while (trs != null && trs.rigidbody == null)
        {
            trs = trs.parent;
        }
        if (trs != null)
        {
            body = trs.rigidbody;
        }

        trs = myTransform.parent;
        while (trs.GetComponent <PhysicMaterials>() == null)
        {
            if (trs.parent)
            {
                trs = trs.parent;
            }
            else
            {
                break;
            }
        }
        physicMaterials = trs.GetComponent <PhysicMaterials>();

        trs = myTransform.parent;
        while (trs.GetComponent <CarDynamics>() == null)
        {
            trs = trs.parent;
        }
        cardynamics = trs.GetComponent <CarDynamics>();
        drivetrain  = trs.GetComponent <Drivetrain>();
        axles       = trs.GetComponent <Axles>();

        localScale = 1 / (trs.localScale.y * myTransform.localScale.y);

        layerMask = 1 << trs.gameObject.layer | 1 << myTransform.gameObject.layer;  //LayerMask.NameToLayer("Wheel");
        layerMask = ~layerMask;

        radiusLoaded = radius;
        if (rimRadius == 0)
        {
            rimRadius = radius * 0.735f;
        }
        sidewallHeight = radius - rimRadius;

        if (mass < 50 * cardynamics.invFixedTimeStepScalar)
        {
            mass = 50 * cardynamics.invFixedTimeStepScalar;
        }
        if (rotationalInertia == 0 || rotationalInertia < (mass / 2) * radius * radius)
        {
            rotationalInertia = (mass / 2) * radius * radius;
        }
        originalMass = mass;

        if (model == null)
        {
            model = new GameObject("temp_model");
            model.transform.parent        = transform;
            model.transform.localPosition = new Vector3(0, 0, 0);
            model.transform.localRotation = Quaternion.identity;
            Debug.LogWarning("UnityCar: wheel model in " + wheelPos + " is missing. Using empty object" + " (" + trs.name + ")");
        }

        modelTransform = model.transform;
        if (caliperModel != null)
        {
            caliperModelTransform = caliperModel.transform;
        }

        skidmarks = cardynamics.skidmarks;
        if (skidmarks)
        {
            skidSmoke = skidmarks.GetComponentInChildren(typeof(ParticleEmitter)) as ParticleEmitter;
        }

        suspensionLineRenderer = gameObject.GetComponent <LineRenderer>();
        if (suspensionLineRenderer == null)
        {
            suspensionLineRenderer = gameObject.AddComponent <LineRenderer>();
        }
        suspensionLineRenderer.material       = new Material(Shader.Find("Diffuse"));
        suspensionLineRenderer.material.color = Color.yellow;
        suspensionLineRenderer.SetWidth(0.01f, 0.1f);
        suspensionLineRenderer.useWorldSpace = false;
        suspensionLineRenderer.castShadows   = false;

        camber *= 1;       // to avoid never assigned warning
        if (camber == 0)
        {
            up = myTransform.up;
        }
        else
        {
            camberRotation = Quaternion.AngleAxis(-camber, forwardNormal);
            up             = camberRotation * myTransform.up;
        }

        SetTireStiffness();
    }
Пример #7
0
    protected void SetUpSkidmarks()
    {
	    if(FindObjectOfType(typeof(Skidmarks)))
	    {
		    skidmarks = FindObjectOfType(typeof(Skidmarks)) as Skidmarks;
		    skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>();
	    }
	    else
		    //Debug.Log("No skidmarks object found. Skidmarks will not be drawn");
		
	    skidmarkTime = new float[4];
        //foreach(float f in skidmarkTime)
        //    f = 0.0f;
    }
Пример #8
0
    void SetUpSkidmarks()
    {
        if (FindObjectOfType (typeof(Skidmarks))) {
            skidmarks = FindObjectOfType (typeof(Skidmarks)) as Skidmarks;
            skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter> ();
        } else
            Debug.Log ("No skidmarks object found. Skidmarks will not be drawn");

        skidmarkTime = new float[4] { 0.0f, 0.0f, 0.0f, 0.0f };
    }