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: Go forward in direction of camera

Previous Thread :: Next Thread 
007n7 is not online. 007n7
Joined: 13 Oct 2008
Total Posts: 109
25 Apr 2014 08:57 PM
Hi, I'm trying to make a ball that you can control with a hopperbin. I'm trying to make it go forwards in the direction that the camera is facing. I already have the keydown event and camera attached. I also have it so it rotates in the direction that the camera is facing, but I need to know how to make it go forward. I tried using angularvelocity and it went in the same direction no matter what.
Please help!
Report Abuse
007n7 is not online. 007n7
Joined: 13 Oct 2008
Total Posts: 109
25 Apr 2014 09:08 PM
Bump.
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
25 Apr 2014 09:10 PM
Camera.CoordinateFrame.lookVector

and I wouldn't use bodyangularvelocity because then your ball won't be able to roll.
Report Abuse
007n7 is not online. 007n7
Joined: 13 Oct 2008
Total Posts: 109
25 Apr 2014 09:13 PM
What should I set as lookVector?
Also, what kind of velocity should I use, I tried BodyVelocity and it did the same thing.

Here's my script:

while true do
wait()
if script.Parent.up.Value == true then
script.Parent.BodyAngularVelocity.angularvelocity = Vector3.new(0,0,script.Parent.BodyAngularVelocity.angularvelocity.Z+1)
elseif script.Parent.up.Value == false and script.Parent.BodyAngularVelocity.angularvelocity.Z > 0 then
script.Parent.BodyAngularVelocity.angularvelocity = Vector3.new(0,0,script.Parent.BodyAngularVelocity.angularvelocity.Z-1)
end
local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = game.Workspace.CurrentCamera.CoordinateFrame:components()
heading = math.atan2(m02, m22)
script.Parent.Rotation = Vector3.new(0,math.deg(heading),0)
end
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
25 Apr 2014 09:13 PM
bodyvelocity.velocity = camera.CFrame.lookVector*speedhere

speedhere would be like,20
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
25 Apr 2014 09:14 PM
Extracting euler's angle from the camera sucks.

Just. Don't.
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
25 Apr 2014 09:17 PM
Like I said, BodyAngularVelocity rotates islandmaker. Plus even if it didn't, yours would make the ball fly in the air.
Report Abuse
007n7 is not online. 007n7
Joined: 13 Oct 2008
Total Posts: 109
25 Apr 2014 09:18 PM
Got it to work.
Thanks everyone for helping!
(just incase someone looks this up or something heres the script i used:)
while true do
wait()
if script.Parent.up.Value == true then
script.Parent.BodyThrust.force = Vector3.new(0,0,script.Parent.BodyThrust.force.Z-100)
script.Parent.BodyThrust.location = game.Workspace.CurrentCamera.CoordinateFrame.lookVector
elseif script.Parent.up.Value == false and script.Parent.BodyThrust.force.Z > 0 then
script.Parent.BodyThrust.force = Vector3.new(0,0,script.Parent.BodyThrust.force.Z+100)
script.Parent.BodyThrust.location = game.Workspace.CurrentCamera.CoordinateFrame.lookVector
end
local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = game.Workspace.CurrentCamera.CoordinateFrame:components()
heading = math.atan2(m02, m22)
script.Parent.Rotation = Vector3.new(0,math.deg(heading),0)
end

Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
25 Apr 2014 09:19 PM
I have no idea how that even worked but okay.
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