#Part that follows mouse is sinking into baseplate, terrain, etc.
129 messages · Page 1 of 1 (latest)
** You are now Level 5! **
^ Note that I cannot simply detect what the orientation of the part is and add a Vector3 to fix it, the part itself comes from a table and always results in a 'attempt to call table value' erorr when putting the orientation into a function.
could you send the script here
There are a god-awful number of scripts that go into making this.
I will try to ss the relevant bits.
@winter plank ^ basic bits.
If you need more to help me with the issue, lmk.
wait so
maybe scrap the screenshots
what is the intended outcome
what does it look like to you
and do you have a photo of whatever is going wrong (i.e. part clipping into wall)
There is a GUI with all of the parts you can use to build.
When you click one of the buttons in the GUI, the intended part spawns, but simply follows your mouse (and is semi-transparent) until you click, at which point the part solidifies and can no longer be modified.
The intended outcome is that, while the part is following your mouse, it stays above the baseplate, terrain, and other parts.
Parts that are not floors (i.e walls) are phasing through the baseplate, to where only a small portion of the wall can be seen above it (same with terrain and other parts).
(let me grab a photo)
@winter plank ^ as you can see here
try changing line 92 to
NP.Position = Vector3.new(MousePosX,MousePosY,MousePosZ + (NP.Size.Z/2))
to me the way i interpret the code is that it's setting the part's position to the mouse coordinates exactly
so when the part's origin is central to the part, it'll be halfway through the ground
but if that were the case i think it'd be doing the same thing with the floors too, but it'd be less noticeable since those are horizontal not vertical
let me know your thoughts though
I don't think arithmetic can be performed on Vector3s?
MousePozZ is just an integer, no?
or a float i mean
it's a float
where are we doing arithmetic on vector3s?
we can add them and all that as much as we like, it just splits it up into its separate components
Unfortunately, the changes did not work.
since we're just constructing a new one though we arent even messing with that, we're just moving the z value in the constructor slightly upwards based on the newpart's size
any difference in the outcome though?
Well, both the floor and wall are the same size.
is the wall slightly higher or anything
The floor is just horizontally rotated.
could i get a photo of both pretty please
The wall/floor?
yeah
Sure.
idk it might help me get a better idea of what's going on
because to me the code i sent should work but for whatever reason is not
There's different iterations of it, but they're all the same size. Only diff is material & color.
now could i see them being previewed on the ground at the cursor's position?
are you sure the wall is the only one in the ground? because to me i would think both parts would suffer from the same problem
Sure, one moment.
I'm pretty sure it is now, actually.
just add the Half Y size to the Position
Yes, they're both in the ground it seems.
tried that
didnt work, apparently
that's why im surprsied
it looks like an easy fix
is there a different line of code where you move the part?
because what i sent here
should be the fix but it isnt for some reason
oh wait
i think it's because you rotate the wall
you dont just scale it vertically
it didnt work because that code is just wrong
Kind of worked, but now it just comes upward by that position value every time I move the mouse, same as before.
It still starts in the ground.
tryed adding it to the Y Position?
you still add it to th Z
also you dont need those brackets there, makes it look cleaner
^
nothing changed at all?
Nope.
is the part Rotated?
ty using the X or Z size
but still add it to the Y position
One of them is, the other isn't.
well that'll make it a lil more difficult
Depends on if you want a wall or floor.
is there any advantage to rotating it as opposed to like
just scaling it vertically
Well, yes. I tried that, but the whole system had a seizure.
local yAdd = NP.Size.Y/2
if NP.Orientation ~= Vector3.new(0,0,0) then
yAdd = NP.Size.Z/2
end
NP.Position = Vector3.new(MousePosX,MousePosY + (yAdd),MousePosZ)
if that doesnt work swap the 3rd line for yAdd = NP.Size.X/2
I can't use any functions that involve the orientation of NP cuz it says I am calling a table value.
aslo, why dont you just send the Mouse Position as Vector3?
When you click a GUI button, a remote event is fired that activates a function to check for the name of the part that you clicked on, and if it is found, it makes sure that you have enough materials to spawn it in, and if you do, a remote event is fired to actually create the part. NP = Instance.new("Part"), then I just assign all of the properties of it that are listed in the table of parts properties.
^ Table of part properties.
Idk why size is there, they're all the same size.
But for when I add smaller-sized parts, should help, idk. I don't see that hurting anything though.
For cleaner code or because it actually matters in this instance?
cleaner???
I used mouse.hit.p to get MPX, MPY, and MPZ.
Not a raycast, which could be an issue.
just send the mouse.Hit.p
its a Vector3
It won't help with functionality in the moment. I can fix that later, once this is resolved.
Tried that when I was making it, and it didn't work.
Now that I think about it, there's a way to do it.
Nvm.
But regardless, I just wanna fix the clipping issue.
None of what I have tried here has made any difference with the part position.
OH WAIT
I THINK
ONE MOMENT
homie had a lightbulb moment
I figured it out.
So uhhh, funny thing.
I did the same thing you did there, but it said I was calling a table value because I was trying to use CFrame instead of Vector3 when checking if the orientation ~= 0,0,0.
Well....much appreciated. It turns out that I am just lacking braincells.
Yep! Thanks.
** You are now Level 6! **