Addons documentation
  • ๐Ÿ˜„Getting Started
  • ๐ŸงฉComponents
    • ๐Ÿ‘ŸGodot Essentials Motion Component
      • ๐ŸคธTop-Down Movement Component
      • ๐ŸคพPlatform Movement Component
      • ๐Ÿ”ฒGrid Movement Component
    • ๐Ÿ’“Health Component
    • ๐ŸŽฅShake Camera Component
    • ๐ŸŒช๏ธRotator Component
    • ๐Ÿš€Projectile component
    • ๐Ÿ”Finite State Machine
  • โณAutoload
    • ๐ŸŽ’Helpers
    • ๐ŸŽงAudioManager
    • ๐ŸŽฌScene Transicioner
    • โš™๏ธEnvironment variables
    • ๐Ÿ†Achievements
  • ๐ŸŽฎExamples
    • ๐Ÿง—โ€โ™‚๏ธAlys - Precision platformer
Powered by GitBook
On this page
  • Normalize vector
  • Normalize diagonal vector
  • Is diagonal direction
  • Generate random direction
  • Generate random angle
  • Generate random directions from an origin Vector2
  • Frame Freeze
  • Generate random string
  • Validate an url
  • Signals
  1. Autoload

Helpers

This plugin provides a global singleton named Helpers to contain all the stuff that can be shared globally and can be useful in your game.

Normalize vector

Normalize the vector only if it's not normalized. Returns the vector

GodotEssentialsHelpers.normalize_vector(Vector2(30, -40))

Normalize diagonal vector

A diagonal vector requires additional treatment, which can be applied using this function.

GodotEssentialsHelpers.normalize_diagonal_vector(Vector2(-0.7444, 0.7444))

Is diagonal direction

Performs a basic check and returns whether the direction passed as a parameter is diagonal. This function is used internally by the normalize_diagonal_vector function.

GodotEssentialsHelpers.is_diagonal_direction(Vector2(1, -1))

Generate random direction

Simple random Vector2 direction generator, use this function if you need a random direction in some behaviour of your game. The result is normalized

look_at(self.global_position + GodotEssentialsHelpers.generate_random_direction())

Generate random angle

Generate a random angle between a range provided, the unit is on degrees

# Between 90ยบ and 120ยบ
GodotEssentialsHelpers.generate_random_angle(90, 120) # 117ยบ

Generate random directions from an origin Vector2

This function generate a n random directions in a Array[Vector2] format from an starting vector point defining the min and max angles:

# 5 Random directions from Vector down (0, 1) between 90ยบ and 180ยบ
GodotEssentialsHelpers.generate_random_directions_on_angle_range(Vector2.DOWN, 90, 180, 5)

# 25 random directions from the actual player global position between 0 and 360ยบ
GodotEssentialsHelpers.generate_random_directions_on_angle_range(player.global_position, 0, 360, 25)

To achieve a slow-motion effect you can use this function that receives the time scale (as time goes by frame by frame) and the duration of the freeze in seconds.

# Time scale 0.05
# Duration 0.5 sec
GodotEssentialsHelpers.frame_freeze(0.05, 0.5)

Here you can see an example that trigger a frame freeze when a character jumps:

func handle_jump():
	if Input.is_action_just_pressed("jump"):
		velocity_component_2d.jump()
		GodotEssentialsHelpers.frame_freeze(0.05, 1)

Generate random string

You can use this function to generate a random string with a specified length and character list, which is set to its default value of "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

For instance, you can utilize this function to create invitation codes for your multiplayer rooms:

var invitation_code: String = GodotEssentialsHelpers.generate_random_string(4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") # YMZ2

Validate an url

As the String class from Godot lack this validation you can use the following one:

GodotEssentialsHelpers.is_valid_url("https://example.com") # true

Signals

frame_freezed signal is emitted when the effect starts in case you want to listen to it to perform other actions such as triggering animations.

Here you can see a basic example:

func _ready():
	GodotEssentialsHelpers.frame_freezed.connect(on_frame_freezed)

func on_frame_freezed():
	animated_sprite.play("juicy_hurt")
	 ...

PreviousFinite State MachineNextAudioManager

Last updated 1 year ago

Frame Freeze

โณ
๐ŸŽ’
๐Ÿจ
Frame freeze example 1 sec