Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make moving object that don't sink down, maintain constant speed and player stick to it?

Asked by 3 years ago

There are many problems that I have. When I tried out some solution, it only causes more problems or the solution isn't working which I fixed by reverting the change. Also, this problem happens both in the studio environment and in the live game.

==== Expected and Actual Result ====

Expected Result: The object will move to determine position and the player will stick to the object. The object will move at a constant speed without changing its speed due to acceleration or de-acceleration.

Actual Result: Object is sinking below determined vertical (Y) position, the object moves at a different speed, deaccelerating when closer to the determined position and accelerate very quickly when far away from determined position. The Player did stick to the object, however.

==== My attempt at finding solution ====

Solution Requirement:

  1. Object must stop falling below determined vertical (Y) position. (This also applies to other position where it will create "Rubber-Band" effect)

  2. Object must be moving and must stay at a constant speed. (object can never accelerate OR deaccelerate)

  3. Player must be stick to the object (player must be moving along with object without any interaction)

  4. There's no major complication with the script (Example: Object glitching when player stand on it)

1st Solution: Rising MaxForce of Y component. This would have been an easy solution and I would have never written this question BUT it looks like the object completely ignored the Y component and keep sinking regardless.

2nd Solution: Changing the D property of BodyPosition. If I change D lesser then the object will move too fast (still don't solve constant speed problem) which isn't what I wanted. When I look at the hour of code which is made by roblox (I know it's old, I am that desperate). It seems like they change the D property to be higher than the P property. I tried the same property, SAME SCRIPT but the result is different from the video. (which I am expecting)

3rd Solution: Using BodyVelocity. BodyVelocity solves constant speed but won't make the player stick to it. BodyVelocity is already out of the window at this point.

4th Solution: Freezing position of Y using script. This solves the problem of object sinking but this does not solve the constant speed problem. This solution also introduces a new problem which is when the object just glitched (weirdly moving, sometimes falling out of the world) when the player stands on it.

5th Solution: Manually set the position of the object using script. This removes all body mover but the player doesn't stick to the object AND it's also very laggy which is questionable, player sticking to an object can be solved by using a conveyor-based solution (object is anchored and player is moving when standing on) but very hard to predict and very weird. This solution is out of the window.

==== Code of the script ====

NOTE: There's no problem with the script itself, it just happens that the code doesn't solve any problem that I mentioned.

-- This is my current script (Server Script)
local me = script.Parent
local bodyPos = me.BodyPosition

while true do
    bodyPos.Position = Vector3.new(-14.25, 0.6, 72)
    wait(7)
    bodyPos.Position = Vector3.new(-14.25, 0.6, 32)
    wait(7)
    -- The difference between each position is 40 (looking at Z component)
end

==== Hierarchy of object ====

Also here's the hierarchy of my part that I want to move an object which is a big problem.

---- MovingPart <-- Part I want to move

-------- Script <-- See above to look at the code of the script

-------- BodyAngularVelocity <-- This is to stop the object from spinning

-------- BodyPosition

Use this tree to add an object OR remove object to the part included in the solution.

0
Have you tried using a BodyGyro? THEROBLOXAIN2 15 — 3y
0
My object have nothing to do with rotation but I did tried using BodyGyro and it doesn't work. Somone_exe 224 — 3y
0
Could you try just using the bodyposition for just the y axis again and then just using a simple bodyforce? Roblox bodyforces and bodypositions are tricky to work with. If its not solved later I will offer to help out on finding the solution with you. THEROBLOXAIN2 15 — 3y
0
Can you try using... SetPrimaryPartCFrame? Xapelize 2658 — 3y
View all comments (5 more)
0
I'm not really sure what you are talking about. Can you explain them in baby words? Xapelize 2658 — 3y
0
One more question, Is the object only moving in one direction or does it turn? THEROBLOXAIN2 15 — 3y
0
1st comment: I will try the bodyforce + bodyPosition, 2nd comment: I am not sure, 3rd comment: Moving part that player stick to with constant speed and determined position Somone_exe 224 — 3y
0
4th comment: it move in 2 direction which is left and right, does instantly go to right from left count as turn? Somone_exe 224 — 3y
0
After I tried bodyForce + bodyPosition, this do not solve any problem (bodyForce don't have constant speed, it simply accelerate) AND this also don't stick player to the part. Somone_exe 224 — 3y

Answer this question