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

How to cheek if the x axes of the force is >1000 when using BodyForce?

Asked by 6 years ago

I am using the BodyForce to move a part. I'm setting the force to a number (in the script) than incrementing the force of the BodyForce that's in the part and I need to check if it is greater that 1000 and if I am incrementing with 350 and I set the BodyForce in the first place to 700 that's equal to 1050 so it never firing that it skipped the 1000 so how do you check if it's > 1000?

Here is the code I'm working with

wait(15)
script.Parent.BodyForce.Force = Vector3.new(700,600,0)

while wait(.1) do
script.Parent.BodyForce.Force = script.Parent.BodyForce.Force + Vector3.new(350,0,0)
wait(.1)
    print(script.Parent.BodyForce.Force)
    if script.Parent.BodyForce.Force == Vector3.new(1000,600,0)  then
        script.Parent.BodyForce.Force = Vector3.new(0,0,0)
        break
    end
end

I tryed doing it like so but didint work out

if script.Parent.BodyForce.Force == Vector3.new(-1000,600,0) or script.Parent.BodyForce.Force == Vector3.new.X <-1000 then

2 answers

Log in to vote
-1
Answered by 6 years ago

Force, MaxTorque, and MaxForce All BodyMovers objects have either a Force, MaxTorque or MaxForce property which function the same. These are Vector3 properties and depending on the amount of each axis (X,Y,Z) will be the maximum amount of force that can be applied to that axis.

BodyPosition.MaxForce = Vector3.new(0, 1000, 0)--no movement on any axis but the Y-axis. P P is the amount of power used to reach a goal. The higher the P value, the faster it will move towards its goal and sometimes even surpass the goal. If set too low, the object might not even move.

D D is the amount of damping that will be used. Damping will stop the object from surpassing its goal and having to turn around. By setting a good D, it will start to slow down as it reaches its goal so that it does not go past it. The higher the D value, the more it will slow down.

BodyAngularVelocity BodyAngularVelocity is used to set a constant rotational velocity. This means it can be used to turn your part even without other forces acting upon it.

The AngularVelocity property controls rotation. Its direction is the axis which the part rotates around, and the magnitude is the speed in radians per second at which it does it. Angularvelocitydiagram.png

BodyVelocity BodyVelocity is used to set a constant velocity. This means that it can be used to move your part at a constant speed despite gravity.

The Velocity property is the maximum speed at which an object can go while being pushed by the BodyVelocity object.

BodyVelocity.Velocity = Vector3.new(0, 1000, 0)--sends the part at a constant speed upward BodyForce BodyForce will push a part with the magnitude and direction of the Force property, in world coordinates.

-- push a 4,1.2,2 part upward, regardless of orientation BodyForce.Force = Vector3.new(0, 1915.52, 0) BodyThrust BodyThrust is similar to BodyForce, however its force works in relation to the object. The Force property defines the direction and magnitude the part should be pushed, in object coordinates. The Location property defines the the position where the thrust is being applied, once again in object coordinates.

-- push a 4,1.2,2 part upward, with the center of thrust at the underside of the part BodyThrust.Location = Vector3.new(0, -0.6, 0) BodyThrust.Force = Vector3.new(0, 1915.52, 0) BodyPosition See also: How To Use BodyPosition BodyPosition moves a brick towards a certain Vector3 point ignoring gravity. The Position property defines the spot in which the part will attempt to move towards.

--Moves part towards center of the world BodyPosition.Position = Vector3.new(0, 0, 0) BodyGyro BodyGyro attempts to keep a fixed orientation of the part relative to its CFrame property. This means it will try to rotate the brick to match the rotation of the CFrame.

--Rotates the brick to stay at a rotation of CFrame.Angles(math.pi / 2, 0, 0) BodyGyro.CFrame = CFrame.Angles(math.pi / 2, 0, 0) RocketPropulsion RocketPropulsion is used to mimic the movement of a projectile. RocketPropulsion has a lot of unique properties that can be used for maximum results.

Target is the Part that the RocketPropulsion is shooting at. TargetRadius is the distance the part must be from its target to trigger its ReachedTarget event. TargetOffset is how far from the target to shoot. CartoonFactor is how much the part points towards its target. 0 is pointing straight up away from the target, 1 is directly at the target. The default is 0.7 in order to counter the force of gravity. MaxSpeed is a number that defines the maximum speed that the part is allowed to reach. TurnP and TurnD are the P and D properties that signify the turning Power and Dampening of the projectile. ThrustP and ThrustD are the P and D properties that signify the movement Power and Dampening of the projectile.

--shoots the projectile in the direction that the object is moving. RocketPropulsion.TargetOffset = RocketPropulsion.Target.Velocity now just use the less than greater than signs to get your >1000

Ad
Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

Just so you know, in Lua code, the == operator isn't the only operator, there are a few more, like: == (Equal to...) ~= (Not equal to...) > (Greater than...) < (Less than...) >= (Greater than or equal to...) <= (Less than or equal to...)

So, you can simply do this:

if script.Parent.BodyForce.Force.X > 1000 then
    --The stuff you want to do
end

Hope this helped!!!

Answer this question