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: Still confused with raycasting...

Previous Thread :: Next Thread 
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
01 May 2012 10:40 PM
I dont understand how you put where it points, or really any of it for that matter. That wiki link isn't very big...
Report Abuse
3lex33 is not online. 3lex33
Joined: 08 Oct 2008
Total Posts: 5220
02 May 2012 12:46 AM
Create ray with Ray.new(start, vector). Both shall be Vector3. First sets position, from which ray starts going. Second is NOT the end point, second is vector, on which ray starts going. If start is (5, 0, 0) and vector is (0, 5, 0) you will have ray starting at (5, 0, 0) and ending at (5, 5, 0).
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
02 May 2012 07:35 PM
So like, the start is the middle of a compass, and the vector is telling which way to point?
Report Abuse
Drenkus is not online. Drenkus
Joined: 03 May 2009
Total Posts: 2380
02 May 2012 07:36 PM
Correct
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
02 May 2012 07:38 PM
Awesome, and nice 2222 posts.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
02 May 2012 07:40 PM
Now how would i put that into a sumobots script? Since the start would be ever changing...
Report Abuse
Drenkus is not online. Drenkus
Joined: 03 May 2009
Total Posts: 2380
02 May 2012 07:42 PM
Maybe with a function that fires every time the torso changes, ex. the position. I don't know if that would work, though.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
02 May 2012 07:45 PM
Could i do this?
a = game.Workspace.Brick

Ray.new(a.Position.x, a.Position.y, a.Postion.z, a.Positon.x +2, And so on)?
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
02 May 2012 08:03 PM
No. Ray.new only accepts two arguments. Just make a ray from the center of the bot and have it go around in a circle until it finds another bot.

With a Five-Guys burger in my hands, I am now invincible!
Report Abuse
LPGhatguy is not online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
02 May 2012 08:04 PM
What are you trying to accomplish with that?
Report Abuse
3lex33 is not online. 3lex33
Joined: 08 Oct 2008
Total Posts: 5220
03 May 2012 10:23 AM
Vector3 arguments. Meaning that it would be

Ray.new(a.Position, a.Position+Vector3.new(2, 2, 2))
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
03 May 2012 09:30 PM
So, whats the part of the script where I tell the ray to do something after it hits something?
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
04 May 2012 07:44 PM
Boo! *Scares post to top of page*
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
04 May 2012 11:32 PM
Really? Nothing? I'll ask again, what is the function for when the ray hits something?

Is it like:

ray = Ray.new(Brick.Position, Brick.Position + Vector3.new(2, 2, 2))

ray.Touched:connect(hit) -- Or however you do a function like that.
Report Abuse
3lex33 is not online. 3lex33
Joined: 08 Oct 2008
Total Posts: 5220
04 May 2012 11:43 PM
hit, position = game.Workspace:FindPartOnRay(ray, model in which ray shall ignore all hits(optional))

Hit is the part which got hit, position is the position of this part.

And read this, it helps on practical example:
http://wiki.roblox.com/index.php/How_to_Make_a_Raycasting_Lasergun
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
04 May 2012 11:52 PM
1) Why isn't it hit.position?
2) It seems simple enough, but where would i put this in a script so it would drive after the ray hit?
3) Finally, not as important, how do you set the ignore?
Report Abuse
3lex33 is not online. 3lex33
Joined: 08 Oct 2008
Total Posts: 5220
05 May 2012 12:01 AM
1)Because functions returns you 2 arguments - hit and position. And hit.Position - position of part is not always equal to position - place, where ray hitted the part.


2)Something like this will pull part away if it gets hitted by ray
Vec = Vector3.new(...)
Ray = Ray.new(startpart.Position, vec)
hit, pos = workspace:FindPartOnRay(Ray)
if hit.Name == "your part" then
hit.Velocity = Vector3.new(startpart.Position-pos)
end

3)Ignored argument shall be a model. Everything in this model will not be hitted by ray. For example:

ignore = game.Workspace.wow75
hit, pos = workspace:FindPartOnRay(Ray, ignore) --your character wont be detected by ray


Read the article, it really helps.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 May 2012 12:12 AM
1) Oh right, because of the (Brick.Position, vec)

2) So hit, pos = workspace:FindPartOnRay(Ray) is basically a touched function for a ray.

3) That was my guess, thank you.
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