Bodygyros, Bodyposition, Bodyvelocity, CFrames, what should I use? And how?

Hey everyone!

I am writing this post as I am simply extremely confused. If you’ve ever seen Attack on Titan before, you’d know this thing called ODM Gear which pretty much uses hooks and launches you towards where you choose to grapple, as seen below.

Video

I’ve looked on many devforum posts, youtube videos, etc, but I can’t figure out at all how people calculate this math and make it work with roblox physics.

I’ve looked at many open sources, but they seem to come with a complicated system of ‘upforcespeed’ and ‘driftspeed’, things I don’t understand why they are being multiplied or calculated, and my goal is to learn, not copy and paste.

If someone is able to explain to me what these things are, the formulas and calculations, and how do I smoothly, incredibly smoothly, move my player and turn them based on their hook. I’ve already figured out how to find the target position and move the hook towards it, but I can’t figure out how to really smoothly move my player towards it.

Please, if you know anything about Roblox Physics, or Physics in General, Velocities, Gyros, etc, give me a hand on this. Just put me to the right direction, as I don’t know where to go from here.

1 Like

You want the character to interact with the enviroment

that scratches off CFrames.

You want the character to naturally accelerate towards the target

that scratches off body velocity which forces a constant velocity. You could find a way to modify the velocity to resemble acceleration but that’ll take more work.

You do not want unsmooth behavior/unrealistic behavior

that scratches of body position which “dampens” the velocity to avoid overshooting the goal. That is not very realistic as this “dampening force” does not exist.

You do know that via physics the rope pulls the character towards a target point from character position to the hooks position.

Hence line force:

https://developer.roblox.com/en-us/api-reference/class/LineForce

However upon experimentation you can only modify the magnitude value. This does not allow you customize how fast horizontally the ODM goes and how fast vertically the ODM goes.

Consequently, vector forces or BodyForce will be the best for customization.

You got the direction vector

local forceDirection = (hookPosition - character.Position).Unit

Now I got lost here, so I searched up a unity tutorial to see if I’m on the right track

Turns out the force equation it’s also the same, grapplePos - character.Position however theres an additional movement in the camera direction to represent the thrusters I believe.

local forceDirection = (hookPosition - character.Position).Unit
local forceStrength = 500
bodyForce.Force = forceDirection * forceStrength 

Also enable humanoid.PlatformStand or else the humanoid will prevent it from moving

7 Likes

@dthecoolest So I should use Lineforces, and to customize it to the best way I can, I use Bodyforces and Vector Forces?

1 Like

Try it out.

I’m not going to guide you step by step, just pointing out what you could do which I do to solve my problems like translating code from unity to roblox. This has worked well for my inverse kinematics project before.

1 Like

Alright, thank you, I’ll give it a try right now then.

1 Like

Hey, Just ran into some minor issues.

I’ve done what you said, and read on lineforces, however right now, it doesn’t do anything, and I can’t seem to figure out why. I’ve done the first part of what you said, so I’m assuming it should move, since the rest of the parts was just to give me more control over configuration.

Here’s the code;

function createLineForce(Parent,A0,A1)
	local Lineforce = Instance.new("LineForce")
	Lineforce.Parent = Parent
	Lineforce.Attachment0 = A0
	Lineforce.Attachment1 = A1
	Lineforce.Magnitude = grappleSpeed
	Lineforce.ApplyAtCenterOfMass = true
	return Lineforce
end

function createAttachment(Parent)
	local newAttach = Instance.new("Attachment")
	newAttach.Parent = Parent
	return newAttach
end

function onLeftVelocity(player,target,TargetParent)
	local newAttach = createAttachment(TargetParent)
	local char = player.Character
	local ODMHolder = char:WaitForChild("ODM").HumanoidRootPart
	local leftDetachment = ODMHolder:WaitForChild("LeftDetacher")
	local LeftHookPiece = leftDetachment.Primary.HookDetachment
	
	local hum = char:WaitForChild("Humanoid")
	hum.PlatformStand = true
	
	local playerAttach = createAttachment(LeftHookPiece)
	local newForce = createLineForce(char,playerAttach,newAttach)
	print(TargetParent)
end

Here’s what happens right now;

Any ideas on how to fix this? :pray:

If it’s not moving then.

Either not enough force

Or line force setup is incorrect perhaps the attachment0 and attachment1 order.

How do I increase the force? and as for the attachments, I’ve parented A0 to the Hook piece (detacher) and A1 to the target aka the odm testing part.