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

Aircraft Reverse Thrusters?

Asked by 9 years ago

Basically, I've been working on a script that makes the brick transparent on activating the keyword "V" V basically acts as reverse thrusters, but I'd like more of a realistic animation. What I would like is to have the brick fade if the speed is 2, and the brick to change width to around 50 upon when the speed is uppered. This is what I'm currently using

rather then a function, i'd just like it to work where it has the "if key=="v" then" thanks

function fadeBrick(obj) for i = 100, 0: obj.Transparency=i obj.Remove() end

if key == "v" then
        fadeBrick(plane.ReverseThrusters.Left.WeldPart)

    end

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

The most efficient way I can see to achieve the effect you desire is to check the current speed and compare it to some breakpoints, after which you can modify the effect to be "realistic".

Here's an example of what I mean:

--I'm assuming this is a LocalScript

local speed = 0 --studs/sec
local accel = 0 --studs/sec/sec

--CODE
if key == "v" then
    accel = -10
end
--CODE

local obj = plane.ReverseThrusters.Left.WeldPart

local t = tick()
game:GetService("RunService").RenderStepped:connect(function()
    local dt = tick()
    dt, t = dt - t, dt --This gets the time delta, so that acceleration is accurate on any framerate.

    speed = speed + accel*dt
    --Wherever you're changing the Position of the aircraft, use `speed` as the speed. :P

    if speed < 0 then   
        obj.Transparency = 1
    elseif speed <= 2 then
        obj.Transparency = 1 - speed/2 --ranges from 0 to 1. Fully opaque at speed = 2, invisible at speed = 0
    end
end)
0
Didnt work. MysticalMod 0 — 9y
Ad

Answer this question