samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 27 Jun 2014 06:16 PM |
How would I make something shoot out in an arc, what's the easiest way to do this? --It lands where you have clicked and doesn't require clicking a few meters above where you want something to land--
Just an idea please |
|
|
| Report Abuse |
|
|
| |
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 27 Jun 2014 06:23 PM |
| But i thought that casts a straight line between two points o.O |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 06:25 PM |
| Use BodyForce or something like that. |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 06:29 PM |
You can use lots of small raycasts to approximate a parabolic arc.
From mechanics, you can attain:
r = r0 + v * t - 1/2 * g * t ^ 2
where r is the current position, r0 is the initial position, v is the initial velocity, g is acceleration due to gravity (In ROBLOX this is 20 * 9.81), and t is the time since the raycast started. |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 06:29 PM |
| You can lower g if you find it drops too quickly. |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 06:35 PM |
| I had this problem and started looking into the Roblox Slingshot, but it required trig and inverse trig functions(which I am still learning). |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 06:52 PM |
| use RocketPropulsion, change the Cartoon Factor to 1 or more (if am not wrong, it's not a Fraction), also, as it's Target, Spawn a Brick were u Clicked and set it to Anchored, cant Collide etc... I'll tell ya how to do this later, gotta go Sleep... |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 27 Jun 2014 06:59 PM |
| Oh ok, any other ideas? I'd prefer not to use raycasting anyhow seen as i require shooting out a ball shaped figure |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 07:13 PM |
ball.Velocity = initialVelocity
That will do it. If it drops too fast, you can add a BodyForce object to slow its descent. |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 27 Jun 2014 07:18 PM |
| What is initialvelocity? :S |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 07:23 PM |
| That, is calculated by the code used in the slingshot. |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 27 Jun 2014 07:28 PM |
A sling shot requires that you aim a bit above your target for it to hit there.
I want it to shoot in an arc formation and land literally where you clicked.
What do i do to achieve this? |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 07:50 PM |
| The slingshot has a link to a Wikipedia article. Read that. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 07:55 AM |
an example Script in a LocalScript:
tool = script.Parent plr = game.Players.LocalPlayer mouse = plr:GetMouse()
tool.Activated:connect(function() --Activated is short for Equipped and MouseButton1Down --all the line here for the Slingshot Ball target = Instance.new('Part') target.CFrame = mouse.Hit.p --more line about Target, for it being Transparent, not Collidable etc rp = Instance.new('RocketPropulsion', ball) --just say u named it 'ball' rp.Target = target rp.Cartoonfactor = 1 --just for now, if it's not a Fraction then change it to higher maybe http://wiki.roblox.com/index.php?title=How_To_Make_Homing_Objects. rp.MaxVelocity = --change to ur needs --http://wiki.roblox.com/index.php?title=How_To_Make_Homing_Objects. rp:fire() --if ya needa stop the ball for some reason, do :abort() end) |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 08:02 AM |
| sry meant http://wiki.roblox.com/index.php?title=CartoonFactor for CartoonFactor |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 28 Jun 2014 09:19 AM |
I tried it, it shot straight towards my object (this is actually useful in the future thanks!)
However, i still need help on creating an arc for it to follow, so far i've got this but it doesn't adjust when one point is higher than the other.
Workspace.Terrain:ClearAllChildren()
firstpoint = CFrame.new(0,0,0) height = 20 secondpoint = CFrame.new(30,0,0) g = Workspace.Part
for i = 0,180 do
x = (i/(180/secondpoint.X)) y = math.sin(math.rad(i))*height z = (i/(180/secondpoint.Z))
p = g:Clone() p.Parent = Workspace.Terrain p.CFrame = firstpoint*CFrame.new(x,y,z)
if i == 0 then p.BrickColor = BrickColor.Red() end
end |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 09:20 AM |
| Use body force and change the Y axis. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 09:21 AM |
| There's an example of it in paintball guns. |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 28 Jun 2014 09:33 AM |
Yes but the problem is, this has no accurate way of landing where you clicked, you have to aim it a bit above your target for it to hit.
I want it to hit exactly where I clicked but go up in an arc |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 28 Jun 2014 09:38 AM |
Notunknown99's equation is the equation for Projectile Motion -- The thing you need. Tbh, it took me 10 minutes to install into my gun when I did that like 5 months ago.
You can still follow what other people said tho. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 28 Jun 2014 09:40 AM |
Alright what you said is a bit trickier.
I'ma try to explain that using projectile motion. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
| |
|
|
| 28 Jun 2014 10:04 AM |
I suppose you could use a BodyVelocity moving an Instance.new("Part", Workspace) forward on its X axis coupled with a BodyVelocity forcing it to go down on its Y axis.
>I will rip out your duodenum |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:07 AM |
But for an arc going up then going down? Hm..
You could use the same method, but with an initial BodyVelocity pushing the part up, then halfway that BodyVelocity cancels and a new BodyVelocity forces the part down. Then they cancel out, leaving you with an arc to the original Y axis.
(Sorry, BodyVelocity really isn't my strong suit)
>I will rip out your duodenum |
|
|
| Report Abuse |
|
|