Attempt to call function 'play' in base 'null instance' on a null instance.
Idk why it cause this :V
Code:
var SxPSy = scale.x + scale.y
var Speed = SxPSy + 200
var JumpVel = SxPSy * -200
@onready var Anim = $AnimationPlayer
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") * SxPSy
func _physics_process(delta):
SxPSy = scale.x + scale.y
scale.x = Global.PSX
scale.y = Global.PSY
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
# Handle jump.
if IIAP("up") and is_on_floor():
velocity.y = JumpVel
if Global.ResizeMachine == 1:
if Input.is_action_just_pressed("resize_x"):
if Global.PSX > 0.5:
Global.PSX -= 0.1
Global.Coins += ((0.1 - Global.MinSize) + (0.1 - Global.MinSize)) * 10
print(Global.Coins)
if Input.is_action_just_pressed("resize_y"):
if Global.PSY > 0.5:
Global.PSY -= 0.1
Global.Coins += ((0.1 - Global.MinSize) + (0.1 - Global.MinSize)) * 10
print(Global.Coins)
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("left", "right")
if direction:
velocity.x = direction * Speed
else:
velocity.x = move_toward(velocity.x, 0, Speed)
Anim.play("Idle_Right")
JumpVel = SxPSy * -200
gravity = ProjectSettings.get_setting("physics/2d/default_gravity") + (SxPSy + 100)
Speed = SxPSy + 300
move_and_slide()
func _on_teleport_portal_body_entered(body):
get_tree().change_scene_to_file("res://Levels/BattleArea.tscn")
func IIAP(key):
return Input.is_action_pressed(key)
func _on_area_2d_body_entered(body):
position = Vector2(-447, 332)```