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 » Scripting Helpers
Home Search
 

Re: making p1 slowly look at p2

Previous Thread :: Next Thread 
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Sep 2012 11:46 AM
I'm trying to get p1 to slowly look at p2, so the final frame should be:

p1.CFrame = CFrame.new(p1.Position, p2.Position)

but I have only tried to do this and have no idea how I can do this. I don't want to have to use slerp to do this because I believe there is a more simple way to accomplish this. Anyone know how I can do this without the use of slerp?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
26 Sep 2012 11:48 AM
Use a BodyGyro.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
26 Sep 2012 11:49 AM
What's slerp?

You could try to use a BodyGyro with a high dampening
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Sep 2012 11:49 AM
Er, the code I had posted was an example, not the real scenario. I'm doing this with the camera's CoordinateFrame.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
26 Sep 2012 12:05 PM
I think you would need a loop and some maths to make it slowly turn towards a position with CFrame.

IMO, you should make the script add an invisible part inside the camera, along with a BodyGyro inside that set to face the position. Then all you would have to do is

game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.Part.CFrame

Report Abuse
SolarCrane is not online. SolarCrane
Forum Moderator
Joined: 03 Jul 2012
Total Posts: 116
26 Sep 2012 12:06 PM
BodyGyros are a great way to do rotations, by letting the engine take care of it it will look better. Although if you can't use a body gyro for one reason or another and slerp is too complicated then the use of nlerp can be a close substitute. It is extremely simple and works almost the same as slerp.

I haven't tested this code but something like this should work:

function Nlerp(start, finish, percent)
return start:Lerp(finish,percent).unit
end
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Sep 2012 12:08 PM
"IMO, you should make the script add an invisible part inside the camera, along with a BodyGyro inside that set to face the position. Then all you would have to do is"

No, don't want to do that.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
26 Sep 2012 12:08 PM
What is this lerp everyone but me seems to know about ._.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
26 Sep 2012 12:21 PM
http://wiki.roblox.com/index.php/Vector3

Look at :Lerp.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
26 Sep 2012 12:22 PM
Its interpolation.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Sep 2012 12:24 PM
"Look at :Lerp."

you.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Sep 2012 06:38 PM
bump
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
26 Sep 2012 07:31 PM
Use interpolation with a scaled function as the input:

for t: 0->1
CFrame = Interpolate(CFrame.new(at, from), CFrame.new(at, to), (t-1)^3+1)

You can steal the interpolation code from my Wiki page.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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