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

Part not moving with positive bodyvelocity?

Asked by 5 years ago

Hello

I'm trying to find a way to make parts move smoothly across the screen. I began by using loops to reset the part position (through a vector3) : this worked ok but the movements were a little clunky.

So I tried attaching a bodyvelocity to the part and setting the values so it would move in the x axis. The script is below, and when I start the game the part does not move at all.

I'm assumign there is something really simple which I am missing here i.e another parameter needs setting. I'd be very grateful if someone could point me to what I am missing here.

workspace.Part.BodyVelocity.Velocity=Vector3.new(50,0,0) local p=Workspace.Part.BodyVelocity.Velocity print(p)

Thanks very much.

2 answers

Log in to vote
0
Answered by 5 years ago

The thing is that it works, it is just not enough to actually show a difference, try putting it at 500 and you'll see the difference

0
Thank you Microsoft_Net. I've tried putting in 500 and then 1000 and it is still not moving. I think there is something I might be misundestanding about how velocity works. Do I need to set another parameter before a part will move. redchris999 4 — 5y
0
I don't really think you need a parameter, do you have the part anchored? Microsoft_Net 21 — 5y
0
Hi there. Yes it is anchored. I've put the velocity up to 5000 and no joy. redchris999 4 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I managed to get the effect I was after by using lerp. This was adapted from an earlier answer.

I'm stil scratching my head about velocity, but at least I have got the effect I was after :)

Thank you

local mover=game.Workspace.Mover -- the part you want to move local right=game.Workspace.RightBound -- a part which sets right bound for movement of mover

local start = mover.CFrame local finish = right.CFrame

-- over the course of ~1 second, vary progress from 0 to 1

for progress = 0, 1, 0.03 do -- consequently: -- over the course of 1s, vary part.CFrame from start to finish mover.CFrame = start:lerp(finish, progress) wait(0.5) end

Answer this question