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: CFrame:lerp help

Previous Thread :: Next Thread 
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 01:13 PM
I was told to use :lerp to make the part move smoothly to position from player.Character.RightHand.Position. I read the wiki, and it doesn't explain it too much.
Besides goal and alpha, which what is alpha really? The goal is where it needs to go, right?

Here is my code:
local RE = script.Parent:WaitForChild("RemoteEvent")
enabled = false

RE.OnServerEvent:connect(function(player, request, ray, hit, position)
enabled = true
if request == 'fireball' then

local ball = Instance.new("Part", workspace)
ball.Name = "Fireball"
ball.Anchored = false
ball.CanCollide = true
--- Shape (Hashtagged)
--- Transparency (Hashtagged)
local fire = Instance.new("Fire", ball)
fire.Size = 2.5

ball.CFrame = CFrame.new(position)
wait(0.5)
game:GetService("Debris"):AddItem(ball, 0.5)

end
end)


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 01:28 PM
bump


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 01:44 PM
bump


ATR'er since 2013.
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
23 Feb 2017 02:40 PM
alpha is basically the progression from the start to end.
0 is the beginning 0.5 is the middle 1 is the end.

print(CFrame.new():lerp(CFrame.new(5,5,5),0.5))

you should use a loop to gradually go from 0 to 1

for i=0,1,0.1 do
print(CFrame.new():lerp(CFrame.new(5,5,5),i))
end


Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 03:26 PM
like this?
for i = 0,1,0.1 do
ball.CFrame = CFrame.new():lerp(CFrame.new(position),i)
end


ATR'er since 2013.
Report Abuse
devHoodie is online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
23 Feb 2017 03:27 PM
for i = 0,1,0.1 do ########### ######################################### wait() end -- Former AKA : luis15232
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 03:28 PM
filter :/

Post it to pastebin then give me the pastebin id?


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 03:33 PM
for i = 0,1,0.1 do
ball.CFrame = CFrame.new():lerp(CFrame.new(position),i)
end
That is what I have but it doesn't flow from the players hand to the position :/


ATR'er since 2013.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 03:57 PM
bump


ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 04:00 PM
--Use lerp like this
local from,to,alpha --"from" and "to" are self explainatory.
for alpha=0,1,.1 do
wait(0)
part.CFrame=from:lerp(to,alpha)
end


Thy = T H E, gotta avoid hashtagnese.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 04:06 PM
my goal is to get the part to move smoothly, will lerp() do that? I was told it would, and if so how would I get the object to go from the players hand to where they clicked? (position)


ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 04:08 PM
Yeah, lerp is pretty smooth... ish.
Anyway, just replace my "from" var to the current CFrame, the "to" var to the destination CFrame, and the "part" var to the object


Thy = T H E, gotta avoid hashtagnese.
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
23 Feb 2017 04:23 PM
Me using CFrame.new() was just an example sorry


Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 04:30 PM
Here is my code:
local to = position
local from = char.RightHand.CFrame.p
local part

for i = 0,1,0.1 do
wait()
ball.CFrame = from:lerp(to, i)
end

Got this error:
17:28:49.982 - Players.Player1.Backpack.Tool.Reciever:20: bad argument #3 to 'CFrame' (CFrame expected, got Vector3)

for this line:
ball.CFrame = from:lerp(to, i)


ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 04:31 PM
.p gets ### position of a CFrame (a Vector3) Remove it from "local from = char.RightHand.CFrame.p" Thy = T # E, gotta avoid hashtagnese.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 04:31 PM
Robloxples.
.p gets the position of a CFrame (a Vector3)
Remove it from "local from = char.RightHand.CFrame.p"


Thy = T H E, gotta avoid hashtagnese.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 04:44 PM
still getting the error


ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 05:08 PM
Then you are doing something very wrong. Read again and keep trying. Thy = T # E, gotta avoid hashtagnese.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 05:22 PM
I'm using the code you gave me..... ^ local to = position local from = char.RightHand.Position local part = ## for alpha = 0,1,0.1 do wait(0) part.CFrame = from:lerp(to, alpha) end ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 05:24 PM
Maybe position is ALSO a vector3?
You are trying to set a CFrame, you can't directly tell RLua to make a CFrame out of a Vector3.


Thy = T H E, gotta avoid hashtagnese.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 05:30 PM
oh yeah, position is a Vector3 :P

How would I do this then? Because position is the ray position/ mouse position and that's where I need it to move to.


ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 05:31 PM
CFrame.new(position) should do the trick.


Thy = T H E, gotta avoid hashtagnese.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 05:33 PM
that doesn't make it go smoothly like gun bull3ts it though :(


ATR'er since 2013.
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
23 Feb 2017 05:35 PM
Then you did something wrong. [2]
Decrease alpha or use a constant instead of lerping it directly to the target.


Thy = T H E, gotta avoid hashtagnese.
Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
23 Feb 2017 05:37 PM
oml I do better with an example of what I need done, then I learn from it. That's how I work. That's how I learned rays, and most of the other stuff I know. Can you please fix mine up? local from = char.RightHand.CFrame.p local part = ## for alpha = 0,1,0.1 do wait(0) part.CFrame = CFrame.new(position) end ATR'er since 2013.
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