Help and Feedback Scripting Support Show
So I’m Working on a game and I want a car to come out of a tunnel and drive to the other tunnel So I want to make a car that drives from point B to Point A * note is a one way street * My grammar is bad since I did this in a rush 2 Likes
You can build a looping lerp function pretty easily. The idea behind it would be you take the current time, take the modulus based on the duration of this loop, and feed that modulus value into the lerp. Here’s an example: local RunService = game:GetService("RunService") local car = some.instance -- for the purposes of this post, it is assumed to be a Model local loopDuration = 123 -- some number of seconds for the loop duration to take place local pointA = Vector3.new(1, 2, 3) -- up to you local pointB = Vector3.new(4, 5, 6) -- up to you function calculateLerpedCFrame(t, pointA, pointB) local displacement = pointB - pointA if displacement.Magnitude == 0 then -- pointA and pointB are identical return pointA end local direction = displacement.Unit local lerpedPosition = pointA + (displacement * t) local lerpedCFrame = CFrame.new(lerpedPosition, lerpedPosition + direction) return lerpedCFrame end function calculateLoopedLerpValue(timestamp, duration) return timestamp % duration end function onStepped() local currentDateTime = DateTime.now() local timestamp = currentDateTime.UnixTimestampMillis / 1000 -- put it into seconds with rough millisecond accuracy local lerpParameter = calculateLoopedLerpValue(timestamp, loopDuration) local carCFrame = calculateLerpedCFrame(lerpParameter, pointA, pointB) car:SetPrimaryPartCFrame(carCFrame) end RunService.Stepped:Connect(onStepped) -- or use one of the new run service signals
1 Like
I have no idea what it means since I’m trash at script. I meant this "new run service signals’ 1 Like
Pretty much the script that Post 2 sent is basically Lerping the Car Lerping pretty much takes an end position (Provided that you already have a start position to get a direction result) and a range between 0 & 1, it’ll return back the Lerped CFrame I believe Although I would try this, it would be confusing to other members Another way you can try is by assigning a BodyVelocity object to the Car itself for it to move from Point A to Point B that way, then detect when the Car ends by detecting a Touched event for Point B 2 Likes
how would you make it so its not a loop, and only lerps in a random amount of time? it waits a random amount of time, then goes to its vector 3 position
Help and Feedback Scripting Support
Hello! My name is Sandessat, I know some things of LUA (Comments to Coroutines), and to prove my knowdeledge: I want to make a car, but I dont know how to start doing this with scripts. I have the base and wheels done, if you need more information about them, tell me! BASE: The body of the car, it is a mesh made from blender. None of them are welded or anything, they’re just added normaly as a mesh in ROBLOX Studio. 1 Like
So the tutorial series I’ve linked is the same for other cars and trucks types besides drifters. This series should help you out, best of luck! Edit: You can add or remove steps from the video.
5 Likes
Here are some more resources I found: https://developer.roblox.com/en-us/articles/building-carkit-1 Control mechanism I found, it’s a better solution to the while true do loop(can get laggy since it always runs) of the Roblox default tutorial: Vehicle Input Controller Module Community Resources Heya fellow developers! I was just updating my Input module for my car game and thought someone else might find it useful, so here you go! local m = {} -- functions local inputs = {} -- input states local controls = {} -- keybinds inputs.Throttle = 0; -- User input determining the power sent to the wheels inputs.Steer = 0; -- User input determining the angle at which the wheels should be turned. inputs.Clutch = 0; -- A mediator between the engine/throttle and the wheels inputs.Ha… This thread has some pretty interesting formulas to apply for suspension: Car Suspension (Scripted) Scripting Support Jailbreak Cars. I’ve been hearing a lot about them in the past few months and I’m really keen to get stuck into the mechanics of their suspension rig. After doing my research, I have found out from numerous sources, that the rig uses Body Gyros & Body Thrusts in combination with ray-casting at each corner of the vehicle to acquire the force to push down on each wheel. This makes sense. The only part that doesn’t make sense is how this would relate to the servo movement of the wheels individuall… This thread also has a list of possible ways to script a car: Is anyone able to help me understand vehicles? Scripting Support If youre looking for cross compatible support like on my game test, you should not use vehicle seat input at all. Some of the controls are terrible, specifically for mobile and console. The joystick, for example, controls both steer and throttle. The triggers also control throttle but the input is not analog. It is mostly better to map them yourself once you got basic input handling down. You can just use values for brake and throttle based on things like the fingers position or the triggers pre… Overall, look through them and decide which one is best for your purposes. Good luck applying and further improving your LUA skills! 7 Likes
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead. Duplicate Wheels1. Move Wheel Against BaseUh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead. 2. Duplicate/Move Back WheelUh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead. 3. Duplicate/Move Front WheelsUh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead. 2. Set Hinge Properties (Both Sides)A. Select Both HingesUh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
Uh oh! Your browser doesn't appear to support embedded videos! Here is a direct link to the video instead.
|