Ejemplo n.º 1
0
    void Start()
    {
        foreach (var item in gameObject.GetComponentsInChildren <WheelCollider>())
        { // This forloop shouln'd exit but unity wouln'd link the correct wheels.
            if (item.name == "FrontWheel")
            {
                frontWheel = item;
            }
            else if (item.name == "BackWheel")
            {
                backWheel = item;
            }
        }

        MovementStart();

        pid = GetComponent <AiPid>();
        pid.UpdateErrorValue += () =>
        {
            pid.errorVariable = (aiSettings.targetSqrSpeed - velocitySqr) / aiSettings.targetSqrSpeed;

            float accel = (velocitySqr - lastVelocitySqr) / Time.deltaTime;

            float val = (aiSettings.targetMaximumAcceleration - accel) / aiSettings.targetMaximumAcceleration * pid.errorVariable;

            pid.errorVariable += val;
        };

        aiSettings.SetRandomValues();

        timeAlive = 0;
        InitialiseRespawn();
        respawn.CallRespawnAction();
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Respawn respawnScript = (Respawn)target;

        if (GUILayout.Button("Respawn player"))
        {
            try
            {
                respawnScript.CallRespawnAction();
            }
            catch (System.Exception)
            {
                throw;
            }
        }
    }
Ejemplo n.º 3
0
 private void OnCollisionEnter(Collision collision)
 {
     respawn.CallRespawnAction();
 }