Skip to content

PopochiuCharacter

Carenalga edited this page Feb 7, 2023 · 10 revisions

icon_character-x4

Description

Inherits from PopochiuClickable.

Any Object that can move, walk, navigate rooms, have an inventory, etc.

Inspector

When you select a PopochiuCharacter in the scene tree of a PopochiuRoom, you'll see this message. That means you won't be able to modify the PopochiuCharacter properties while in the room' scene, except for its position. This is because that node instance will be deleted during runtime to be replaces by the one used globally by Popochiu.

You'll need to open the PopochiuCharacter' scene in order to modify its properties.

character_inspector_in_room

Properties

Enumerations

  • FlipsWhen

    NONE = 0 --- The $Sprite child doesn't flips when moving.

    MOVING_RIGHT = 1 --- The $Sprite child flips (flip_h = true) when the character is moving to the right.

    MOVING_LEFT = 2 --- The $Sprite child flips (flip_h = true) when the character is moving to the left.

  • Looking

    UP = 0 --- Indicates the character is looking up.

    UP_RIGHT = 0 --- Indicates the character is looking up and right.

    RIGHT = 0 --- Indicates the character is looking to the right.

    RIGHT_DOWN = 0 --- Indicates the character is looking down and right.

    DOWN = 0 --- Indicates the character is looking down.

    DOWN_LEFT = 0 --- Indicates the character is looking down and left.

    LEFT = 0 --- Indicates the character is looking to the left.

    UP_LEFT = 0 --- Indicates the character is looking up and left.

Signals

  • started_walk_to( PopochiuCharacter character, Vector2 start, Vector2 end ). Emitted when the character starts walking. As parameter it sends itself, the starting position and the ending position. PopochiuRooms connect to this signal in order to make a character move inside the room from start to end.
  • stoped_walk. Emitted when the character stops walking.

Export

  • can_move bool. Default true. Whether the character can or not move.
  • flips_when FlipsWhen. Default FlipsWhen.NONE. When using the $Sprite child to render the character, it will flip horizontally when this node moves to the left if the property is equal to FlipsWhen.LEFT, it will flip when moving to the right if it is equal to FlipsWhen.RIGHT. Set the value of this property to FlipsWhen.NONE if you remove the $Sprite child in order to use another node to render the character.
  • follow_player bool. Default false. Whether the character should follor the player-controlled character when it moves through the room.
  • ignore_walkable_areas bool. Default false. Whether the character ignores or not walkable areas. If true, the character will move to any point where players click without taking into account walkable areas.
  • is_player bool. Default false. Whether the character is the one controller by the player.
  • text_color Color. Default Color.white. The color in which the dialogue lines of the character are rendered.
  • voices Array. Default []. Array of Dictionary where each element has { emotion = '', cue = '', variations = 0 }. You can use it to define rules for playing audio cues when a character speaks with a specific emotion. Check this video for an example.
  • walk_speed float. Default 200.0. The speed at which the character will move. It is pixels per frame.

Public

  • emotion String. Default ''. The current emotion used by the character.
  • is_moving bool. Default false. Whether the character is nor not moving.
  • last_room String. Default ''. Stores the script_name of the preiously visited PopochiuRoom.

Private

  • _looking_dir Looking. Default Looking.DOWN. Used to know the direction the character is looking to.

Methods

Virtual

🍑 For a detailed and exemplified description of all the virtual methods of this class (included those inherited from PopochiuClickable), go to the Your scripts > Character page.

  • play_grab() void

    Use it to play the grab animation of the character.

  • play_idle() void

    Use it to play the idle animation of the character.

  • play_talk() void

    Use it to play the talk animation of the character.

  • play_walk( Vector2 target_pos ) void

    Use it to play the walk animation of the character.

