Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        //get the car script component
        car = GetComponent <CarScript>();

        //get line script component
        line = GameObject.FindGameObjectWithTag("Line").GetComponent <LineScript>();

        //get the max velocity of the car
        maxCarVel = car.GetMaxVelocity();

        //get the steering(acceleration) scale of the car
        steeringValue = car.GetSteeringScale();

        //find the input and text objects in the scene and set them as variables here
        carPositionInputField  = GameObject.FindGameObjectWithTag("FuzzyCarPositionInputField");
        linePositionInputField = GameObject.FindGameObjectWithTag("FuzzyLinePositionInputField");
        velocityInputField     = GameObject.FindGameObjectWithTag("FuzzyVelocityInputField");
        steeringText           = GameObject.FindGameObjectWithTag("FuzzySteeringText").GetComponent <Text>();
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        //get the car script component from the car
        car = GetComponent <CarScript>();

        //get the line script component from the line
        line = GameObject.FindGameObjectWithTag("Line").GetComponent <LineScript>();

        //get max velocity from the car script
        maxCarVel = car.GetMaxVelocity();

        //get the steering scale(acceleration) from the car script
        steeringValue = car.GetSteeringScale();

        //find the input field and text objects that we want to change in the scene and set the mas variables
        carPositionInputField  = GameObject.FindGameObjectWithTag("RuleBasedCarPositionInputField");
        linePositionInputField = GameObject.FindGameObjectWithTag("RuleBasedLinePositionInputField");
        velocityInputField     = GameObject.FindGameObjectWithTag("RuleBasedVelocityInputField");
        steeringText           = GameObject.FindGameObjectWithTag("RuleBasedSteeringText").GetComponent <Text>();

        //set specific values for the rules to use
        //distance variable
        FarLeftDist  = -1.5f;
        LeftDist     = -0.025f;
        RightDist    = 0.025f;
        FarRightDist = 1.5f;

        //velocity variable
        FastLeftVel  = -0.75f * maxCarVel;
        LeftVel      = -0.25f * maxCarVel;
        RightVel     = 0.25f * maxCarVel;
        FastRightVel = 0.75f * maxCarVel;

        //steering output variables
        SteerHardLeft  = -0.75f * steeringValue;
        SteerLeft      = -0.5f * steeringValue;
        SteerRight     = 0.5f * steeringValue;
        SteerHardRight = 0.75f * steeringValue;
    }