|
| 06 Feb 2017 02:41 PM |
| How would one raycast velocity to generate a bullet..? |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 02:47 PM |
@Soybeen I know your there, please help me :C
A bullet using velocity... <-- I've done it using tween but that inefficient... |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 02:47 PM |
What do you mean by raycasting velocity? You could lerp the bullet between the startpoint and destination
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 02:49 PM |
I do, but I basically want to using velocity... for efficiency.
Here join me: https://www.roblox.com/games/625675133/Lerp-Bullets |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|
|
| 06 Feb 2017 02:51 PM |
| Yea, but getting the direction and stuff is my issue and keeping them going perfectly straight. (Using the mouse, not like lookvector) |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 03:00 PM |
-- this will give you some unavoidable bullet drop
local player = game.Players.LocalPlayer local tool = script.Parent local mouse = player:GetMouse()
tool.Activated:connect(function() local bullet = Instance.new("Part") bullet.Size = Vector3.new(1,1,1) bullet.CFrame = CFrame.new(tool.Handle.Position,mouse.Hit.p) bullet.CustomPhysicalProperties = PhysicalProperties.new(0,1,0,1,0) bullet.Velocity = mouse.Hit.p.unit*1000 bullet.Parent = workspace end)
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:01 PM |
| Is there a way to raycast this bullet so I can set the debris for the speed and distance..? |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 03:05 PM |
No reason to raycast here when you can detect .Touched of the bullet. As soon as the bullet touches something, remove it.
Alternatively you can work out the magnitude between yourself and the mouse.Hit.p, and use the speed of the part (the *1000 we multiplied the unit vector by) to determine when it should reach its destination travelTime = distance/speed i.e. travelTime = (handle.Position-mouse.Hit.p).magnitude/1000
and if it hits something on its way then just remove it anyways
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:05 PM |
| throw script 100% credit to EviLDonutNoob function ############### local a=-196.2 local t=.3 --TIME IT TAKES FOR BULLET TO REACH MOUSE local v=Vector3.new( ################# ######################### ################ ) print(v.magnitude) local part=Instance.new('Part',workspace) part.Shape='Ball' part.BrickColor=BrickColor.new('Dark green') part.CanCollide=false part.Size=Vector3.new(1,1,1) part.CFrame=CFrame.new(pos0) part.Velocity=v end local pl=game.Players.LocalPlayer local mo=pl:GetMouse() mo.Button1Down:connect(function() throw(pl.Character.Head.Position,mo.Hit.p) end) |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:06 PM |
REPOST
paste bin . com / NQjwQGx4 |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:11 PM |
local player = game:GetService("Players").LocalPlayer local tool = script.Parent local Speed = 1000
tool.Equipped:connect(function(mouse) local User = tool.Parent mouse.Button1Down:connect(function() local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300) local Hit,Position = workspace:FindPartOnRay(ray, player.Character, false, true) local Distance = (tool.Handle.CFrame.p - Position).magnitude local bullet = Instance.new("Part") bullet.Size = Vector3.new(1,1,1) bullet.CFrame = CFrame.new(tool.Handle.Position,Position) bullet.CustomPhysicalProperties = PhysicalProperties.new(0,1,0,1,0) bullet.Velocity = mouse.Hit.p.unit*Speed bullet.Parent = workspace game.Debris:AddItem(bullet,Distance/Speed) end) end) |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:14 PM |
| How would I make the bullet go downward toward the mouse, as it just goes straight as if it was lookvector... |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:15 PM |
I modified your script here test it
pastebin . com / JQm5KfpJ |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:16 PM |
| ^ Don't use pastebin... thanks anyways... :/ |
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 03:39 PM |
Downward toward the mouse? I'm not really sure what you mean.
Also pastebin is very useful
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:44 PM |
--Looking down makes the bullet go down, so it goes up and down and whatever toward the mouse...
local player = game:GetService("Players").LocalPlayer local tool = script.Parent local Speed = 1000
tool.Equipped:connect(function(mouse) local User = tool.Parent mouse.Button1Down:connect(function() local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300) local Hit,Position = workspace:FindPartOnRay(ray, player.Character, false, true) local Distance = (tool.Handle.CFrame.p - Position).magnitude local bullet = Instance.new("Part") bullet.Size = Vector3.new(0.2,0.2,0.2) bullet.Shape = 'Ball' bullet.CanCollide = false bullet.BrickColor = BrickColor.new('New Yeller') bullet.Material = 'Neon' bullet.CFrame = CFrame.new(tool.Handle.Position,Position) bullet.CustomPhysicalProperties = PhysicalProperties.new(0,1,0,1,0) local velocity = Instance.new('BodyVelocity',bullet) velocity.Velocity = mouse.Hit.p.unit*1 bullet.Parent = workspace game.Debris:AddItem(bullet,Distance) end) end) |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 03:45 PM |
Right, the bullet should always go towards the mouse, no?
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:54 PM |
| I already posed my code on your other multi page post. |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 03:54 PM |
| To the mouse's hit, with this the x and z work and the y only works going upwards. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 04:01 PM |
I guess I'm just very confused when you say that the y only "works going upwards." Is the target above you? Are you shooting directly up? Affecting the velocity requires the part to be unanchored, affecting it through a BodyVelocity would pull the part in undesirable directions. Check the old Roblox rocket's method of propulsion. I believe it uses BodyMovers, but in my experience BodyMovers will subject your part to undesirable movement patterns when you think it should be linear.
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2017 04:03 PM |
| No the part doesn't go down if the mouse is down (on the floor), it just goes in that direction. :/ |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 04:06 PM |
That's how gravity works, right? Hard to have any bullet drop if you're shooting towards earth's center mass
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 06 Feb 2017 04:08 PM |
Testing it for myself and I can see the issue you are describing, it's odd and I'm not sure why it's occurring
|
|
|
| Report Abuse |
|
|