#Part that follows mouse is sinking into baseplate, terrain, etc.

129 messages · Page 1 of 1 (latest)

ornate edge
#

I have a part that follows the players' mouse. When it is a floor (i.e an orientation of -90,0,0), it does not go through the baseplate or terrain, yet when it is a wall (orientation of 0,0,0), it does phase through. Is there a simple way of preventing this?

twilit pebbleBOT
#

studio** You are now Level 5! **studio

ornate edge
#

^ 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.

winter plank
#

could you send the script here

ornate edge
#

I will try to ss the relevant bits.

#

@winter plank ^ basic bits.

#

If you need more to help me with the issue, lmk.

winter plank
#

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)

ornate edge
# winter plank what is the intended outcome

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

winter plank
#

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

ornate edge
winter plank
#

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

ornate edge
#

Unfortunately, the changes did not work.

winter plank
#

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?

ornate edge
#

Well, both the floor and wall are the same size.

winter plank
#

is the wall slightly higher or anything

ornate edge
#

The floor is just horizontally rotated.

winter plank
ornate edge
#

The wall/floor?

winter plank
#

yeah

ornate edge
#

Sure.

winter plank
#

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

ornate edge
#

There's different iterations of it, but they're all the same size. Only diff is material & color.

winter plank
#

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

ornate edge
#

Sure, one moment.

winter plank
#

thank you for your patience

#

appreciate you

ornate edge
#

^ Floor

#

^ Wall

winter plank
#

is the floor not halfway in the ground too?

#

it really appears that way to me

ornate edge
#

I'm pretty sure it is now, actually.

plush delta
#

just add the Half Y size to the Position

ornate edge
#

Yes, they're both in the ground it seems.

winter plank
#

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?

winter plank
#

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

plush delta
winter plank
#

??

#

what's wrong with the code

#

wym

ornate edge
#

It still starts in the ground.

winter plank
#

im in blender mode

#

thinking the z axis is vertical

plush delta
#

tryed adding it to the Y Position?

winter plank
#
NP.Position = Vector3.new(MousePosX,MousePosY + (NP.Size.Y/2),MousePosZ)
#

try this

plush delta
#

you still add it to th Z

winter plank
#

yeah i

#

didnt patch it yet

#

feeling silly today

plush delta
#

also you dont need those brackets there, makes it look cleaner

ornate edge
#

No change happened.

#

With any of the iterations.

winter plank
#

nothing changed at all?

ornate edge
#

Nope.

plush delta
#

is the part Rotated?
ty using the X or Z size
but still add it to the Y position

ornate edge
winter plank
#

well that'll make it a lil more difficult

ornate edge
#

Depends on if you want a wall or floor.

winter plank
#

is there any advantage to rotating it as opposed to like

#

just scaling it vertically

ornate edge
winter plank
#
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

ornate edge
plush delta
#

aslo, why dont you just send the Mouse Position as Vector3?

ornate edge
#

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.

ornate edge
plush delta
#

cleaner???

ornate edge
#

I used mouse.hit.p to get MPX, MPY, and MPZ.

#

Not a raycast, which could be an issue.

plush delta
#

just send the mouse.Hit.p
its a Vector3

ornate edge
ornate edge
#

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

winter plank
#

homie had a lightbulb moment

ornate edge
#

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.

winter plank
#

cframes are funky

#

problem solved then?

ornate edge
twilit pebbleBOT
#

studio** You are now Level 6! **studio

winter plank
#

good stuff man

#

glad you got it fixed