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: Lookvector help

Previous Thread :: Next Thread 
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 11:31 AM
I am working on a train that I want to be able to run on tracks on both the x and y axis, but right now, the bodyvelocity.velocity in the train only moves forward on the z axis, so when it turns, it moves very slow.

Things I need to know:
-How to find the lookvector of a part, and how it is described
-How to edit this script so that BodyVelocity.velocity is always the lookVector of its parent.

bv = Instance.new('BodyVelocity')
bv.maxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Parent = Workspace.Engine --(Engine is a part)
bv.velocity = Vector3.new(0,0,60)

I need to know how to change the last line so that the direction of the velocity is the same as the Lookvector of bv's parent.

Thanks in advance


Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
07 Aug 2014 11:36 AM
If you want something to always be pushed forwards, regardless of its orientation, you could use BodyThrust. Set it to the speed you like (I'm pretty sure the Z axis is forwards, but I may be wrong) and your part will always be moving forwards (even when it turns 90 degrees).

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Bobobob12 is not online. Bobobob12
Joined: 23 Jan 2008
Total Posts: 5350
07 Aug 2014 11:36 AM
while wait() do bv.velocity = script.Parent.CFrame.lookVector * 10 end
Report Abuse
Bobobob12 is not online. Bobobob12
Joined: 23 Jan 2008
Total Posts: 5350
07 Aug 2014 11:37 AM
Use BodyThrust instead!
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 12:00 PM
So the 'force' property of BodyThrust is like 'veloctity' for BodyVelocity?
Report Abuse
Bobobob12 is not online. Bobobob12
Joined: 23 Jan 2008
Total Posts: 5350
07 Aug 2014 12:01 PM
yes, only set x or z and experiment to figure out which is forward in your case
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 12:07 PM
I set the force of BodyThrust to (0,0,60), which is the forward direction since it didn't move at all when it was set to x, but it moves extremely slow, and in a second test it moved backward. Is the force the same as the velocity? Right now it doesn't really seem like it.
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
07 Aug 2014 12:09 PM
The force will not be the same as velocity. Just bump up the force until you find a good amount.

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 12:23 PM
Ok, I've found the proper numbers, but the train moves backward instead of forward, could it be the Lookvector of the engine? Could it be BodyThrust.location?
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
07 Aug 2014 12:24 PM
If it's moving backwards just make the thrust negative what it is right now.

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 12:26 PM
That worked great! Thanks for all the help you two!
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 12:45 PM
The train moves properly on the z axis now, but I'm still having the same problem with the x axis. I've even tried setting the force to (-12000, 0, -12000), but the train still stops when the track turns 90 degrees.
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
07 Aug 2014 01:02 PM
You can't turn the track all at once, you have to make it curve the train as it goes. Take everything off the X axis, and provided you're using BodyThrust the train will always move in the direction that it is facing.

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 01:09 PM
Here is a screenshot of how the track is curved:

http://s22.postimg.org/dlwghrv9s/Roblox_Screen_Shot08072014_140614296.jpg

The train can curve on this track, but it stops when it reaches the end of the curve.
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
07 Aug 2014 01:11 PM
I'm really not sure what is happening with that then. Are you sure the only BodyMover inside of the train is the BodyThrust (and maybe BodyAngularVelocity, if you're using that)?

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 01:34 PM
I don't really know how this fixed it, but moving the engine all the way to the front of the train did the trick. Thanks for all your help, again.
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 01:53 PM
Actually, the problem isn't solved, my bad. As a last resort, I'd thought I'd post the script here:
num = 0
button = script.Parent
bt = Instance.new('BodyThrust')

bt.force = Vector3.new(0,0,0)
bt.Parent = button.Parent.Parent.Engine


function normalspeed()

button.BrickColor = BrickColor.new(37)
bt.force = Vector3.new(0,0,-12500)



end

function lowspeed()
button.BrickColor = BrickColor.new(24)
bt.force = Vector3.new(0,0,-10000)

end

function brake()
button.BrickColor = BrickColor.new(21)
bt.force = Vector3.new(0,0,0)



end

button.ClickDetector.MouseClick:connect(function()
num = num + 1
if num == 1 then
normalspeed()
elseif num == 2 then
lowspeed()
elseif num == 3 then
brake()
num = 0
end






end)
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 01:57 PM
bump
Report Abuse
Bobobob12 is not online. Bobobob12
Joined: 23 Jan 2008
Total Posts: 5350
07 Aug 2014 02:05 PM
there's nothing wrong with your script, it may just be that it's hitting something that's stopping it
Report Abuse
Bobobob12 is not online. Bobobob12
Joined: 23 Jan 2008
Total Posts: 5350
07 Aug 2014 02:06 PM
assuming it stops at the right there, if those parts are collidable there's a good chance it's getting stopped on them
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 02:15 PM
Yes! I widened the track a bit and now it works! Thanks both of you for like, 10 helpful responses.
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 03:21 PM
Now I have a problem where I call brake() to stop the train when it is on the x axis, then call normalspeed() again, it won't move anymore. Is there any explanation? I think this has been unexpectedly puzzling all of us today.
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 03:37 PM
bump...?
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 03:46 PM
I looked in the cookbook on the wiki and it said that BodyForce allows you to move a brick using a certain amount of force, and that BodyThrust moves a brick using a certain amount of force AND in a certain direction, so is BodyForce the solution to this problem?
Report Abuse
Hakupa is not online. Hakupa
Joined: 03 Sep 2011
Total Posts: 5375
07 Aug 2014 04:16 PM
I tried BodyForce and it just isn't working.
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