|
| 25 Jul 2015 10:29 PM |
This portion of the script is supposed to place a building where a brick called "Highlight" is located. It works fine, but it always ends up being a half-stud off.
function PurchaseBuilding(ID, Location, Rotation) local NewBuilding = game.ReplicatedStorage.Buildings[Buildings[ID].Name]:Clone() ... NewBuilding:MoveTo(Vector3.new(Location.X, Height, Location.Y)) print("B:", Vector3.new(Location.X, Location.Y)) ... end
print("A:", Highlight.Position.X, Highlight.Position.Z) PurchaseBuilding(BuildingID, Vector2.new(Highlight.Position.X, Highlight.Position.Z), Rotation)
The output is something like this: A: -6 102 B: -6, 102
But in reality, the position of the model becomes this: -5.5, 3.2, 102
The -5.5, of course, is supposed to be -6. I have no idea why it isn't.
I even tried moving the model in the command line to see if it works there, but even there it didn't; in fact, I get strange results when I try other numbers:
workspace.TEST:MoveTo(Vector3.new(-5.5, 2.4, 102)) > -5.5, 3.2, 102
workspace.TEST:MoveTo(Vector3.new(-6, 2.4, 102)) > -5.5, 3.2, 102
workspace.TEST:MoveTo(Vector3.new(-6.5, 2.4, 102)) > -6.5, 3.2, 102
workspace.TEST:MoveTo(Vector3.new(-7, 2.4, 102)) > -7.5, 3.2, 102
workspace.TEST:MoveTo(Vector3.new(-7.5, 2.4, 102)) > -7.5, 3.2, 102
To add to the confusion, sometimes the same command has varying results. The -6 one has brought it to -5.5 and -6.5 before, and I can't figure out when it goes where.
Why is MoveTo not moving to the proper location? |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 10:37 PM |
| It offsets by 0.5 studs for some reason, does this in studio as well. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 10:39 PM |
| I assume it's some stupid voxel thing, I have no idea honestly. If you try using the move tool in Studio things automatically offset by 0.5. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 10:48 PM |
| So, it is *supposed* to do that, or is it a bug? |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 10:51 PM |
| I have no idea, I don't like it though. I think it's stupid, I have no idea why it does that or why it's needed. It's just something that happens. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 25 Jul 2015 10:53 PM |
| Model:SetPrimaryPartCFrame(PositionOfWhereItGoes) |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 10:56 PM |
| SetPrimaryPartCFrame has saved my life so many times. I love that method. |
|
|
| Report Abuse |
|
|
ShungTzu
|
  |
| Joined: 14 Jun 2014 |
| Total Posts: 959 |
|
|
| 25 Jul 2015 10:58 PM |
| It also tends to yield to parts already in the way, which is bad if you want to move buildings. SetPrimaryPartCFrame() always seems to get the job done, though. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 10:59 PM |
That was the workaround I was thinking of, but it's going to be a pain in the butt to use that under these circumstances...
I wish Roblox would just make their stuff work properly, ugh |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:00 PM |
> It also tends to yield to parts already in the way
That's not a problem, I already am checking for that. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:00 PM |
| You probably don't have the PrimaryPart set because you're an idiot. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:07 PM |
It's because of the variety of buildings
Using SetPrimaryPartCFrame would put it in the ground so I have to make a height offset for each building, whereas MoveTo automatically put it on top of the ground. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 25 Jul 2015 11:08 PM |
| have the primary part the lowest one O.o |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:09 PM |
| You still need to have the PrimaryPart set. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:12 PM |
> have the primary part the lowest one O.o
That would still put it slightly in the ground, because the lowest one still has a height.
I'm planning on putting a separate 'offset' part right underneath each building where the building and the ground meet and making that the primary part. Problem is, there are tons of buildings... |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:13 PM |
> You still need to have the PrimaryPart set.
I do have it set, but unless I make a separate part underneath the whole model it will be partly underground. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:14 PM |
> You still need to have the PrimaryPart set.
I do have it set, but unless I make a new one underneath the whole building it will be partly underground. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 25 Jul 2015 11:14 PM |
| You are making your game, you will sometimes struggle and have to add a lot. I'm sure that adding one part to all of your buildings wouldn't be the most time consuming thing... |
|
|
| Report Abuse |
|
|