// gets the input and generates a direction for moveEngine.move void movementController() { Vector2 direction = Vector2.zero; // the direction of the movement Vector2 keyboard_direction; // the direction given by the keyboard Vector2 position = new Vector2(transform.position.x, transform.position.y); // MOUSE if (Input.GetMouseButtonDown(0)) // left click { // TODO : Need to check if anyone is under the mouse, you don't want to keep walking into people eternally chase_mouse = chase_mouse == false; mouse_position = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y); } if (chase_mouse) { direction = mouse_position - position; // if we are close enough we stop if (direction.magnitude < distance_stop) { chase_mouse = false; } } // KEYBOARD keyboard_direction = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); // the keyboard is prioritary if (keyboard_direction.magnitude > 0) { direction = keyboard_direction; chase_mouse = false; } // MOVE moveEngine.move(direction); }
public void switch_corpse(Character other) { if (is_young_enough() && !has_dialogue) { MoveEngine other_move_engine = other.GetComponent <MoveEngine>(); InputManager other_input_manager = other.GetComponent <InputManager>(); Collider2D other_collider = other.GetComponent <Collider2D>(); other.is_player = false; other_move_engine.move(Vector2.zero); other_move_engine.can_move = false; other_input_manager.chase_mouse = false; other_collider.isTrigger = true; moveEngine.move(Vector2.zero); moveEngine.can_move = false; // TODO : launch animation GameObject spirit_orb = Instantiate(spirit) as GameObject; spirit_orb.GetComponent <SpiritTravel>().initialize(other.transform.position, transform.position, animation_time); // SoundEffects.Play("possession"); Invoke("set_active_player", animation_time); } }