#Gobot's Adventures

1 messages · Page 1 of 1 (latest)

celest grail
#

Great job! The addition of the camera shake is a really nice touch.

silent dragon
untold gyro
#

The camera shake when taking damage looks really cool. How did u add that in, are u pausing and unpausing the game or adjusting the camera positioning or something else?

silent dragon
# untold gyro The camera shake when taking damage looks really cool. How did u add that in, ar...

Oh! It's really easy. I basically do it like this:

extends Camera2D

@export var max_shake_intensity: float = 25.0

@onready var shake_timer: Timer = %ShakeTimer


func _ready() -> void:
    set_process(false)

    shake_timer.timeout.connect(set_process.bind(false))


func _process(_delta: float) -> void:
    var shake := Vector2(
        randf_range(-max_shake_intensity, max_shake_intensity),
        randf_range(-max_shake_intensity, max_shake_intensity)
    )

    var timer_progress := 1.0 - shake_timer.time_left / shake_timer.wait_time

    offset = lerp(shake, Vector2.ZERO, timer_progress)


func _shake_camera() -> void:
    shake_timer.start()
    set_process(true)

The shake_timer's One Shot property should be on

untold gyro
#

This is a cool way of doing it. I was searching this up and came across the term "hit stop". It seemed a bit complicated.

From what I see here, the main feature is:

  • offsetting the camera between a random range limited by the max_shake_intensity
  • subtract the ratio of time_left and wait_time from 1 to progress the offset from the random shake vectors to zero
  • setting the process to false on timer timeout signal

But, where are you calling _shake_camera as it is a declared a private method? I guessing, you call it when the player takes damage.

distant nebula
#

the mobs shouldnt be getting blocked by the barriers otherwise they just keep getting stuck everywhere, same bullets shouldnt be disappearing when hitting the barrier it looks weird