|
| 02 Nov 2015 04:20 AM |
I have a tool, kind of a building tool where you can place a building onto a Smooth Terrain map. The problem is, that when I use MoveTo(mouse.Hit.p) it CFrames the building through the terrain, while in studio(using the command bar) it places the model on top of the terrain, which is exactly what I want to happen. However, this doesn't happen when I try to do it with a tool, also the y-coordinate seems to be always 0 for some reason... When I do this: print(mouse.Hit.p.y) it doesn't say 0, but the building really is placed at a 0 y-coordinate
Can someone please help me out? |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:22 AM |
Setting the CFrame property ignores collisions. Using :MoveTo() does not. Post code pls |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:25 AM |
b:MoveTo(Vector3.new(9999, 99999999999, 9999)) local hit = mouse.Hit.p print(hit) local targ = mouse.Target if targ and targ.Name == "Terrain" then b:MoveTo(Vector3.new(math.ceil(hit.x), math.ceil(hit.y), math.ceil(hit.z))) print(hit.y, b:GetModelCFrame().p.y)
I use MoveTo because I don't want it to ignore collisions, but somehow it does anyway. the last print gives me this:
Actual y-coordinate of mouse.Hit.p.y, 0 |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:32 AM |
b.Parent = nil local hit = mouse.Hit.p local x = math.floor(hit.X+.5) local y = math.floor(hit.Y+.5) local z = math.floor(hit.Z+.5) local target = mouse.Target b.Parent = game.Workspace if tostring(target) == "Terrain" then b:MoveTo(Vector3.new(x,y,z)) end
Dunno, try this |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:36 AM |
I don't know what magic you used, but it worked xD
your version should be exactly the same as mine, right? How come yours worked xD
Anyway, thanks a lot! |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:50 AM |
he used the opposite of math.ceil() he used math.floor he used toString, which is similar to yours I do not understand the .5, but whatevs anyways you may have just used the wrong function of the math property
|
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:54 AM |
| using floor didn't solve the problem, i used ceil and it has the same effect, as well as when i remove the +.5 |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 04:58 AM |
then your starting b was the incorrect as you see b.Parent = Nil versus your b.MoveTo
|
|
|
| Report Abuse |
|
|