DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:25 PM |
If I use Mouse.Target and click on a piece of terrain, how can I tell what I clicked on?
Like if it's grass, sand, water, etc..
Can I do that?
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 02:26 PM |
| Last time I checked, it doesn't work. |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:30 PM |
:/ Well, there goes half my game plan...
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 26 Jul 2012 02:32 PM |
| You could use mouse.Hit.p to get the position of where the mouse is in 3d coordinates, then check if that's in the bounds of terrain, and then find which cell it's in. That's as much as I can help you with though as I don't know any of the methods for the terrain. |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:35 PM |
>dr01d3k4, Thanks, but the terrain I'm working with is around 500x500 and that's a bit too big for me to map out.
I'll just figure something else out.
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 26 Jul 2012 02:38 PM |
What do you mean, "map out"? Can't you just do something like: local p = Mouse.Hit.p; local x = p.x; local y = p.y; local z = p.z;
if ((x > -250) and (x < 250)) then -- X is in bounds end
Etc? |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:41 PM |
>dr01d3k4,
I mean, then I'd have to map out where the sand is, where the water is and where the grass is.
Also since they are in odd shapes, There'd be hundreds of arrays I'd have to log.
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 02:42 PM |
| WorldToCell( Vector3 position ) |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 02:42 PM |
| I'm fairly sure you can just use a simple loop to go through every single block in a gridm instead of manually doing it all. |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 26 Jul 2012 02:42 PM |
| Isn't there a simple method likee Terrain:GetCellType(x, y, z) or something? (Just guessing) |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:44 PM |
>Darkmist101,
Could you explain what that does?
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 26 Jul 2012 02:46 PM |
Use WorldToCell and GetCell methods of the terrain. http://wiki.roblox.com/index.php/RBX.lua.Terrain_%28Object%29 Read that page on the wiki for an explanation of the methods. |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:47 PM |
>dr01d3k4, Thanks, funny thing is, I was just reading about the GetCell method. I'll take a look at WorldToCell too,.
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:50 PM |
One last thing.
If a player clicks on the terrain, will the Mouse.Target be the terrain?
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 26 Jul 2012 02:51 PM |
That I have no idea about. You should test it yourself. print(Mouse.Target.Name) (or ClassName).
I can't test it myself as I uninstalled roblox. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 02:52 PM |
| WorldToCell converts world coordinates to coordinates specific to the terrain grid. As you know, you usually use world coordinates, but the terrain uses its own grid. WorldToCell converts it to that grid. |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 02:54 PM |
>ElectricBlaze,
Thanks, but if the coordinate is on the surface of the terrain, which way does it round?
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 02:55 PM |
So you could do this:
local WorldPos = Vector3.new(50, 50, 50) local material, type, orientation = workspace.Terrain:GetCell(workspace.Terrain:WorldToCell(WorldPos)) |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 02:56 PM |
| Could you please rephrase that? |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 26 Jul 2012 03:00 PM |
| I'm pretty sure that mouse.Hit will return terrain if you clicked on it... |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 03:02 PM |
>ElectricBlaze, Thanks, but do you know the difference between material and type?
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 03:02 PM |
>Quenty, Thanks.
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 03:04 PM |
| Type is the Shape of the cell. It can either be Solid, VerticalWedge, CornerWedge, InverseCornerWedge, or HorizontalWedge. Material is the material. I believe you know what that is. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2012 03:05 PM |
| @Quenty - No, mouse.Hit will return a CFrame holding the world coordinates of where the mouse is current pointing. |
|
|
| Report Abuse |
|
|
DlSCORD
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 555 |
|
|
| 26 Jul 2012 03:06 PM |
>ElectricBlaze, Thanks, I'll try that to get the material.
[ Love And Restraint Cannot Co-Exist ] |
|
|
| Report Abuse |
|
|