Code problem when trying to zoom out???

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Denny2705

This is my code

  1. extends Camera2D
  2. func _ready():
  3. pass
  4. func _proccess():
  5. zoom Vector2 (2, 2): [this is the error line]

But it still says “Error(8,7): expected end of statement after expression”
How can i fix this??

:bust_in_silhouette: Reply From: kidscancode

This code is not valid at all. First of all, when you paste code here, you can use the formatting button (it looks like {}) to format your code properly, like this:

extends Camera2D

func _ready():
    pass

func _proccess():
    zoom Vector2(2, 2)

Make sure to format your code so others can read it. The line numbers don’t help at all. Here is what is wrong with your code as you’ve pasted it:

  1. “process” is spelled wrong.
  2. The _process function includes a parameter, delta which is the frame time. That line should read func _process(delta):
  3. If you’re trying to set the zoom property of the camera, you must assign a value to it. It’s a variable. So for example, you could say zoom = Vector2(2, 2) to make the zoom level 2x.
  4. There’s no point in putting this in _process() as that would assign 2x as the zoom every frame. Once it’s set, you’re not changing anything. You should probably put that line in _ready() or just set it in the Inspector.
  5. If you’re trying to change the zoom every frame, then you need to assign a new, larger value every frame. I’m not sure why you’d want to do that, but you could try something like this:
func _process(delta):
    if zoom.x < 10:  # set a maximum zoom level
        zoom += Vector2(1, 1) * delta  # add to the zoom every frame

Thanks! This really helped me out! Now I can continue programming

Denny2705 | 2019-02-20 23:57