generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Raycasting

Previous Thread :: Next Thread 
Nagrath99 is not online. 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 is not online. 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 is not online. 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 is not online. Nagrath99
Joined: 26 Mar 2011
Total Posts: 1537
02 Mar 2014 09:07 PM
@dekkonot It's already doing that.
Report Abuse
dekkonot is not online. 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 is not online. Nagrath99
Joined: 26 Mar 2011
Total Posts: 1537
02 Mar 2014 09:10 PM
Yes..
Me.......................................................Them ======================>
Report Abuse
trogyssy is not online. 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 is not online. 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 is not online. Nagrath99
Joined: 26 Mar 2011
Total Posts: 1537
02 Mar 2014 09:23 PM
bump


halp qq
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image