|
| 10 Nov 2017 03:11 PM |
I am using a position Handles object to move blocks around.
I got a table of functions defining movement for different NormalIds, an example would be:
local movement = { [Enum.NormalId.Front] = function(obj, delta) obj.CFrame = obj.CFrame + (obj.CFrame.lookVector * delta); end; ... };
the movement table contains a function that defines movement for each NormalId.
Now on the handles MouseDrag event I calculate a delta, using a previously acquired drag distance, and the current drag distance. (dont worry, I reset the previously acquired drag dist in the handles.MouseUp event function)
move_handle.MouseDrag:connect(function(fase, dist) if not debounce then debounce = true; local delta = (dist - (dist % 0.5)) - (last_dist - (last_dist % 0.5)); --I move blocks by 1/2 of a stud for i,v in pairs(movement) do if i == face then movement[i](move_handle.Adornee, delta); end end last_dist = dist; debounce = false; end end);
The problem comes occasionally when I move a block, then let go of the handle, the block will move by 1/2 of a stud in a seemingly random direction. This often happens when I am trying to place a block right beside another block, however whenever a user decides to enter the position mode, I make sure every block in a user's workspace is CanCollide false so that you can move blocks inside of each other without problems.
I have no other code that changes the position of the block other than this movement code, so what could be causing this annoying and odd problem? Am I not doing something correctly, or am I forgetting to do something important? or is there something wrong with ROBLOX?
thanks |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 10 Nov 2017 09:43 PM |
| bumpbumpbumpbumpbmupumpbmpuhrtedrfa |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 11 Nov 2017 10:55 AM |
| BUMP HELP THIS IS A FRUSTRATING PROBLEM |
|
|
| Report Abuse |
|
|
Elbixdio
|
  |
| Joined: 03 Aug 2016 |
| Total Posts: 38 |
|
|
| 11 Nov 2017 11:29 AM |
learn your scripting this is an easy fix
|
|
|
| Report Abuse |
|
|
|
| 11 Nov 2017 04:33 PM |
@Elb I'm obviously too stupid to see the problem in this case, which makes me sad.
I literally don't understand what is causing my problem.
if you want the code for the MouseButton1Up event here it is
move_handle.MouseButton1Up:connect(function() last_dist = 0; end);
please help :( |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Nov 2017 05:42 PM |
nevermind im stupid, i somehow just realized how dumb I was for placing a debounce on the drag function lol!
Easiest fix ever, thank you elb. |
|
|
| Report Abuse |
|
|
Skylake_X
|
  |
| Joined: 16 Jul 2014 |
| Total Posts: 275 |
|
|
| 11 Nov 2017 05:44 PM |
| dont use semicolons this isnt c |
|
|
| Report Abuse |
|
|
Voxxie
|
  |
| Joined: 27 Aug 2006 |
| Total Posts: 325 |
|
|
| 11 Nov 2017 05:46 PM |
| There's nothing wrong with using semicolons :^) |
|
|
| Report Abuse |
|
|
|
| 11 Nov 2017 05:50 PM |
nevermind the debounce has nothing to do with the problem as it still persists.
I like using semicolons to format my Lua code; are you trying to say that the semicolons are the cause of the problem? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 12 Nov 2017 12:20 PM |
I finally realized that the iteration in the MouseDrag function is pointless, so I removed it, however the problem is still there.
move_handle.MouseDrag:connect(function(fase, dist) if not debounce then debounce = true; local delta = (dist - (dist % 0.5)) - (last_dist - (last_dist % 0.5)); --I move blocks by 1/2 of a stud movement[face](move_handle.Adornee, delta); last_dist = dist; debounce = false; end end); |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 12 Nov 2017 03:27 PM |
bump
I think this thread is getting close to the world's most number of bumps without receiving any help. |
|
|
| Report Abuse |
|
|
| |
|