BodyVelocity in the direction of a part

I want to set my bodyvelocity in the direction of a part but I’m not sure how? I might be missing something really simple but I want my character to have the bodyvelocity I made set to move at a part no matter wich way I face etc, thanks.

2 Likes

Are you asking to make the part to move towards another part at the same direction or to move the part to the other part’s position? Sorry I’m a bit confused about your question.

I want my HumanoidRootPart’s BodyVelocity that I added to move toward another part no matter what angle I’m facing at a chosen speed.

BodyVelocity.Velocity = part.CFrame.LookVector*25

this code would make the body velocity’s velocity move at the direction that the part is facing by 25 studs

I tried this already and it had weird results when turning your camera I can retry it though

Confirmed this does weird things

thats weird could you show what the problem when you use that in a video since its working great for me

You would want to add a Body Gyro in that case to make sure its facing the part.

I said without doing this I already did that and it works but I don’t want to do that

When I turn my camera it makes me go backwards away from the part instead of toward it,

Let’s say we have two parts, Part1 and Part2 and we want to move part1 towards part2

local Direction = (Part2.Position - Part1.Position).Unit —this will give you the direction towards part2
Part1.BodyVelocity.Velocity = Direction * 120 —120 being a speed at which it will move

Typed this on phone so pardon any errors also I may have the subtraction order backwards and one last thing sorry about the comments iPhone doesn’t like the - -

6 Likes

Hmm have your tried using Body Positions? It will move you towards the Object regardless of what direction your looking at.

I’m trying sirens answer, bodyposition doesn’t work for what I’m doing

1 Like

So this actually works, thankyou. Can you explain why it gives you the direction by getting the difference between the 2 parts?

1 Like

So you can think of it like Dir = Vec3.new(B.X - A.X, B.Y - A.Y, B.Z - A.Z) it essentially just tells you how far each point must travel to reach destination B from point A

So
A = Vec3.new(3, 0, 6)
B = Vec3.new(-2, 0, 3)
Dir = Vec3.new(-2-3, 0-0, 3-6) or (-5, 0, -3)
.Unit normalizes said direction vector to a magnitude of 1 making it easier to manipulate in this scenario

2 Likes

alright thankyou

ssssssssssssssssssssssssssssss