|
| 11 Jan 2015 11:06 AM |
I'm trying to make a model circle around something with body velocity, but there's one big problem
body velocity uses world coordinates and not cframe
I've only been able to make parts circle around eachother using cframe andnot vector3
how would I do it with body velocity?
this is what I've tried:
function circleUnit(targ) local targetPoint = (huey.Main.Position - targ.Position).unit * settings.Speed.Value local dist = (huey.Main.Position - targ.Position).magnitude huey.Main.Engine.velocity = Vector3.new(targetPoint.X - dist/2, huey.Main.CFrame.Y, targetPoint.Z * dist/2) end
All it does is make the model back all the way up away from the target. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 11 Jan 2015 11:10 AM |
| Just do the same as you would for a CFrame method, but stick parentheses around the whole CFrame thin and put .p after it to change it to a V3Pos |
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 11:13 AM |
*Clicks thread and hopes I can be of assistance...
*Reads off first paragraph...
*Sees code...
*Relizes i'm no help... |
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 11:22 AM |
@Elunate, I'm not entirely sure how to apply it though..
There is no "angles" in body velocity, and that's what I would use to do it. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 11 Jan 2015 11:24 AM |
| Position = (CFrame.new(Origin, pointTo)*CFrame.Angles(Rotation)*CFrame.new(0,0,-Distance)).p |
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 11:32 AM |
I did this, and it made it fly really fast in one direction:
local targetPoint = (huey.Main.Position - targ.Position).unit local dist = (huey.Main.Position - targ.Position).magnitude huey.Main.Engine.velocity = (CFrame.new(huey.Main.Position, targetPoint) * CFrame.new(0, 0, -dist)).p |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 11 Jan 2015 11:36 AM |
| Changing a unit to a rotation vector involves position+unit or V3.Zero,unit |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 11 Jan 2015 12:11 PM |
| (CFrame.new(huey.Main.Position, huey.Main.Position+targetPoint) * CFrame.new(0, 0, -dist)).p |
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 01:41 PM |
It just makes it go in one direction.
Btw I'm using body velocity. If I set the velocity to it's position, it'll make it go very fast in one direction |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Jan 2015 02:07 PM |
Sorry, my approach is much different as I hand-created it on a piece of paper.
local body = part.BodyVelocity; local radius = (part.Position - target.Position).Magnitude;
while true do local direction = (target.Position - part.Position).unit; local angle = math.atan2(direction.Z, direction.X); body.velocity = Vector3.new(radius * -math.sin(angle), 0, radius * math.cos(angle)) wait(); end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Jan 2015 02:12 PM |
I actually made is a bit misleading. It should be atan2(direction.X, direction.Z) and radius * -math.cos(angle) and * math.sin for the other one. |
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 03:15 PM |
@cnt
https://www.youtube.com/watch?v=-yDusZOs1Hs
|
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 03:21 PM |
I also kept changing it after that.
It circles 90 rads around the building, and then goes in the same direction after that. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Jan 2015 03:22 PM |
It is working perfectly fine for me though. pastebin/e6FQDCXc |
|
|
| Report Abuse |
|
|
|
| 11 Jan 2015 03:24 PM |
| Damn, you actually fixed it. Was just a problem with my looping. Thanks |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Jan 2015 03:26 PM |
This is how I basically did it on paper if you care:
prntscr/5rblsr |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 11 Jan 2015 04:04 PM |
I thought you were using a bodyPosition. Dude why |
|
|
| Report Abuse |
|
|
| |
|