Difference Between Velocity & Position

Hello, I’m trying to put a part in a certain position. The issue at hand is when I use BodyVelocity to make my player move towards a specific position it works perfectly fine but now that I instance a part to try to show where the position the player is moving towards it doesn’t spawn in the correct position. As you can see in the code below at line 364 if I was to uncomment the line out it’ll push my player in the correct position that I want but if I now make a part using the same position in line 364 it doesn’t place it in the correct position even though I didn’t change anything. I change the parts position in line 376. Any help is greatly appreciated thank you all :+1:

bumping because im still struggling with this

hey can you clarify your problem a bit more, its a bit unclear on what u want

Yes, so basically when I use BodyVelocity the velocity in where I want my player to go in this situation is towards the right. Now instead of me using BodyVelocity I want to spawn a part in the direction that the BodyVelocity is headed towards but when I spawn a part and update its position it doesn’t spawn in the direction that the BodyVelocity is going towards even though I’m using the same CFrame/Vectors.

ok

  1. use LinearVelocity instead of BodyVelocity as BodyVelocity is deprecated and it is advised not to use it
  2. for your velocity, thats just the direction. to get the target, you would need to add the direction to the player’s current position. i believe that would get the desired result

Okay, I’ll use LinearVelocity but using the code in above would I add the players position like this?

hrp.Position + (CFrame.new(hrp.Position,Vector3.new(goal.Position.X,hrp.Position.Y,goal.Position.Z)) * CFrame.new((verySlow_Movement),0,-.5)).Position - hrp.Position

huh? thats far more complicated. all you want is the put the part in the direction of the velocity correct? you would just do hrp.Position + velocity.VectorVelocity for linear velocity.

Thanks so much my brotha really appreciate it

no problem! feel free to ask anything else. also linear velocities require an attachment in the part to work. this means that you can apply the force anywhere on the object. additionally, linear velocities can be applied relative to the part by setting the relativeto property to attachment0 (or attachment1). this essentially means that it will move the part based on its orientation ex. if you set the force to 1,0,0 it will always move the part to its right

1 Like

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