//setter public void SetCurrentState(ROBOT_STATES state) { states_enum = state; parent_object.GetComponent <Rigidbody2D>().velocity = Vector2.zero; if (current_state != null) { current_state.gameObject.SetActive(false); } current_state = states[(int)states_enum]; current_state.gameObject.SetActive(true); }
// Use this for initialization void Start() { //SetCurrentState(roam_state); parent_object = transform.parent.gameObject; states_enum = ROBOT_STATES.ROAM; SetCurrentState(states[(int)states_enum]); disignated_position = new Vector3(Random.Range(-4, 5), Random.Range(-4, 5), 1); //get the sprite size robot_sprite_renderer = parent_object.GetComponent <SpriteRenderer>(); robot_sprite = robot_sprite_renderer.sprite; robot_sprite_size = robot_sprite.rect.size; robot_local_sprite_size = robot_sprite_size / robot_sprite.pixelsPerUnit; robot_sprite_across_length = Mathf.Sqrt(robot_local_sprite_size.x * robot_local_sprite_size.x + robot_local_sprite_size.y * robot_local_sprite_size.y); //parent_object.GetComponent<SpriteRenderer>().ma //waypoints = FindObjectsOfType<TempScripts>(); //mainWaypoint = Vector3.zero; //max_bounds = GameObject.FindGameObjectWithTag("Robot_MaxArea").GetComponent<BoxCollider2D>(); max_bounds = UsefulFunctions.GetNearbyRobotMaxAreaWithBoxCollider(parent_object.transform.position, robot_local_sprite_size).GetComponent <BoxCollider2D>(); //get the home base that is in the game scene home_base = GameObject.FindGameObjectWithTag("Base"); }