|
| 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 |
|
|
|
| 28 Jul 2017 03:15 PM |
| BodyForce.force = (camera.CFrame.p-BodyForce.Parent.CFrame.p).unit*POWER |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2017 03:21 PM |
| One question? What is the POWER? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 28 Jul 2017 04:44 PM |
force = Vector3.new(lookVector.X,partVector.Z,lookVector.Z) * FORCE
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 28 Jul 2017 06:14 PM |
| oh, and how do I paste a script in a post? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 06 Aug 2017 12:14 PM |
.rightVector = right - .rightVector = left |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2017 12:18 PM |
| Ok, and do you know a solution to my problem stated above? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 06 Aug 2017 09:24 PM |
| Try hooking it up to RunService Stepped |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 07 Aug 2017 07:04 PM |
| If you already have a loop you can use that instead. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2017 10:25 AM |
| When I use a loop, it wont stop doing it though. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|