예제 #1
0
 void Start()
 {
     m_RigidBody     = GetComponent <Rigidbody>();
     m_Controller    = GetComponent <CarController>();
     m_Reward        = GetComponent <CarReward>();
     m_StartPosition = transform.position;
     m_StartRotation = transform.rotation;
 }
예제 #2
0
    // Give the car a punishment if it's not set to kill the car
    void OnCollisionStay(Collision collisionInfo)
    {
        CarReward car = collisionInfo.gameObject.GetComponentInParent <CarReward>();

        if (car)
        {
            if (!m_KillCar)
            {
                car.AddReward(m_Punishment);
            }
            else
            {
                car.Kill = true;
            }
        }
    }
예제 #3
0
    void OnTriggerEnter(Collider other)
    {
        CarReward car = other.gameObject.GetComponentInParent <CarReward>();

        if (car)
        {
            if (!m_KillCar)
            {
                car.AddReward(m_Punishment);
            }
            else
            {
                car.Kill = true;
            }
        }
    }
예제 #4
0
    // Add a reward to the car if it´s the currect checkpoint, otherwise give the car a punishment
    void OnCollisionEnter(Collision collision)
    {
        CarReward car = collision.gameObject.GetComponentInParent <CarReward>();

        if (!car)
        {
            return;
        }

        if (s_NextCheckpoint < 0 || m_CheckpointIndex < 0 || s_NextCheckpoint == m_CheckpointIndex)
        {
            // Correct checkpoint
            car.AddReward(m_Reward);
        }
        else
        {
            // Incorrect checkpoint
            car.AddReward(m_Punishment);
        }
    }