|
| 27 Dec 2012 08:19 PM |
I have a question about this peice of code:
function fire(v)
Tool.Handle.Fire:play()
local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter)
local missile = Instance.new("Part")
local spawnPos = vCharacter.PrimaryPart.Position
spawnPos = spawnPos + (v * 8)
missile.Position = spawnPos missile.Size = Vector3.new(1,1,1) missile.Velocity = v * 100 missile.BrickColor = BrickColor.new(colors[math.random(1, #colors)]) missile.Shape = 0 missile.BottomSurface = 0 missile.TopSurface = 0 missile.Name = "Paintball" missile.Elasticity = 0 missile.Reflectance = 0 missile.Friction = .9
local force = Instance.new("BodyForce") force.force = Vector3.new(0,90,0) force.Parent = missile Tool.BrickCleanup:clone().Parent = missile
local new_script = script.Parent.Paintball:clone() new_script.Disabled = false new_script.Parent = missile
local creator_tag = Instance.new("ObjectValue") creator_tag.Value = vPlayer creator_tag.Name = "creator" creator_tag.Parent = missile
missile.Parent = game.Workspace
end
If you can see in this code there is the vaqriable spawnpos. Now there is a line saying spawnpos = spawnpos + (v*8). what is v? More importantly why isnt the function run on the mouse!
dailyUSERNAME |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2012 08:20 PM |
| Disected for the paintball gun. I get HOW the guns work just not why the function is run on v, and what is "v". |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 27 Dec 2012 08:25 PM |
| v is the argument passed to the function when fire() is called. |
|
|
| Report Abuse |
|
|
| |
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 28 Dec 2012 12:27 AM |
| Hard to guess without knowing what data type v is. Check to see what is passed when the function is called and post it here. |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Dec 2012 12:20 PM |
In this paintball script, v is the direction of where you are aiming in Vector3. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 12:22 PM |
| Hard to understand, So "v" can be used in any script to define the direction where you are aiming at. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 01:09 PM |
| Hmm. Better leave off the gunscripts until I get done building the map! |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 28 Dec 2012 01:56 PM |
Ooh, now I understand.
When the fire() function is called, the script gets the unit vector of where you are aiming, and then the fire function takes that unit vector and goes out along it 8 units, so that the paintball doesn't hit the gun when firing. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 05:17 PM |
| Ok. But can I use "v" to set vector in ANY script. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 05:19 PM |
| I understand the script now. BUT not what "v" is. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 05:25 PM |
v is a variable passed on to the function. It could be "tehvelecccityoftehammmmmmmmmmmmer" for all the script cares, as long as it is named consistently.
-~Obly of C&G~- |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 05:34 PM |
| Oh, Silly me. Well a variable that has no value and consists of a value :P. Thanks |
|
|
| Report Abuse |
|
|