Godot says "Identifier stomp impulse is not declared in the current scope"

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

extends Actor

export var stomp_impluse: = 1000.0

func _on_EnemyDetector_area_entered(area):
_velocity = calculate_stomp_velocity(_velocity, stomp_impulse)

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, Vector2.UP)

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

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, impluse: float) → Vector2:
var out: = linear_velocity
out.y = -impulse
return out

:bust_in_silhouette: Reply From: jgodfrey

The variable you defined has a typo:

export var stomp_impluse: = 1000.0

Note that’s stomp_impluse, but should be stomp_impulse.

Thank you so much!

Parsa | 2022-07-12 20:36

Happy to help. As a point of board housekeeping, if the answer solved your problem, you should mark it as “best answer”. That way, the question will will show up in the main board with a marker that indicates that it’s resolved. That’s helpful for others that might come along later with the same problem. Questions that are shown as resolved (have a “best answer”) are likely to be the most helpful to others.

jgodfrey | 2022-07-12 20:46