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 vs vector3

Previous Thread :: Next Thread 
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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
punkymonkies is not online. punkymonkies
Joined: 22 Dec 2013
Total Posts: 1229
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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
11 Jan 2015 11:41 AM
how would I do that?
Report Abuse
eLunate is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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 is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
11 Jan 2015 03:15 PM
@cnt

https://www.youtube.com/watch?v=-yDusZOs1Hs

Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
11 Jan 2015 03:24 PM
Damn, you actually fixed it. Was just a problem with my looping. Thanks
Report Abuse
cntkillme is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
11 Jan 2015 03:29 PM
cewl
Report Abuse
eLunate is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
11 Jan 2015 04:18 PM
lol :(
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