Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 05:39 PM |
This is a simple script that I didnt put much thought into. script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() local fireball = game.Lighting.FireBall:clone() fireball.Parent = game.Workspace fireball.Position = script.Parent.Parent.Parent.Character.Torso.Position + Vector3.new(5, 0, 0) fireball.BodyVelocity.velocity = m.Hit.p end) end)
What it does it it shoots the ball at a position way out in space. Anybody know why? |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 13 Jul 2011 05:49 PM |
script.Parent.Selected:connect(function(m) m.MouseButton1Down:connect(function() local fireball = game.Lighting.FireBall:clone() fireball.Parent = game.Workspace fireball.Position = script.Parent.Parent.Parent.Character.Torso.Position + Vector3.new(5, 0, 0) fireball.BodyVelocity.velocity = m.Hit.p end) end)
|
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 05:56 PM |
| All you did was copy my script and break it by adding 'mouse' in front of Button1Down. Which I dont even need to test to know that it doesnt work. MouseButton1Down is for GUI buttons and stuff. You dont need to put Mouse if its in a hopperbin that already identifies it as a mouse. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 06:04 PM |
| It hits at your mouse's hit position, which is out in space. |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 06:06 PM |
| Oh. Whoops. Thanks but how might I fix that? |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 06:07 PM |
| Give it a set velocity. You don't want variable velocity, that's never good. |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 06:08 PM |
| Wait a second. I thought I couldnt give BodyVelocity a set velocity unless thats where I wanted to shoot the ball every single time. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 06:10 PM |
| You can make the fireball shoot in the direction the player is facing using some math and .lookVector |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 06:12 PM |
| That would work, except for the fact that I want the ball to shoot where the player clicks. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 06:14 PM |
Then you want to index m.Hit.p before you set the velocity. Like this:
firePos = m.Hit.p -- rest of code [bVelocity].velocity = firePos |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
| |
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
| |
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 07:53 PM |
| Bump. This is mainly intended for DingDong since he is the only good scripter on. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 08:03 PM |
| Well what do you want the ball to do, exactly? |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 08:03 PM |
| Like a... let me find a metaphor here... like an iceshard. Wherever you click, it shoots a ball that way. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 08:05 PM |
| Wouldn't you be able to modify a premade paintball gun (you can replace the Handle). The math in there already shoots where you are aiming. And no BodyVelocity is used, it's just the Velocity property of the Part firing. |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 08:06 PM |
| Aha. Good idea. Its a hopperbin though, and spawning normally has to do with the handles position. But no matter, I am on another mission. |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 08:23 PM |
I was looking at the paintball gun script and I came across this. I semi-understand it, but it would help if somebody could explain this.
local targetPos = humanoid.TargetPoint local lookAt = (targetPos - character.Head.Position).unit |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2011 08:27 PM |
humanoid.TargetPoint is where the humanoid is going. lookAt is the distance between the character's head and it's end position. |
|
|
| Report Abuse |
|
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
|
| 13 Jul 2011 08:32 PM |
| I understood that much, but what is .unit? |
|
|
| Report Abuse |
|
|
| |
|