|
| 31 Aug 2016 12:43 AM |
Im making a script that you can click and drag bricks, but i dont want the bricks to get too far from the original clicked distance. How would I do use? Im trying to figure it out via magnitude, can I set an objects magnitude?
|
|
|
| Report Abuse |
|
|
| |
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
|
| 31 Aug 2016 12:52 AM |
if (PlayerCharacter.Torso.Position - part.Position).magnitude > MaxDistance then
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 12:53 AM |
I got that. Its just setting the parts distance after that. Do I just magnitude = MaxDistance?
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 12:56 AM |
hmm, no.. because they're readonly values if i remember.
|
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
|
| 31 Aug 2016 12:57 AM |
"Do I just magnitude = MaxDistance?"
I think you want this:
MaxDistance = -- maximum distance the part can be set to
You don't have to define MaxDistance. |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:04 AM |
I know what magnitude is, its just how do I make it like a rope constraint, bascially.
|
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
|
| 31 Aug 2016 01:07 AM |
Whaddya mean?
Is it like 'if part is too far away then don't run code'? |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:08 AM |
use a rope constraint
that or get the offset it is from the other part and if the magnitude of the offset is higher than what you want, set it to the offset.lookVector*maxlength |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:14 AM |
I got a script that allows players to pick up objects. If the brick gets too farther than the original distance the player picked it up, it simply wont go any farther. As if the part was attached via a rope to the player. And I cant use rope constrants because they are broken, unless I am using them wrong.
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:15 AM |
"cant use rope constrants because they are broken" ?????? |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:16 AM |
I have the attachments, the rope constraint, ive been testing them out and they simply do not work. Ive done everything right with them, dont think I havent attempted to use them. That was my original plan. But its legit just, not working. I drag the brick too far, and it just lets it.
|
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
|
| 31 Aug 2016 01:16 AM |
So isn't this what you need?
if (PlayerCharacter.Torso.Position - part.Position).magnitude < MaxDistance then -- I derped out a little on my first time posting this
It checks for the distance and if the distance is smaller than MaxDistance then your code runs. |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:17 AM |
you can just use a prismatic constraint to make it only move along a certain axis and then change the CFrame of the Attachment to change the rotation of the brick and then use LimitsEnabled and change the min and max when moving it |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:17 AM |
I already have that, I just dont know the code to run to make it where it wont go any farther. I can check it, i just cant fix it.
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:22 AM |
Aha, I fixed my Rope Constraint problem. Im going to use that. Thanks for the help guys, I appreciate it.
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:26 AM |
Pretty sure prismatics also have a Servo Actuator Type so you can change the position of it
one problem is that the lower limit has to be a bit high because it can possibly reflect backwards or behind itself when it takes too much force |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:29 AM |
*sigh* I've come across another problem, I'd like to do this myself beacuse I dont want to have to burden you guys again, but when you *tug* on the constraint, the player goes with it. Can I just make the CurrentDistance the same as the magnitude when the maximum magnitude is reached to solve this, or is CurrentDistance a readonly?
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:30 AM |
| >> "Pretty sure prismatics also have a Servo Actuator Type so you can change the position of it"[2] |
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
|
| 31 Aug 2016 01:31 AM |
Does 'if (PlayerCharacter.Torso.Position - part.Position).magnitude < MaxDistance then' not work for you then?
I'm lost here. |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:32 AM |
| he wants to limit the position, not be like "omg guess what its not in range" |
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 01:32 AM |
My bad, was typing and didnt see it. Ill check it out.
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2016 02:01 AM |
if (Part.Position - Torso.Position).magnitude > MaxDistance then Part.CFrame = CFrame.new(Torso.Position + (Part.Position - Torso.Position).unit * MaxDistance) end
|
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
| |
|