Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 02 Mar 2014 09:04 PM |
So, I'm trying to make it so that when you click you shoot a beam towards the target and the Beam's size is the distance, and the max distance is 50, and it's position is the midpoint of you and the target position.
When I use Raycasting for it, it makes the beam's start (the part that should be one you) be AT the target, going towards the direction it should be going in.
I've tried messing around with all the numbers but nothing is working.
local Ray = Ray.new(script:findFirstChild("MC").Value:findFirstChild("Big"):findFirstChild("Center").CFrame.p,(Targ - script:findFirstChild("MC").Value:findFirstChild("Big"):findFirstChild("Center").CFrame.p).unit * 500) local hit,position = game.Workspace:FindPartOnRay(Ray,game.Players.LocalPlayer.Character) if hit and hit.Parent then Distance = (position - script:findFirstChild("MC").Value:findFirstChild("Big"):findFirstChild("Center").CFrame.p).magnitude/2 end
local direction = Targ - game.Players.LocalPlayer.cHaracter:findFirstChild("Torso").Position direction = computeDirection(direction)
missile.CFrame = CFrame.new(position, script:findFirstChild("MC").Value:findFirstChild("Big"):findFirstChild("Center").CFrame.p) * CFrame.new(0, 0, -Distance/math.pi + Extend/2)
Any ideas? |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 02 Mar 2014 09:05 PM |
Maws is the mouse
Extend is 3
Targ = Maws.Hit.p
Where it says, MC, it should be the character's torso, not that. I already fixed.
computeDirection:
function computeDirection(vec) return Vector3.new(vec.x * (1 / math.sqrt(vec.magnitude * vec.magnitude)), vec.y * (1 / math.sqrt(vec.magnitude * vec.magnitude)), vec.z * (1 / math.sqrt(vec.magnitude * vec.magnitude))) end |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 02 Mar 2014 09:06 PM |
Make the ray start at the part the beam is coming from. If it's not coming from anywhere in particular, try the user's torso (the user that is clicking).
~ Non simpliciter Latinam legere ~ |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 02 Mar 2014 09:07 PM |
| @dekkonot It's already doing that. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 02 Mar 2014 09:09 PM |
Hm. So you say the beam is starting at the target's torso, and not where it should?
~ Non simpliciter Latinam legere ~ |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 02 Mar 2014 09:10 PM |
Yes.. Me.......................................................Them ======================> |
|
|
| Report Abuse |
|
|
trogyssy
|
  |
| Joined: 29 Oct 2010 |
| Total Posts: 2322 |
|
|
| 02 Mar 2014 09:13 PM |
| Seardh the wiki for "How to make a Raycast Gun" -.- |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 02 Mar 2014 09:15 PM |
It's not a gun.
I did.
I'm doing something different than what they are doing.
Please actually read posts. |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
| |
|