This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm building a camera for my game

extends Camera

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

export var center_offset : (0, 5.0)
export(float, 0.1, 1.0) var move_speed : float = 0.5
export(float, 0.1, 0.4) var smoothing : float = 0.3

var initial_distance : = 0.0
var initial proportion : = 0.0
var viewport_rect : Rect2

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
    viewport_rect = get_viewport().getvisibleRect()
    set_process(get_child_count() > 0)
    for child in get_children():
    # pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta : float) -> void:
    translation = calculate_position(calculate_targets_rect(), calculate_unprojected_rect())

#   pass
func calculate_unprojected_rect() -> Rect2:
    var rect : = Rect2(unproject_position (get_child(0).translation), Vector
for index in get_child_count():
    if index == 0:
        rect = rect.expand(unproject_position (get_child(index).translation)
        return rect

func calculate_targets_rect() -> Rect2:
    var rect : = Rect2(vec3_to_vec2 (get_child(0).translation), Vector
for index in get_child_count():
    if index == 0:
        rect = rect.expand(vec3_to_vec2(get_child(index).translation)
        return rect

        func vec3_to_vec2(vector: Vector3)-> Vector2
        return  Vector2(vector.x, vector.y)

        func calculate_center(rect: Rect2) -> Vector2:

            return Vector2(rect.position.xsrect.position.y + rect.position.y + rect.size.y / 2)

            func calculate_position(rect: Rect2, unprojected_rect: Rect2) -> Vector2
            var center := calculate_center(rect)

            if initial_proportion == 0 or initial_distannce == 0
            initial_proportion = unpojected_rect.size.x / viewport_rect.size.x
            initial_distnace  = translation.distance_to(get_child(0).translation)

            var z_position : = translation.z
             if unprojected_rect.size.x / viewport_rect.size.x : > initial_proportion
            z_position = translation.z + move_speed

            elif unprojected_rect.size.x / viewport_rect.size.x : < initial_proportion and z_position > initial_distance:
            z_position = translation.z - move_speed
            return(center.x, center_offset.x, center.y, center_offset.y, lerp(translation.z, z_position.smoothing))

Yet i keep getting errors on this line

export var center_offset : (0, 5.0)

Expected a type for this variable

Why is this error keep showing up?

Godot version Godot 3.4
in Engine by (104 points)

1 Answer

0 votes

I think the line has to be one of these:
1. export var center_offset : Vector2 = (0, 5.0)
2.export var center_offset := Vector2(0, 5.0)

The problem is that you don't assign a value to the variable (= is missing).

I hope I was able to help.

by (226 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.