0 votes

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??

in Engine by (17 points)

1 Answer

0 votes
Best answer

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
by (20,477 points)
selected by

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

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 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 webmaster@godotengine.org with your username.