Roblox Bicycle Mechanics, Urgently Need Help. How do I make the bicycle jump, without bouncing, and able to do so when moving?

How would I go about making a bicycle jump? I’ve tried the following, where I already have a VectorForce controlling the forward movement of the bike. However, I’m unsure if a VectorForce is appropriate for making it jump, and I can’t think of alternative ways. This is what I’ve got and I’ve basically hit a brick wall in my brain from here. Any help is appreciated, thanks.

local HoldingSpace = false
local Jumping = false

function JumpChanged()
	while HoldingSpace do
		if not Jumping then
			Jumping = true
			
			Force.Force = Vector3.new(Force.Force.X, 1000, Force.Force.Z) -- increase the Y force by 1000
			
			repeat task.wait() until PlayerHasFinishedJumpAndIsBackOnTheGround -- dont know how to detect once the player is back on the ground
			
			Jumping = false -- player is on the ground! let us jump again!
		end
	end
end

UserInputService.InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = true
		
		JumpChanged()
	end
end)

UserInputService.InputEnded:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = false
	end
end)
1 Like

Hey!

You can use a vectorforce, bodyforce, velocity and a pulse on an object.

By modifying certain values you can create many amazing things!

1 Like

Also, you can try this script:

local UserInputService = game:GetService("UserInputService")

local HoldingSpace = false
local Jumping = false

local function isPlayerOnTheGround() 
    return false
end

local function JumpChanged()
	while HoldingSpace do
		if not Jumping then
			Jumping = true
			Force.Force = Vector3.new(Force.Force.X, 1000, Force.Force.Z)
			repeat
				task.wait(0.1)
			until isPlayerOnTheGround()
			
			Jumping = false
		else
			task.wait(0.1)
		end
	end
end

UserInputService.InputBegan:Connect(function(Key, Processed)
    if not Processed and Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = true
		JumpChanged()
	end
end)

UserInputService.InputEnded:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = false
	end
end)

You can use ApplyImpulse to give the bike instant velocity upward, also to detect when the bike is on ground you can use raycasting

2 Likes

The question I’m asking is how would I detect if the player is on the ground? I don’t understand, you just copy and pasted my original script and added a function?

ApplyImpulse works well, but the bike tips forward instead of staying upright. The bike is massless, however.

Try using LinearVelocity or AssemblyLinearVelocity of a part.

Apologies for the delayed response. I tried using this and I think that ApplyImpulse applies a better jumping effect since it is more instant, and it feels more natural than LinearVelocity. Besides this, even with the linear velocity, the bicycle still tips forward as shown in the video, which is what I’m now trying to solve

I think it’s because player is not at the center. Try to center the player or make another force to neutralize it.

I made the Player massless and made sure the force was being applied to the center of mass as I was applying it to only the center of the model. It works fine, but whenever the bike is in motion, it will tip forward again. It only happens a bit when I release the W key before jumping, but it happens often if I am still holding W after the jump. I also can’t make the Player massless permanently, because that interfere with other scripts that need the character’s mass, so I am still looking for an alternative solution

I am also looking for ways to make the bicycle stop bouncing when it reaches the ground after a jump. I want it to land perfectly and stop moving

I’m looking for something similar to this game. I can’t figure out how they did it.

This bike doesn’t bounce when landing, or tilt forwards

It can move forward and jump at the same time without tilting forwards

Compared to this:

This is the basis of my bike:

I don’t know if my bike is setup in the same way that the one shown in the top videos is, but it’s all I could think of how a bike would be setup. Here is a link to the scripts shown under Drive. I used them from a pre-existing model since I don’t know how to do it myself, and it would be too time-consuming.

Bike FE Script
Bike Steering (parented under Bike FE script)
Create Bike Motors
Lean Animator

You can fix the bouncing by making the Wheels’s CustomPhysicalProperties Elasticity to 0 and ElasticityWeight to 100

About the tilting forward when jumping, I’m pretty sure it occurs because the VectorForce applies the force above the bike’s center of mass which causes the bike to tilt, even if u turn on VectorForce’s ApplyAtCenterOfMass property, it will apply the force at the bike assembly’s center of mass which does not include the wheels, this is because the assembly only includes parts that are rigidly connected with joints like WeldConstraint, RigidConstraint, Weld, Motor, Motor6D and other rigid joints, but not constraints like HingeConstraint, BallSocketConstraint, PrismaticConstraint, etc

You can fix the tilting by turning off the VectorForce’s ApplyAtCenterOfMass property and putting the attachment at the center of mass of the whole bike, the easiest way to do this is probably with a script that automatically calculates the center of mass and puts the attachment where it needs to be

local Model = Script.Parent -- put the reference to your bike into this variable
local VectorForce = Model.Drive.VectorForce -- put the reference to the vector force of your bike into this variable

local CenterOfMass = Vector3.zero
local TotalMass = 0

for _, v in pairs(Model:GetDescendants()) do
	if v:IsA("BasePart") then
		CenterOfMass += v.Mass * v.CFrame:PointToWorldSpace(v.CenterOfMass)
		TotalMass += v.Mass
	end
end

CenterOfMass /= TotalMass

VectorForce.Attachment0.WorldPosition = CenterOfMass
1 Like

Update on this, sorry for the bump. Decided to use this BMX system instead: Giving out my bike system

Thanks for all the help to those who did

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.