Hello, I don’t know much about Body Velocity I just starting to learn about it and I was wondering if it’s possible to go up or down with it. Is it Body Velocity or something else I need to do?
Here is my current code, rn it just goes where the mouse is but I would like it to go down a bit so it touches the floor.
The .Velocity property of BodyVelocity is a Vector3 value, just like a part’s position. As you probably know, Vector3.new(x,y,z) is the basic constructor for a Vector3 value. You can read up on Vector3 values more if you’d like, but I can give you a simple explanation for this issue.
Vector3 values can be treated very similarly to numbers in that you can perform arithmetic on two Vector3 values:
local VectorValue = Vector3.new(1,1,1) + Vector3.new(0,10,0)
This would result in a Vector3 value with the coordinates [1,11,1].
Applying this to your issue, if you want the velocity to go “down a bit”, then (assuming by down you mean along the Y-axis), you can simply subtract from the velocity at the end:
Notice that only the Y value is being subtracted because that’s the up/down direction in workspace. You can always change how much slower/faster it is by adjusting the number.
Sorry I might of explained what I wanted wrong but thanks anyways! What I ment is when I click it throws an object then it goes towards the floor. like throwing a paper, it throws and goes straight then it goes down to the floor.
So basically you want it to be impacted by gravity?
If that’s the case, you can actually change a different property of the BodyVelocity. The MaxForce property is what determines how much force can be applied within each axis.
Again, up-and-down movement correlates with the Y-axis, so you would want to change the value from math.huge to something smaller. Changing it to zero wouldn’t allow the object to move upwards even when being thrown, so it can’t be too small, but it has to be small enough to be quickly impacted by gravity.
You can play around with what numbers to see what works best. Eventually, gravity should overcome the velocity and cause it to move downwards. I’d start with something like this:
And then you can adjust the number to be higher or lower until you’re happy with the result.
Also note that you’d need to adjust this number depending on how much mass the object has, so if you plan to use the script on parts of different mass, you can use part:GetMass() with some math to adjust appropriately without having to hardcode it. But you don’t have to worry about this at all if you’re always going to be using this script on parts of the same size and material.
Could you send the new code? If the MaxForce of the BodyVelocity’s Y-coordinate is small enough, it should move down from the force of gravity if nothing else is pushing it upwards.
The Y value of MaxForce (currently at 100) needs to be changed to a lower number if the movement doesn’t stop, and it needs to be changed to a higher number if the movement barely happens or doesn’t happen at all. That is what I meant by this: