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: Facing a part towards another.

Previous Thread :: Next Thread 
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 11:35 AM
Note:
I can not use p.CFrame = CFrame.new(p.CFrame.p, p2.CFrame.p);
as I just want it to be a rotate in a general direction and gradual rather than instant.

Here's what I've:
local rotation = function(p1, p2)
local dir = (p2.Position-p1.Position).unit;
p1.CFrame = p1.CFrame * CFrame.fromAxisAngle(dir, math.rad(30))
end;

It works if the object is directly in front of the model, however if it's not, it will rotate in essentially the opposite direction.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 11:37 AM
um its called lerp

obj.CFrame = obj.CFrame:lerp(CFrame.new(obj.CFrame.p,part.CFrame.p),0.1)

or you can use a Body Gyro

and to make it rotate in the opposite direction, multiply by rad(180) Y angles
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 11:40 AM
I wasn't aware lerp even existed as a method, I'll try it\.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 11:48 AM
Nope, faces the same problem as my previous methods.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 11:49 AM
obj.CFrame = obj.CFrame:lerp(CFrame.new(obj.CFrame.p,part.CFrame.p)*CFrame.Angles(0,math.rad(180),0),0.02)
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 11:49 AM
declare obj and part as variables instead of replacing them
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 11:54 AM
model:SetPrimaryPartCFrame(thruster.CFrame:lerp(CFrame.new(thruster.CFrame.p, goal.p) * CFrame.Angles(0, math.rad(180), 0), 0.3));

Result: Still facing the wrong dir.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 11:55 AM
then remove the angles :/
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 12:00 PM
The thing is the first iteration I used when I said it didn't work, did infact not use CFrame.Angles. I'll probably have to manualy calculate the distance.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:01 PM
dude it works correctly, you just do it horribly
it will lerp the cframe of the part to the cframe of it pointing to another object
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:01 PM
you want to use GetPrimaryPartCFrame most likely anyways
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 12:08 PM
"dude it works correctly, you just do it horribly
it will lerp the cframe of the part to the cframe of it pointing to another object"
So since your solution didn't work you attack me.. Classy. How am I doing it horribly when it is literally the code you gave, modified for my situation? If I was doing it horribly then so were you boyo.

"you want to use GetPrimaryPartCFrame most likely anyways"
Thruster is the primary part so it makes no empirical difference.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:11 PM
it works, the problem is that you dont know how to use it you idiot

watch this gif to see how you are helpless

goo.gl/OJ3jEm
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:14 PM
while wait() do
script.Parent.CFrame = script.Parent.CFrame:lerp(CFrame.new(script.Parent.CFrame.p,workspace.e.CFrame.p),0.1)
end

is the code i used
so its not my problem
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 12:18 PM
I understand that it works for small parts which is why I said "within the context that I am using it". And if I am using it wrong then how about showing what I did wrong then? I am willing to learn if you think I did it wrong then show.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:19 PM
model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame():lerp(CFrame.new(model:GetPrimaryPartCFrame().p, goal.p), 0.2))


and set goal as the part every time
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 12:32 PM
#############################################################################################################
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 12:33 PM
I tried it and the method isn't working for this. I will try to manually calculate the angle I guess.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:34 PM
that is because goal needs to be the cframe of the other object at all times
if you are not setting it to that cframe, things will go wrong
Report Abuse
ScripterJohn13 is not online. ScripterJohn13
Joined: 01 Jan 2010
Total Posts: 5658
11 Sep 2016 12:37 PM
@ daily just ignore him and let this thread die... he obviously isn't wanting a quality answer... this fool thinks you should spoon feed him the EXACT answer.. he isn't willing to go the extra mile.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:38 PM
lol the gif even works correctly idk what this dude is doing wrong
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
11 Sep 2016 12:41 PM
I am not asking for a spoonfed answer it's just that when I use the method for the model, it works the same way my .unit rotation solution worked. I can get both solutions to work for small parts but this isn't working at all for the model I am using.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
11 Sep 2016 12:42 PM
then make sure that goal is always what you want to point to
goal = thing.CFrame

other than that idk what you did wrong
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
11 Sep 2016 12:44 PM
The problem is probably that it is rotating the model correctly but what you think the "front" of the PrimaryPart is probably actually a different size.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
11 Sep 2016 12:44 PM
different side*
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