#Moving Model resets the Orientation (rotation)

76 messages · Page 1 of 1 (latest)

narrow olive
#

I can click a model to move it, rotate it and place it, when i move it again the rotation gets reset to 0,0,0 (even if the base model is rotated like 0,-90,0). i need help to fix this rotation reset, it should keep what it was before. Check lines of code

radiant gorgeBOT
#

studio** You are now Level 2! **studio

narrow olive
#

The reset happens when i move it again, so inside the last if

warm pewter
#

send full script

narrow olive
#

Is there a better way i can send it to you?

narrow olive
warm pewter
#

ctrl-A

narrow olive
#

I did, that txt is the entire script

warm pewter
#

mb i was on phone it didnt show like that

#

soo ur problem is that after u place it 1 time with a a rotation, the next time u try to move the rotation becomes 0,0,0

#

right?

narrow olive
#

Exactly, originally it's at 0,0,0, then i move the model and rotate it by 90 degrees, then i place it. When i move it again the rotation resets to 0,0,0

#

But even if the original model rotation isn't 0,0,0 it gets resetted to 0,0,0

#

Original, After dragging it with mouse and rotating it, After being dragged again

#

I think the problem is on the local newPivot calculation, cause if i force it to be 0,math.rad(90),0, when i move it it stays like i wrote

warm pewter
#

No no i get the problem truna figure it out rn

radiant gorgeBOT
#

studio** You are now Level 10! **studio

warm pewter
#

try this

#

mb

narrow olive
#

It works man, what was the issue?

#

Oh it's incomplete?

warm pewter
#

no i accidently deltet it

#

problem was when u were placed in the end

#

u werent saving it

#

and i made it as an attribute

narrow olive
#

But currentrotation shouldn't change value?

#

I mean in the old code it's currentRotation = OriginalCoordinates (movingObject:GetPivot()) Which is calculated every time you move it,

#

so if it's rotated, the pivot should change the values , or am i wrong?

warm pewter
#

Each time you moved and rotated an object, the rotation would reset to its initial state when the object was grabbed again

#

SavedRotation is getting the currentrotation value

narrow olive
#

But if i placed it rotated i saved the pivot, then when i take it again the pivot is recalculated and it should pass me the new values with the rotation, and assign them to currentRotation, this is what i did before

radiant gorgeBOT
#

studio** You are now Level 3! **studio

narrow olive
#

Also, do i need to do movingObject:PivotTo() if i'm calling ApplianceMoveEvent that pivot too? i commented the first and it works anyway

#

It gave that laggy effect

#

I mean it does the same thing

warm pewter
#

ye sure

narrow olive
#

Ok i commented the PivotTo and left the ApplianceMoveEvent ones

narrow olive
warm pewter
#

also everytime the runservice moved earlier it was multiplying it by 90

#

but u comented it

#

i was confused

#

what u were tryna do

narrow olive
warm pewter
#

ye

narrow olive
#

It was a test to see if it was the calculation to orient it at 0,0,0

#

with that line it was indeed always moving rotated by 90

warm pewter
#

oh alr

#

but u got why it wasnt working right

narrow olive
#

I think so, but i was saving the rotation too before (i guess)

#

cause everytime i moved it i saved the OriginalCoordinates by getting the Pivot, then passing the values to currentRotation, so currentRotation was always updated

#

apparently i was wrong

warm pewter
#

Well no ur not entirely wrong i dont think

#

test if it works without that thing that keeps changing it

#

that was more like a test

narrow olive
#

This, i guess it updated currentRotation, cause GetPivot happens only everytime you take it to move it

#

I mean in debugging it was indeed updating

warm pewter
#

soo it works without chaning the attribute everytime?

narrow olive
#

Nope

#

I can send the debbuging values just like this

#

This is moving it (no rotations done)

#

Expanded

#

After the 90 degree rotation

#

As you can see currentRotation is getting updated by Original Coordinates (GetPivot())

warm pewter
#

not sure tbh

narrow olive
#

no wait, it's getting changed, The currentRotation assignation changed the values

#

I indeed lost the rotation like this

warm pewter
#

lmao

narrow olive
#

I was probably taking the wrong values from the Pivot

warm pewter
#

ye i just addet that part where it keeps getting changed just cuz

narrow olive
#

Cause with the rotation it passed from 0,0,0,1,0,0,0,1,0,0,0,1 to 0,1.5707,0,1,0,0,0,1,0,0,0,1

warm pewter
#

if i didnt we prolly be stuck rn

narrow olive
#

Well i'm glad it works hahaha

warm pewter
#

lmao