Look Vector Going Wrong Way?

Hello! I’m trying to get a projectile (Bowling ball) to fire at a certain speed, with the look vector of the Camera Part. One problem though, It’s going in the wrong direction. I want it to go based on the front of the part, but it seems to go off of the back and go in the opposite direction. I’ve tried a lot of things but none seems to work. Please note in this case the attribute “BallDefaultSpeed” is a number value set to 50, but it may vary from time to time. Anything helps, thanks!

Code:
lookvector = CameraPart.CFrame.LookVector
BallPart.Velocity = lookvector * (speed*BallPart:GetAttribute(“BallDefaultSpeed”))

3 Likes

If it’s going in the wrong direction, just negate it:

lookvector = -CameraPart.CFrame.LookVector
BallPart.Velocity = lookvector * (speed*BallPart:GetAttribute(“BallDefaultSpeed”))
1 Like

It still goes behind me, but just faster.

1 Like

@Pokemoncraft5290’s solution should work. If not, there must be other external factors from the snippet of code you shared that are influencing the outcome.

What is speed defined as? Also, is it possible the ball is bouncing off of something immediately?

2 Likes

I feel so dumb, but it turns out there was an invisible part that was bouncing in front of it immediately.

2 Likes

No don’t feel dumb :slight_smile: Doing things like that is one of the joys of game development debugging. If you need that invisible part to be there and need both that part and the ball to have CanCollide set to true, then you can use CollisionGroups to make sure the two still don’t collide with each other.

1 Like