extends "res://scripts/OverworldEntity.gd" var interactRange = 0.7; func updateOverworldLogic(delta) -> void: # Check if interact button is pressed if(Input.is_action_just_pressed("interact")): var rayDirection = getDirectionVector(); # cast ray var query = PhysicsRayQueryParameters3D.create( position, position + (rayDirection * interactRange) ) query.collide_with_areas = true query.exclude = [self] var result = get_world_3d().direct_space_state.intersect_ray(query) if result and result.collider: var collider = result.collider if(collider.has_method("interact")): collider.interact(self) func updateMovement(delta) -> void: # User movement var dir:Vector2 = Input.get_vector("left", "right", "up", "down"); if(dir.x != 0 or dir.y != 0): velocity.x = dir.x * speed * delta; velocity.z = dir.y * speed * delta; # Update direction if(dir.x > 0): if( dir.y == 0 or (dir.y < 0 and direction == Direction.SOUTH) or (dir.y > 0 and direction == Direction.NORTH) ): direction = Direction.EAST; elif (dir.x < 0): if( dir.y == 0 or (dir.y < 0 and direction == Direction.SOUTH) or (dir.y > 0 and direction == Direction.NORTH) ): direction = Direction.WEST; elif (dir.y > 0): direction = Direction.SOUTH; elif (dir.y < 0): direction = Direction.NORTH; pass