Hi! I am now to godot and coding. I am trying to make grame similiar to icy tower to learn, and I stumbled across and Issue I have hard time solving. I want to make a camera that starts moving when player starts moving. I don’t know how to make this happen, since while loop is not working, and I don’t know why. I probably do it all wrong so I would appreciate all helpfull tips ^^ I
type or paste code here extends
Camera2D
var camera_velocity = -0.5
var camera_trigger = true
func _ready():
pass
# It should start working from begining of the game since it's already true but it doesn't :(
func _process(delta):
while(camera_trigger == true):
offset.y += camera_velocity
#this is how I wanted to trigger it later
func camera(delta):
#if Input.is_action_just_pressed("ui_accept"):
#_process(delta)
Oh! I see, thank you but I don’t think this will solve my issue I already tried this method and this is not what I was looking for. My idea is that the camera move itself in a constant way, and the player have to keep up with it. Additionally, the camera should start moving only when the player first start moving.
Basically, all function can return some value.
Useful to name some verifications or other.
Simple example:
func _possible_jump(): return on_ground and not paralize
# Here function return a complexe bool
# which was ugly to put directly after the future "if"
# Later in your code...
if _possible_jump(): _jump
Also, return end the function. So if you just want stop reading the rest of the code use return with no value after.
Here, you just cancel reading of the rest of the function if camera_trigger bool is not true ^^