Jump to content

interpolateBetween not working!


Recommended Posts

local x, y, z = 134.52067565918, -69.88720703125, 2.4778761863708
local marker = createMarker (x, y, z)

addEventHandler ("onClientRender", root, function()
    x, y, z = interpolateBetween (x, y, z, x, y, z + 3, 0, "Linear")
    setElementPosition (marker, x, y, z)
end)

Hi i'd like to move a marker from my position, to up, but the script is not working at all. It is not giving any error but the marker is not moving.

Edited by tommymaster
Link to comment

For it to work you need to increase the progress argument from 0-1 over time like this

local x, y, z = 134.52067565918, -69.88720703125, 2.4778761863708
local marker = createMarker (x, y, z)

local start = getTickCount(  )
local length = 3000 -- 3 seconds

addEventHandler ("onClientRender", root, function()
    local progress = (getTickCount(  )-start)/length
    local x, y, z = interpolateBetween (x, y, z, x, y, z + 3, progress, "Linear")
    setElementPosition (marker, x, y, z)
end)

 

  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...