Duplicate action on teleporters

When a player is using a teleporter after some kind of cutscene using straight movements, the teleport action is performed twice (attached sound also).

Requirements:

  • Create a map
  • Place a destination
  • Place a teleporter with a sprite
  • Teleporter has to got to another map

Actions to reproduce:

  • Let the "cutscene" operates
  • Move to the teleporter
  • You should hear the teleport sound twice instead of once.

Map script:

local map = ...
local hero = map:get_hero()
local camera = map:get_camera()

local function start_cutscene()
  hero:freeze()

  local camera_movement = sol.movement.create("target")
  camera_movement:set_ignore_obstacles(true)
  camera_movement:set_target(camera:get_position_to_track(teleporter))
  camera_movement:set_speed(32)
  camera_movement:start(camera, function()
    local hero_movement = sol.movement.create("straight")
    hero_movement:set_angle(math.pi / 2)
    hero_movement:set_speed(hero:get_walking_speed() / 2)
    hero_movement:set_max_distance(16)
    hero_movement:start(hero, function()
      hero:unfreeze()
    end)
  end)
end

---This is called twice
function teleporter:on_activated()
  print("warp")
end

function map:on_opening_transition_finished()
  start_cutscene()
end
Edited by Metallizer