Oh sorry, I don’t remember that.
I have a place file with the proper train model I made/still working on so I was wondering if you want to see the train model drive for it to look a bit more realistic.
Oh sorry, I don’t remember that.
I have a place file with the proper train model I made/still working on so I was wondering if you want to see the train model drive for it to look a bit more realistic.
Sure, show it, what is the approach to make the train to travel? ofc, just show it
I can’t show you right now because I’m not on my laptop right now but I will be in around 14 hours! Lol
The train already travels. It uses Balls for the wheels (which each wheel has a cylindrical constraint for the wheels to spin) and a cylinder between the tracks for the glider and it works really well but the system itself still needs a lot of work.
Is your version of the pantograph finished yet or are you still working on it? I’ll show you the video of the train once I’ve added your version of the pantograph to the train.
Hey!
On your version of the pantograph was the hand anchored when the pantograph moves? I’ve made a new version using your approach and it works but it’ll only work when the hand is anchored and not anchored and this will be an issue for the train because the train will not move if there are any parts that are welded to the train are anchored. If your version of the pantograph hand is not anchored then how did you fix this issue?
For making it look animated like it did when the pantograph used target angles to raise and lower when you click the button would the best approach to be to use tween service?
The Hand is welded to the Train or the Pantograph by a Motor6D. Not anchored, just controlled by the Motor6D. Now you should offset the C0 or C1 coordinates based on the RayCast result, Hit.Position or Hit.Distance, both can work to offset the Motor6D
You should offset the Motor6D slowly, by lerp I think, or TweenService, I think lerp could work better, but idk until testing it
Should I attempt to make my own version or should I just wait for you to finish off your version? I don’t want to waste your time working on it if I’m working on it also.
Yup, sorry for not working on that, Im kinda busy, but I think I already provided with an approach that works good, would be better you keep working on your version and I can reply to your questions if you have some
Nah, its all good. Ok thank you!
I don’t really know how to use motors but I’ll have a little player around.
I don’t know what lerp is or how to use it but I do know how to use TweenService.
Motor6D is what characters uses to weld its parts, so the character can move while the parts still welded and still can be moved or even animated by the Animator Tool.
You can do it with TweenService then, but same as the Motor6D’s, I suggest you should go into those topics and learn both. Search for information about Lerp() and Motor6D. The more you know, the closer you are to achieve your system
Okie dokie.
What was the red block inside of your version for?
Do you want to give me instructions or explain how you did it?
Its a welded block where the Raycast comes from. The block is using a WeldConstraint, that welds the Train and the Block.
So the raycast is not handled from the Hand, its handled from a welded block glued to the Train, in that way the Motor6D can offset the Hand the exact amount. If you do it from the pantoHand it will behave weird because the Hand position is always changing over time
So how does your raycast work? or what’s the calculations you used?
What should I change here?
local RaycastResult = workspace:Raycast(Pantograph.Hand.Position, Vector3.new(0, 10, 0))
if RaycastResult then
local RaycastInstance = RaycastResult.Instance
if RaycastInstance.Name == "Wire" then
Pantograph.Hand.Position = RaycastResult.Position - Vector3.new(0, Pantograph.Hand.Size.Y / 2, 0)
Pantograph.Hand.Orientation = Vector3.new(RaycastInstance.Orientation.Z, -90, 0)
end
end
What was the Motor6Ds part0 and part1? I’ve tried to set the part0 to the base and then part1 to the hand and it made the hand go to the center…
Raycast from the red block and upwards
local origin = originRay.Position
local direction = originRay.CFrame.UpVector * 20
And I used the Distance between the red box and the wire hit point to offset the hand’s motor.
Like:
Motors.Hand.C1 = CFrame.new(0, -RaycastResult.Distance, 0)
After making that to work, you should need to add extra offset as the Hand Size and the half of the Size of the Wire.Y
I forgot to add, that the Hand of my panto re-Orients itself too. So the rotation of the Hand is based on the Wire rotation too, so the front and back of the Hand always lays on the surface of the Wire.
For that, I created 2 Hands, one is just an invisible Box (the one that is welded to the Motor6D, and welded by Hinges to the Arms) And a VisualHand, which is the Mesh, which is welded to the invisible Hand, by another motor6D, that motor will be re-Oriented based on the Wire rotation
Ok thanks I probably wouldn’t have of got that lol.
Yeah I figured that one out by myself lol.
Ok.
I’ll have a play around and I’ll see what I can do.
Pantograph.Origin.CFrame.UpVector * 20 isn’t seem to be working for me, it prints out nil when I fire it using the raycast. Did you at all have this issue?
Nope, it works as expected for me. Its something that should not fail, unless the wire is more than 20 studs away from the red box.
Show your code. And remember to use RaycastParams.Exclude
Heres the code:
local Pantograph = workspace.Train.Pantograph
local function UpdatePantograph()
local RaycastResult = workspace:Raycast(Pantograph.Origin.Position, Pantograph.Origin.CFrame.UpVector * 20)
if RaycastResult then
local RaycastInstance = RaycastResult.Instance
if RaycastInstance.Name == "Hitbox" then
Pantograph.HandBox.Motor.C1 = CFrame.new(0, -RaycastResult.Distance, 0)
--Pantograph.HandBox.Motor.C1.Orientation = Vector3.new(RaycastInstance.Orientation.Z, -90, 0)
end
end
end
local Heartbeat = nil
Heartbeat = game:GetService("RunService").Heartbeat:Connect(function()
UpdatePantograph()
end)
I’ve turned off the CanQuery property on everything except for the origin and wire hitbox. Is there anything wrong with updating the position of the hand or would that work just fine?
At first sight looks going good, add prints to be sure the raycast is hitting something or not. The motor is already in place too?
If you have issues adding the motors use this plugin RigEdit Lite
Yeah its Definity hitting something.
Change all Hinges from Servo to None.
The motor you are changing on your script:
Pantograph.HandBox.Motor.C1 = CFrame.new(0, RaycastResult.Distance, 0)
Its not the right one, that one is to change the rotation of the VisualHand.
The one you want to offset is the Motor that welds the BoxHand and the Train. You didnt created that one yet.