I am working on a Bow tool and I need it to shoot arrows that don’t just go straight but have gravity actually effect it
Right now I have a tween solution that tweens to the end
I have no idea how else to do it
Ideas?/
I am working on a Bow tool and I need it to shoot arrows that don’t just go straight but have gravity actually effect it
Right now I have a tween solution that tweens to the end
I have no idea how else to do it
Ideas?/
why not use FastCast instead?
I think you misunderstood
I am not trying to detect a hit
I am trying to figure out the path for a arrow and how I should move it along the path.
What I suggest is get the direction first basically like if you’re clicking somewhere to where you want to the arrow to shoot at it can be defined as the end position then you get the start position which is where the player is at or the bow, subtract the end position by start position define it as direction then make a variable called force and make it equal the direction + vector3.new(0,workspace.Gravity/2,0) then lastly for the arrow just do arrow:ApplyImpulse(force * arrow.AssemblyMass) since I’m not on pc rn couldn’t give a code sample but what this does is instead of making it shoot straight it’s gonna get affect by gravity so it’s gonna go up in a curve then back down being affected by gravity.
Or you can just learn more about it and get what you’re looking for in this video he does a very good job explaining something similar of what you’re talking about if not exactly. Surprisingly I watched it earlier today and made something from what I’ve learnt
you will probably have to use trig
I have 2 variables
power(how strong, 0.5-10, based on how LONG you pull back)
and direction
nothing else
I want the bow to not just have perfect aim lmao I want it to actually require aiming, no just set end position
what do you mean by trig what is that??
Hello. I hope this is helpful. To simulate projectile movement using only power and direction, you can do it in two ways:
If you’re using Roblox physics, then it’s like this:
BasePart:ApplyImpulse()
in the direction of force, multiplied by the power.Touched
event to see where the arrow hits.That’s the straightforward approach, although rather naïve. If you do that you might notice that it’s not really the best way to go about it, especially if you want a reliable way to fire arrows. You’ll end up having to deal with somewhat weird collisions, and there’s also NetworkOwnership and security because of how Roblox handles physics replication.
So I suggest doing it programmatically, this involves some more advanced scripting. You will use something called Raycasting. Ideally, you can just use FastCast to avoid doing the heavy lifting of scripting the system yourself. There’s a very helpful tutorial (here) showing you how to do it. It’s a tutorial for a gun, but you can easily just use a Bow model and an Arrow for the bullet, tweaking the Velocity value to be your Direction * Power.
But to complete my answer here and guide you with how to do just that, here:
Heartbeat()
or RenderStepped()
.Vector3.new(0, -workspace.Gravity * DeltaTime, 0)
to your direction vector.Also, trig means trigonometry. You may need it when calculating the projectile motion, depending on how you’re getting the direction of launch.