Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hi, sorry to bother you, just wondering if you could please explain or even upload the camera code? I'm attempting a similar camera style for a visual novel and the severe lack of online documentation is rough. Anything helps, cheers!

I know this is late and you probably have found a solution that works for you, but if not here is only the relevant part of the camera movement which is contained in the player script:

var viewport : Viewport
var viewport_center : Vector2
var target_direction : Vector2
onready var camera := get_node("Offset/Camera")
func _ready():
     viewport = get_viewport()
     viewport_center = viewport.get_visible_rect().size/2
func _process(delta):
    # get direction from center of the screen to current mouse position
    var direction = viewport.get_mouse_position() - viewport_center
    # remap value range to 0-1
    direction = direction/viewport.get_visible_rect().size.x
    # lerp to add delay and bounds to camera movement
    target_direction = lerp(target_direction, Vector2(direction.x, clamp(direction.y, -1, 0)), delta*10)
    # movement inversions transfrom in local space
    camera.transform.origin.x = target_direction.x
    camera.transform.origin.y = -target_direction.y

You basically take the center point of the screen and lerp the camera position to current mouse position with a clamp that defines your bounds. The relative camera position must be at (0,0,0) for it to work.

Hope that helps,

Cyanine

Very nice technique! Thank you very much!