Need help tilting the character using BodyVelocity

I want to create a grappling system using BodyVelocity. The problem is that I want the character to be able to tilt left or right depending on their key. Currently, it seems to have no effect.

https://gyazo.com/04e75b66c735e0194c15c37ed9e75d97


API.shootBullet = function(Box)
	local newBullet = Box.PrimaryPart.Bullet:Clone()
	Box.PrimaryPart.Shooter.Beam.Attachment1 = newBullet
	newBullet.Parent = Box.PrimaryPart
			
	local startPos = Box.PrimaryPart.Shooter.WorldPosition
	local endPos = startPos + Mouse.Hit.LookVector * DMGSettings.BulletSpeed
	local ray = Ray.new(startPos, (endPos - startPos).Unit * DMGSettings.BulletSpeed)
	local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, {Character})
	
	if hit then
		newBullet.Parent = hit
		newBullet.WorldPosition = pos
		newBullet.Orientation = Character.PrimaryPart.Orientation
		
		State = "Following"
		
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.MaxForce = Vector3.new(1,1,1) * 1000
		BodyVelocity.Velocity = CFrame.new(pos).RightVector * 100
		BodyVelocity.Parent = Character.PrimaryPart
		
		coroutine.wrap(function()
			local Velocity = (pos - Box.PrimaryPart.Shooter.WorldPosition).Unit * DMGSettings.BulletSpeed / 4
			while State == "Following" do
				wait()
				if UserInputService:IsKeyDown(Enum.KeyCode.D) then
					--Velocity = Velocity * DMGSettings.BulletSpeed + CFrame.new(pos).RightVector * -20
				elseif UserInputService:IsKeyDown(Enum.KeyCode.A) then
					--Velocity = Velocity * DMGSettings.BulletSpeed + CFrame.new(pos).RightVector * 20
				else
					Velocity = (pos - Box.PrimaryPart.Shooter.WorldPosition).Unit * DMGSettings.BulletSpeed / 4
				end
				
				Character.PrimaryPart.Velocity = Velocity
				--BodyVelocity.Velocity = Velocity
			end
		end)()
	else
		local newPart = Instance.new("Part")
		newPart.Anchored = true
		newPart.CanCollide = false
		newPart.Transparency = 1
		newPart.Position = endPos
		newPart.Parent = game.Workspace
		
		newBullet.Parent = newPart
		newBullet.WorldPosition = newPart.Position
	
		--> If you didn't hit anything reset state
		delay(.25, function()
			State = "N/A"
			newPart:Destroy()
			newBullet:Destroy()
		end)
	end
end

As you can see, I’ve tried editing the character’s primary part velocity, I’ve tried adding RightVector relative to the hit position and etc.

EDIT: I’ve noticed that 2 BodyVelocity will work against each other, the new one overlaps the old one.

1 Like

If you’re trying to tilt something then, wouldn’t you want to use rot-velocity? Or body-angular velocity?

2 Likes

Then try adjusting the velocity of the first bodyvelocity, and force move the character directly. Ex: if a or left pressed then character.cframe = character.cframe*(5,0,0)
(Obviously this is pseudo code).
Also, look into bodyposition, that moves an object from one position to another whereas bodyvelocity moves it in a direction. Pretty sure that’s what you’ll have to use to do what you want ex: a body positon parented to primarypart, bodyposition.position = hit.position (of course you’ll have to tweak the other values of bodyposition so it moves at the speed you want)

1 Like

These body movers rotate the character itself, what I’m trying to do is apply force on one side of the character. The goal is for the character to be able to circle around the tower.

2 Likes

Moving the character directly will make a glittering effect and is not appealing to the eye. I’ve looked into bodyposition and it will not help me achieve what I want to do. BodyPosition will directly move the character to the position and it’s at an inconsistent rate which are things I want to avoid.

EDIT: Adding any offset to the BodyPosition’s Position will also not work because the position is the end goal

1 Like

If you move it at small intervals over time, it’ll look the same. That’s how all moving works. so do something like while a or left pressed move 0.01 wait().

No, it moves it at a fixed rate, and how fast it moves can be tweaked.

It doesn’t just do endgoal, it does current position to end goal. I missed to say that when you update character’s position, update bodyposition’s position as well.

1 Like

https://gyazo.com/9b7ca4e8eda0753add72e6c1647b4c81

Moving at 1 stud every wait()

while true do 
wait() game.Workspace.Mystifine:SetPrimaryPartCFrame(game.Workspace.Mystifine.PrimaryPart.CFrame * CFrame.new(0,1,0)) 
print("and") 
end

Moving at 0.01 stud every wait() does nothing

The overall speed is the same but the movement is sine or something like that, it’s clear that the part slows down upon reaching the target. I’ve also noticed an odd moving pattern, I expected it to move diagonally to the target (shortest distance)

https://gyazo.com/6a4fb38902675e8d37a7785bd1f4c8c3

This is something I’ll look into

Thanks

1 Like

Then try a higher value, I used that as an example. Try 0.1 or 0.2 etc.

It appears you’re right here. So back to what I initially said then, move the character then re-calculate the direction they have to move in and update the bodyvelocity’s velocity to that direction.

I don’t know for sure if the speed decrease with bodyposition can be dealt with, I’ll have to play around with its other properties and see what they do.

1 Like

I’ve already tried 1 stud as an example:
https://i.gyazo.com/9b7ca4e8eda0753add72e6c1647b4c81.mp4

Again thanks, I’ll look into what I can do.

1 Like

Try a smaller value. I’m using small values as examples for a reason.

1 Like

I think we are in a loop

30characters

1 Like