if Input.is_action_just_pressed("ui_focus_next"):

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

Can’t get to resolve the issue Unexpected token: if: as an error.

if Input.is_action_just_pressed(“ui_focus_next”):
print(“Creating a fireball”)
var fireball = FIREBALL.instance()

It looks like you haven’t included enough information to diagnose the error. What comes before the if? Can you format your code properly, so that it’s apparent whether the indentation is correct?

kidscancode | 2019-10-27 04:44

extends Actor

const FIREBALL = preload(“res://Buttons/game/Fireball.tscn”)

export var stomp_impulse = 2000.0

func _on_EnemyDetector_area_entered(area: Area2D) → void:
_velocity = calculate_stomp_velocity(_velocity, stomp_impulse)

func _on_EnemyDetector_body_entered(body: PhysicsBody2D) → void:

func _physics_process(delta: float) → void:
var is_jump_interrupted: = Input.is_action_just_released(“jump”) and _velocity.y < 0.0
var direction: = get_direction()
_velocity = calculate_move_velocity(_velocity, direction, speed, is_jump_interrupted)
_velocity = move_and_slide(_velocity, FLOOR_NORMAL)

func get_direction() → Vector2:
return Vector2(
Input.get_action_strength(“move_right”) - Input.get_action_strength(“move_left”),
-1.0 if Input.is_action_just_pressed(“jump”) and is_on_floor() else 0.0

if Input.is_action_just_pressed(“ui_focus_next”):
print(“Creating a fireball”)
var fireball = FIREBALL.instance()

func calculate_move_velocity(
linear_velocity: Vector2,
direction: Vector2,
speed: Vector2,
is_jump_interrupted: bool
) → Vector2:
var out: = linear_velocity
out.x = speed.x * direction.x
out.y += gravity * get_physics_process_delta_time()
if direction.y == -1.0:
out.y = speed.y * direction.y
if is_jump_interrupted:
out.y = 0.0
return out

func calculate_stomp_velocity(linear_velocity: Vector2, impulse: float) → Vector2:
var out: = linear_velocity
out.y = -impulse
return out

func _on_EnemyDetector_body_shape_entered(body_id: int, body: PhysicsBody2D, body_shape: int, area_shape: int) → void:

WhatAmIDoingHere | 2019-10-27 04:55

:bust_in_silhouette: Reply From: kidscancode

Your code still isn’t formatted correctly. There’s a button to format code when you edit your post. It looks like {}.

However, I can see I think that your if statement is not indented at all. It must be inside a function to parse correctly.