# Converting Attachment VectorForce to World

1. What do you want to achieve?
I have a VectorForce with specific rotation that keeps changing in a RunService loop. I want the force that is applied here to be converted to World Axis

2. What is the issue? Include screenshots / videos if possible!
I’m making a leap system, where you press space and just yeet yourself forwards, like the Hulk. problem is, If I turn myself mid-air, the direction of the force applied changes. I want the direction of the force to stay constant, for which I have to use World Axis on my VectorForce instance.

``````-- dummyforce "Attachment" is an attachment I only perform rotation on and take worldcframe from.
-- force is actually applied in world axis on the forceInst "VectorForce" instance.

dummyAtt.Orientation =
v3(direction.Position,0,0)

forceInst.Force =
dummyAtt.WorldCFrame.UpVector
* speed.Position
* mult /28
``````

However the above only seems to work when I’m jumping towards the X Axis in World.

Help is appreciated very much. Thanks

2 Likes

Don’t use a world axis! This is why it only works in one direction.

Put a strong VectorForce in the forward and up direction of the player’s HumanoidRootPart but only for a very short time. If you keep applying the Force for any length of time in the HumanoidRootPart it’ll change if you rotate.

VectorForce explains how to apply the Forces at the Attachment0.

2 Likes

My system needs that constant force. That’s why I need the force direction to stay constant and not just as an impulse forward and upward. I get what you’re saying though.

I know the concept of Attachment and World based Forces. What I’m struggling at is the vector math.

Why can’t you use the world axis? And what do you mean by “only works in one direction”. I disagree.

1 Like

I am using the world axis, but I find it easier to change direction of a local force and only apply force in code as `v3(0, Force, 0)`
What im looking into is converting this force taking into consideration the orientation of the attachment to a world space force.

Here’s a video with the code provided in the parent post.

If you want the vector force to be based on world space then change the vectorforce property???

1 Like

It’s not that simple. If I have a rotated attachment deciding a vectorForce’s direction, then if I just set it relative to World, it will work on one axis. Z value in local direction would take up any one value in world direction. It does not take player’s LookVector into account. And since I’m updating this force direction on RunService, I would have to find a way to change the direction on this vector3 which would be world based.

I mean it is that simple, if the vectorforce is world based then it won’t take into account the orientation of the attachment.

1 Like

Agreed, but I’m controlling the direction of the attachment which makes it easier to control the trajectory as a developer.

``````local direction = Spring.new(-30)
direction.Speed = 2
direction.Target = -180
``````

This here represents Theta in the minus Z, which is forward. It decreases this angle and provides force in local space.

Changing directions in world space is something I haven’t worked with. So I asked if there was a way to translate.

If you know the unit vector of where you want to go, it’s as simple as multiplying the unit vector by the desired length (force):

``````-- Multiply by (1, 0, 1) to remove the Y axis
local force = ((unitVector * length) * Vector3.new(1, 0, 1))

-- Add Y axis force here
``````

I’m not entirely sure what you’re doing, but I believe the unit vector in this case is:

``````-- I'm guessing this is where you're looking, but I could be wrong
dummyAtt.WorldCFrame.LookVector
``````
2 Likes

There’s small value changes I will have to make, but this has pointed the right way. Thanks a lot!

1 Like