KasakuKun
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 1060 |
|
|
| 28 Dec 2015 06:44 PM |
So, how do I create a bullet that only shoots on the 2D Axis? Excluding the Z.
|
|
|
| Report Abuse |
|
|
|
| 28 Dec 2015 06:46 PM |
Get Mouse.hit and create a new vector out of it using only the X and Y properties.
local mousePos = Mouse.Hit.p -- Make a new vector that ignores the Z axis local newPos = CFrame.new(mousePos.X, mousePos.Y, 0) |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2015 06:48 PM |
I'm not quite sure; but its possibly something along these lines;
local player = game.Players.LocalPlayer repeat wait() until player.Character local mouse = player:GetMouse() mouse.Button1Down:connect(function() local mouseCFrame = mouse.Hit local twoD_CFrame = CFrame.new(mouse.Hit.Y,mouse.Hit.X,0) local bullet = Instance.new("Part", workspace) bullet.CFrame = twoD_CFrame*CFrame.Angles(mouse.Hit.p) end) |
|
|
| Report Abuse |
|
|
KasakuKun
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 1060 |
|
|
| 28 Dec 2015 06:52 PM |
| I think I got it now, Thanks. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2015 06:57 PM |
Ah, this one works; I just made it in studio.
local player = game.Players.LocalPlayer repeat wait() until player.Character local character = player.Character local mouse = player:GetMouse() mouse.Button1Down:connect(function() local mouseCFrame = mouse.Hit local newCFrame = CFrame.new(mouseCFrame.X, mouseCFrame.Y, 0) local bullet = Instance.new("Part", workspace) bullet.CanCollide = false bullet.CFrame = character.Torso.CFrame bullet.CFrame = newCFrame*CFrame.Angles(mouseCFrame.X, mouseCFrame.Y, 0) local velo = Instance.new("BodyVelocity", bullet) velo.velocity = bullet.CFrame.lookVector*90 velo.maxForce = Vector3.new(math.huge,math.huge,math.huge) end) |
|
|
| Report Abuse |
|
|
KasakuKun
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 1060 |
|
|
| 28 Dec 2015 07:08 PM |
hmm. I can't quite seem to get it to work the way I want it too;
here's my code.
'
local f = Instance.new("Part") local mh = mouse.Hit f.CFrame = prt.CFrame*CFrame.new(0,0.3,-3) f.CFrame = CFrame.new(f.Position, mh.p) --this is the specific line. local fbv = Instance.new("BodyVelocity",f) fbv.velocity = f.CFrame.lookVector * 120
' |
|
|
| Report Abuse |
|
|
KasakuKun
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 1060 |
|
|
| 28 Dec 2015 07:13 PM |
f.CFrame = CFrame.new(f.Position, mh.p)
anybody????????????????? |
|
|
| Report Abuse |
|
|
KasakuKun
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 1060 |
|
| |
|
|
| 28 Dec 2015 07:47 PM |
local newVector = f.Position f.CFrame = CFrame.new(newVector.X,newVector.Y,0),mh.CFrame.p) |
|
|
| Report Abuse |
|
|
KasakuKun
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 1060 |
|
| |
|