generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Interpolating at a consistent rate?

Previous Thread :: Next Thread 
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 07:14 AM
How can I interpolate a Part between a Table of different Positions at a consistent rate?
Each point is of varying distance from one another.
Basically, I want the Part to travel at the same speed from pointA, to pointB, to pointC, and so on.

Any help or advise would be greatly appreciated.
Report Abuse
Naco88 is online. Naco88
Joined: 30 Oct 2009
Total Posts: 665
28 Feb 2016 07:24 AM
You could use Body Gyro and Body velocity to make it move and then work out the position and wait until it equals the one you set.

Here is a lift model I change to give something movement which you could use too:

http://www.roblox.com/item.aspx?id=373935996

I hope this helps! :D
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
28 Feb 2016 07:36 AM
Have a rate in mind, studs per second; it could be 10 or 15/4 (15 per 4 seconds)
Get the distance between the 2 points:

(VecA - VecB).magnitude -- I would use Vector3s even if it's cframe, just to get the raw distance between.

-- Time = (Distance / Velocity)
Time = ((VecA - VecB).magnitude / 10)

Now interpolate with that time.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
28 Feb 2016 07:38 AM
So to get the distance if you are working with CFrames:

(CfA.p - CfB.p).magnitude -- I assume you wouldn't care about rotation.
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 08:26 AM
@Darkmist101

Thanks, but what are you suggesting I place in the script.
I understand where you're coming from, I'm just a little lost.

(VecA - VecB).magnitude

--Shouldn't this be a variable of some kind? Is it supposed to be in the actual code?

Time = ((VecA - VecB).magnitude / 10)
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 09:08 AM
I understand what you mean now.
Why won't this work for me though?

for i = 1, #Positions, 1 do
VecA = script.Parent.Position
VecB = Positions[i]
Time = ((VecA - VecB).magnitude / 10)
script.Parent.Position:Lerp(Positions[i], Time)
print("done")
wait()
end

It prints "done" numerous times but the Part never moves.
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 09:14 AM
Any ideas?

Any help or advise would be greatly appreciated.
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 09:26 AM
Can anybody help with this?
Report Abuse
Gensoki is not online. Gensoki
Joined: 15 Feb 2014
Total Posts: 1982
28 Feb 2016 10:19 AM
Lerp doesn't use time
CFrame:lerp(CFrame goal, number alpha) returns a CFrame interpolated between this CFrame and the goal by the fraction alpha


#code "Oh, did I die again?"
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 11:09 AM
Would BodyMovers give a smoother, more accurate effect?
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
28 Feb 2016 11:30 AM
Any ideas?
Report Abuse
Lineout is not online. Lineout
Joined: 06 Nov 2012
Total Posts: 684
28 Feb 2016 11:33 AM
I'm also interested so free bump.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
28 Feb 2016 12:05 PM
I just modified what I usually use in my projects.
If I want linear speed I usually do that before I call the function, might change that.
Don't know if I didn't break it.

function _G.Interpolate(Object, EndPos)

local StartPos = Object.Position
local Seconds = ((StartPos - EndPos).magntiude / 10)
local Time = 0

-- Start interpolation
while Time < Seconds do
Time = (Time + wait()) -- Delta
Object.Position = StartPos:lerp(EndPos, (Time / Seconds))
end

Object.Position = EndPos -- Finish
end
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Mar 2016 08:36 AM
Thanks for the advise.

However, I've tried a few different interpolating methods now and each is very "jumpy", if you know what I mean. The Part doesn't interpolate smoothly.

Is there any way this can be done smoothly?
Could BodyMovers accomplish this?
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Mar 2016 08:47 AM
Any ideas?

I'd really appreciate any help or advise.
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Mar 2016 01:36 PM
Any help or advise?

I'd really appreciate it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image