Public

  • face_clicked( bool is_in_queue = true ) void

    Makes the character face left or right depending on the direction of the clicked PopochiuClickable stored in E.clicked. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • face_left( bool is_in_queue = true ) void

    Sets _looking_dir = Looking.LEFT and yields until idle() is completed. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • face_right( bool is_in_queue = true ) void

    Sets _looking_dir = Looking.RIGHT and yields until idle() is completed. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • face_up( bool is_in_queue = true ) void

    Sets _looking_dir = Looking.UP and yields until idle() is completed. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • face_up_right( bool is_in_queue = true ) void

    Sets _looking_dir = Looking.UP_RIGHT and yields until idle() is completed. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • face_down( bool is_in_queue = true ) void

    Sets _looking_dir = Looking.DOWN and yields until idle() is completed. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • grab( bool is_in_queue = true ) void

    Calls play_grab and yields until the character_grab_done signal is emitted, then plays the idle animation. When running inside a cutscene (E.run_cutscene()), ignores the mentioned behavior if the cutscene is skipped. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • hide_helpers() void

    Used by the plugin to hide the visual helpers that show the baseline and walk_to_point of the object in Godot´s 2D Canvas. It also hides the $DialogPos child.

  • idle( bool is_in_queue = true ) void

    Calls playe_idle() and then yields 0.2 seconds. When running inside a cutscene ( E.run_cutscene() ), ignores calling play_idle() if the cutscene is skipped. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • say( String dialog, bool is_in_queue = true ) void

    Calls play_talk() and emits the character_spoke signal sending itself as parameter and the dialog line to show on screen. If an audio cue is defined for the emotion set in the dialogue line, then it is played by calling A.play_no_block(). When running inside a cutscene ( E.run_cutscene() ), it will ignore the previous mentioned instructions if the cutscene is skipped. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • show_helpers() void

    Used by the plugin to make visible the visual helpers that show the baseline and walk_to_point of the object in Godot´s 2D Canvas. It also shows the $DialogPos child.

  • stop_walking( bool is_in_queue = true ) void

    Makes the character stop moving and emits the stoped_walk signal, then yields until the next frame. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • walk( Vector2 target_pos, bool is_in_queue = true ) void

    Makes is_moving = true and sets the value of _looking_dir to Looking.LEFT or Looking.RIGHT depending on the movement direction calculated with target_pos. It calls play_walk(), and after emitting the started_walk_to signal, yields until the character_move_ended signal is triggered. When running inside a cutscene ( E.run_cutscene() ), ignores calling play_walk() if the cutscene is skipped, and also sets the position of the character to target_pos. If you want to use it outside E.run(), send is_in_queue as false. Can be yield.

  • walk_to( Vector2 pos ) void

    Makes the character walk to a coordinate. Meant to be used in E.run(). Can be yield.

  • walk_to_hotspot( String id ) void

    Makes the character walk to the PopochiuHotspot (in the current room) which script_name is equal to id. Meant to be used in E.run(). Can be yield.

  • walk_to_prop( String id ) void

    Makes the character walk to the PopochiuProp (in the current room) which script_name is equal to id. Meant to be used in E.run(). Can be yield.

  • walk_to_room_point( String id ) void

    Makes the character walk to a room point (Position2D) (in the current room) which name is equal to id. Meant to be used in E.run(). Can be yield.

Set and get

  • get_dialog_pos() float

    Returns the y position of the $DialogPos child. Used by the graphic interface to calculate where to show the dialogue lines of the character.

  • set_voices( Array value ) void

    Creates a Dictionary with { emotion = '', cue = '', variations = 0 } each time a new element is added to the voices Array in the Inspector. This dictionaries can be used to define the rules to play a set of audio cues depending on the emotion of each dialogue line. Check this video for an example.

Private

  • _get_vo_cue( String emotion = '' ) String

    Return the script_name of the audio cue to play when say() is called. This will take into account the number of variations defined to pick a random cue name based on that. Check this video for an example.

  • _translate() void

    Makes the description take the value returned by E.get_text() sending the description_code as parameter. This is used by the engine when translating the game in runtime.

Clone this wiki locally