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 Pass Method

Previous Thread :: Next Thread 
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 11:25 AM
function RayCasting()
User = Tool.Parent
Fire = false
local Ray = Ray.new(Tool.Handle.CFrame.p, (clicker.Hit.p - Tool.Handle.CFrame.p).unit*900)
local Hit, Position = game.Workspace:FindPartOnRay(Ray, User)
if Hit then
Fire = true
end end

The wiki is not explaining how I use the...

local Hit, Position

Part to find a part of the ray. I want to fire my gun, and have it stop at any part it hits along it.

It is a laser gun, however, it is not a raycast type of gun, and this is how I make the laser...

part1.Size = Vector3.new(1,1,(pos - obj.Position).magnitude)

part1.CFrame = CFrame.new(((obj.Position + pos)/2) + 1 * (pos - obj.Position).unit, pos)

I need the ray to follow that same path, and prevent the laser from firing through walls. I am not entirely sure how to do it, but, I want it to set Fire to true if there are no parts on the ray until the end, or to change the target to the first part it finds on the ray. Hmm...

If you have questions, ask, I'm not entirely sure how to word this correctly.

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 11:31 AM
Hmm...

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 11:53 AM
Bump.

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 02:55 PM
Hello there...

Nobody is even going to attempt to help?

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 03:00 PM
It's been so long since I've made a raycasting gun, sorry that I can't be of any service, but I do know you're missing an argument on local Hit,Position.
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 03:01 PM
Also, where'd you get clicker from?
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
23 Jun 2012 03:05 PM
The wiki does explain this? The 'laser' doesn't go through walls because it detects where the ray hits an object, and creates a laser that starts at the gun and ends at the position that it hit.

http://wiki.roblox.com/index.php/How_to_Make_a_Raycasting_Lasergun
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 03:10 PM
I read 3 wiki pages on raycasting, the method, how to make the gun, it does not explain how I use just that method, to target the first brick along the ray that I caste.

Clicker is from an event connection function(mouse)
clicker = mouse

It was the only way I could get mouse to be used in any part of the script.

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 03:12 PM
I am not making a raycast gun, if I was not clear on that.

I already have a laser gun, and I showed you how I drew the laser, but, that method allows me to target anywhere on the map and hit where I target, regardless of any boundaries.

So, I figured I could use a raycast method, that would return true if there was no object blocking it, or would return the first object I hit, and allow me to use that in the firing function.

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
23 Jun 2012 03:13 PM
..Uh?

local Hit, Position = game.Workspace:FindPartOnRay(Ray, User)

Correct?

So...

http://wiki.roblox.com/index.php/FindPartOnRay

It tells you what it returns and what the arguments are? You clearly read the wrong wiki pages.
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 03:17 PM
I read the ones you are linking me to, they are vague however, and don't specify how I can even use the method...

Besides that, I've never seen a value defined as...

local a, b = blah

Does that mean that Hit = Ray, and Position = User?

The wiki honestly does not explain as much as I had hoped it would. I don't see anything referencing the return of the first part is passes through. :/

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
23 Jun 2012 03:18 PM
If you're not making a raycast fun then what on Earth are you doing?
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
23 Jun 2012 03:21 PM
Read this really fast.

http://wiki.roblox.com/index.php/Variables#Multiple_Assignment

And also, you shouldn't need to have a whole description about the thing. All you need to know is what the arguments are, and what it returns.

The first thing it passes through.. The ray only returns the first thing it passes through the way that it runs in that laser gun script.
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 03:22 PM
Making a, "RayCasting Pass Method".

...

I fire my gun, it activates a function that creates my laser, and then eventually does damage.

Before I create my laser, I need to run another function or method that will make sure I am not firing through any parts, and if I am, change my target to the first part on the ray, and then pass me on to continue firing.

It's similar to my anti-teamkill pass method, it runs a simple algorithm that makes sure the targeted player is not on my team, my ally, or a neutral player, if it is, then the gun won't do damage, if it is not, then the gun continues as if nothing happened.

However, I have never worked with raycast before, and the method is a bit more complex, as it will be changing my target.

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
23 Jun 2012 03:25 PM
Well if it's firing into a part, then the ray will stop?

Copy/paste the wiki code into a tool or something. Set up a small arena. The laser doesn't go through walls.
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 03:25 PM
Hmm...

Never knew about multiple assignment, thanks for the heads up.

I still think I am a beginner when it comes to Lua, since I don't know a lot of things, and there are a lot of methods I am ignorant when it comes to them...

Most things I can look up and figure out, but raycasting introduced a few things I am not used to.

"APN Forever, Long Live Its Eternal Glory!"
Report Abuse
8SunTzu8 is not online. 8SunTzu8
Joined: 30 Sep 2011
Total Posts: 8199
23 Jun 2012 03:26 PM
Yes, the raycasting laser gun script will not go through walls, however, I am not making a laser gun in that format...

My laser gun works differently, and I need to figure out a method for passing...

:/

In order to, I needed some insight on how the raycasting method works, and how :FindPartsOnRay() worked.

"APN Forever, Long Live Its Eternal Glory!"
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