I followed an youtube video for making a 2D game.
The video
The problem is that whenever i change the value of the variable gravity godot does not run the code with the new variable.At first i thought it was due to "export" but even after removing them the same problem occurs.I had to write the entire code just to change a data.It worked once but after changing the variable gravity again Godot is not reading the new variable.
The codes after removing "Export"
Actor.gd
extends KinematicBody2D
class_name Actor
var speed:=Vector2(300.0,1000.0)
var gravity:=500.0
var velocity:=Vector2.ZERO
func _physics_process(delta: float) -> void:
velocity.y+=gravity*delta
velocity= move_and_slide(velocity)
Player.gd
extends Actor
func _physics_process(delta: float) -> void:
var direction:=Vector2(Input.get_action_strength("move_right")
-Input.get_action_strength("move_left"),
-1.0 if Input.is_action_just_pressed("jump") else 1.0)
velocity=speed*direction
Why this happens?And how can i fix it?