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: Using camera's cframe (I need help)

Previous Thread :: Next Thread 
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 03:13 PM
Is there a way I can script a Body Force's force value to make it go toward where the camera is looking?

If you know, just tell me how please.
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
28 Jul 2017 03:15 PM
BodyForce.force = (camera.CFrame.p-BodyForce.Parent.CFrame.p).unit*POWER
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 03:21 PM
One question? What is the POWER?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
28 Jul 2017 03:31 PM
How much force you want to push the brick. Try a bunch of numbers and pick one you like.
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 03:54 PM
Ok, I found using a negative number will move it towards where you are looking. Positive numbers will just move the object to the camera, lol...
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
28 Jul 2017 03:59 PM
Oh, I didn't see that you wanted it towards where you are LOOKING. You can switch the subtraction before .unit while keeping POWER positive, but I would do this instead:

BodyForce.force = camera.CFrame.lookVector * POWER
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 04:22 PM
thx!
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 04:38 PM
is there a way I can disable movement on the y axis to where the camera can only affect x and z?
Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
28 Jul 2017 04:42 PM
BodyForce.force = camera.CFrame.lookVector * POWER

BodyForce.force = Vector3.new(camera.CFrame.lookVector.x, 0, camera.CFrame.lookVector.y)*POWER

i think that will give you the desired results


Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
28 Jul 2017 04:44 PM
force = Vector3.new(lookVector.X,partVector.Z,lookVector.Z) * FORCE

Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
28 Jul 2017 04:44 PM
shoot, i made a typo. dont say .y on the last one, say .z instead


Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 06:03 PM
I have a script to where when I press 'w' I have a part named Head move forward. How can I make it constantly keep up with the camera. When I press w, it goes forward from where the camera was first, but doesn't follow new camera angles. How can I fix this?
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
28 Jul 2017 06:14 PM
oh, and how do I paste a script in a post?
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
06 Aug 2017 12:07 PM
I have been working on getting this working for a while, and how can I make it go left or right from the camera? I still need help with it keeping track of the cframe and stuff
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
06 Aug 2017 12:14 PM
.rightVector = right
- .rightVector = left
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
06 Aug 2017 12:18 PM
Ok, and do you know a solution to my problem stated above?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
06 Aug 2017 12:42 PM
Oh, so I guess you need to update the force of the BodyForce when the camera moves?
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
06 Aug 2017 12:54 PM
I have it to where it is constantly like it, but I have the force equal the camera stuff only when a key is pressed, and it is in an if statement, so how can this be fixed?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
06 Aug 2017 02:15 PM
When you say "constantly like it", it leads me to believe you have either a while loop or a RunService step updating the force. Shouldn't that do what you want, following the camera whether a keypress moves it or not?
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
06 Aug 2017 06:27 PM
I mean "constantly" as only when I press the key, but I want it to keep up with the camera.
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
06 Aug 2017 09:24 PM
Try hooking it up to RunService Stepped
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
07 Aug 2017 09:53 AM
Where would I incorporate RunService Stepped into my script, I find it to act like a loop already with a debounce.
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
07 Aug 2017 07:04 PM
If you already have a loop you can use that instead.
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
08 Aug 2017 10:25 AM
When I use a loop, it wont stop doing it though.
Report Abuse
bobbybob1010 is not online. bobbybob1010
Joined: 02 Mar 2014
Total Posts: 120
08 Aug 2017 11:32 AM
I got it working. I had a script inside of the script that makes a value equal the camera stuff, then I just have the force's parent go to the part and out of the part of the events.
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