(Ill use the runner example because some collision issues in my project) so if you one of the people that helped me with the teleportation thingy I need help again when Im “telporting” the X and Y change but I want only the X to change here recording:
the project is this(https://www.defold.com/tutorials/runner/)
full code for the hero: https://pastebin.com/A7ryfJ7E
and here the code:
function update(self, dt)
local gravity = vmath.vector3(0, gravity, 0)
if not self.ground_contact then
self.velocity = self.velocity + gravity
end
-- apply it to the player character
go.set_position(go.get_position() + self.velocity * dt)
update_animation(self)
-- reset volatile state
self.correction = vmath.vector3()
self.ground_contact = false
if self.teleport == true then
self.position = vmath.vector3(100, self.position.y, self.position.z)
go.set_position(self.position)
end
self.teleport = false
end
function on_input(self, action_id, action)
if action_id == hash("jump")then
jump(self)
elseif action_id == hash("teleport") then
print("teleported")
self.teleport = true
end
end