|
| 03 Jul 2015 03:27 AM |
So the idea is to make a part "look" at an object while being able to rotate on a local Y axis. I'm using a BodyGyro for this. Now I know you can do the good ol' "CFrame.new(part1.Position - part2.Position)", but when you rotate on the Y axis, it is relative to the world and not the part. I've tried making two separate gyros with the maxForces set to (100000,0,100000) & (0,100000,0), but this seems to cancel each other out.
Anyone know how I can achieve this? If you still don't quite understand, imagine sticking your arm straight out pointing at something, and rolling your arm left and right. This is the effect I'm going for.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 03:50 AM |
Must be too late to be coming to the forums for answers I guess.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 03:52 AM |
| one sec im reading dun lev yet |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:01 AM |
I'll be around for a bit.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:02 AM |
Okay
Im assuming your issue is only making the brick face the brick
Try doing this
part.CFrame = CFrame.new(part.Position, ObjectPointingTo.Position)
that will make it face the brick |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:04 AM |
Woops, that's what I meant by the "good ol' CFrame.new(part1.Position - part2.Position)".
I'm trying to make the part look at an object while still being able to make it spin on a local Y axis. By that, I mean a Y axis relative to the part, not the world.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:06 AM |
| Im confused, what exactly is your issue? What are you trying to do? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:13 AM |
Okay, imagine a drill where the point is facing upwards. That drill will be always facing an object while still rotating on the drill's Y axis. How can this be achieved?
Doing this makes it look at a part and rotate on the Y axis relative to the world:
local rotate = 0 while wait() do rotate = rotate+1 part.CFrame = CFrame.new(part.Position,target.Position) * CFrame.Angles(0,math.rad(rotate),0) end
This is not what I want, I want to rotate that part on the part's Y axis, not the world's.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:17 AM |
Oh, I understand now..
I dont know alot about CFramed but,
ill try to look at the wiki and figure it out though. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:19 AM |
Thanks for trying :)
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:21 AM |
| seems like me and you are the only ones on this forum. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 03 Jul 2015 04:26 AM |
| What do you mean by "Rotate on the Y axis"? Can this be accomplished through script or does it have to rotate by touched it? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:28 AM |
@lord
Duh it can be done through script, that's why I'm here and that's why I posted script. Read everything above again, because I don't know how I could have not made sense.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:33 AM |
Basically, he wants to spin the brick, and if you manually rotate the brick, it should still be spinning the exact same way (but roatated)
Like the a drill bit, it rotates the same way, even if you turn the entire drill. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 04:38 AM |
Here's a diagram I posted on ɪᴍɢᴜʀ.ᴄᴏᴍ
/IbUkF1d
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
bomblover
|
  |
| Joined: 23 Mar 2011 |
| Total Posts: 238 |
|
|
| 03 Jul 2015 04:49 AM |
| CFrame.fromAxisAngle() may be of help for this, but I didn't look at the im.gur so I'm not positive. |
|
|
| Report Abuse |
|
|
Tuneable
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 2932 |
|
|
| 03 Jul 2015 05:19 AM |
Perhaps try this?
local x,y,z = CFrame.new(part.Position, target.Position):toEulerAnglesXYZ() part.CFrame = CFrame.new(part.Position) * CFrame.Angles(math.rad(x), math.rad(angle), math.rad(z)) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:43 AM |
@Tune
You'd think that would work huh. It works for the most part, but the X and Z seems to be "dampened" if that makes sense. I tried multiplying them, which made it better, but I can't seem to find the right number to multiply them by. There has to be a way to get that number without guessing..
The search continues
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:52 AM |
So here is what I have right now for testing:
local point = script.Parent.Point local target = script.Parent.Target local inputX = 0
while wait() do local x,y,z = (CFrame.new(point.Position, target.Position)*CFrame.Angles(math.pi/2,0,0)):toEulerAnglesXYZ() point.CFrame = CFrame.new(point.Position) * CFrame.Angles(x, math.rad(inputX), z) inputX = inputX+10 end
Basically there is a model in workspace with "Point" & "Target" inside. I changed it to not use math.rad() for the X and Z, which made it much more accurate, but now it seems that it's spinning "swiveled". You can see my current problem by using my script and applying it to a model with two parts in it. The parts have to be named though, of course.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 06:02 AM |
| For some reason it worked perfectly for me, until I moved the Target part around a little. Sorry I can't help you here, just thought I would let you know that though. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 06:08 AM |
Thanks for posting that, that is actually really good information to have. It seems that it works great when the target is on the same X as the point, time to experiment more.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 06:11 AM |
So some problems seem to be that the rotation flips direction when the target is on different sides of the point, and it starts swiveling when moved off of the same X position.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
Fabunil
|
  |
| Joined: 25 Oct 2013 |
| Total Posts: 4325 |
|
|
| 03 Jul 2015 06:32 AM |
Based on what you have posted so far this is what you want?
local point = script.Parent.Point local target = script.Parent.Target local rotspeed = 180 local angle = 0 while true do angle = angle + wait() * rotspeed point.CFrame = CFrame.new(point.Position, target.Position) * CFrame.Angles(-math.pi/2, math.rad(angle), 0) end |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 06:36 AM |
@Fab
That's it! You're a life-saver man, knew someone had the answer.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 06:39 AM |
Oh my gosh that's so simple, I feel really dumb now lol.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|