Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there a better way to move my projectile than BodyPosition?

Asked by 4 years ago
Edited 4 years ago

I tried using BodyPosition, which works ok but the thing is with BodyPosition when I click on something the projectile doesn't travel in a straight path (or if i dont click on anything the projectile flings itself to who knows where)

Here's what I used:

projectile.BodyPosition.Position = Mouse.hit.Position

I don't think BodyVelocity will work either, because I don't want the projectile to just go forward in the direction the player is facing, but for it to be shootable in any direction (towards the mouse).

I also don't think raycasting will do the job either (Although I may be mistaken) because everything i've seen on raycasting so far just shows like a laserbeam towards the mouse that disappears after a second and not really anything projectile based.

So, is there a better way to move my projectile? If so, what?

edit: I also don't want it to travel in an arc either

0
BodyVelocity travels in world axis. If you know what direction vector the projectile will be moving in (in your case, the vector unit of the position the mouse is pointing at MINUS the character's position), you can multiply that value by a speed and the BodyVelocity will apply force to the part in that direction. pidgey 548 — 4y
0
A pseudo-example could be: BodyVelocity.Velocity = (Mouse.hit.Position - Handle.Position).Unit * SPEED --handle would be the base of whatever your using to shoot the projectile with pidgey 548 — 4y
0
wow TheluaBanana 946 — 4y
0
@kamoojan the legend TheluaBanana 946 — 4y
View all comments (2 more)
0
I use this "BodyVelocity.Velocity = CFrame.new(Handle.CFrame.p + Handle.CFrame:vectorToWorldSpace(Vector3.new(0, 0.4, -1.1)), Mouse.Hit.p).lookVector * 100 --[[ Speed ]]" OnaKat 444 — 4y
0
@pidgey @OnaKat thank you guys a ton kamoojan 10 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

It is possible to "segment" rays to get a projectile speed effect. The projectile (ray) travels 10 studs (in this example) then stops, if it doesn't hit something it continues where it stopped. If however it does hit something it will stop.

I don't remember how to do this on the top of my head but i recommend that you should look into raycasting.

1
thank you kind gamer kamoojan 10 — 4y
Ad

Answer this question