- Home /
why does the pointer not match up with the actual gameobject location?
As seen in the image below. the object is at location 0,0,0. this is also displayed this way in the world. things like rotations work as expected. its only the pointer that's the wrong location. the problem that this creates in game is that the game sometimes thinks that the object is of screen when it isn't and stops rendering it. Is there a way to move the pointer back to the object?
other things that may be handy to know. the mesh is created in game in separate parts. this works fine. it's only after i use CombineMeshes() and create a new instance which I than give that mesh that it breaks.
What's happening here is that your pivot point is off. Check the transform.pivot in debug, see what value it is.
@$$anonymous$$azer83 : According to the image, the editor does not show the pivot, but the center of the object.
@friso100 : Try to display the pivot of the gameobject by clicking on the Center
button, next to the $$anonymous$$ove
, Rotate
, Scale
and RectTransform
buttons just above your`Scene` window.
@Hellium : when i do that it matches with the center of my gameobject. so the pivot point is correct. I did not realise that the pivot point and the center point of my object would be different. Is there a way to change the center point of a object? is this dependent on the mesh and could i change it from there?
Answer by friso1100 · Oct 29, 2017 at 01:39 PM
I found a solution. It turns out when using CombineMeshes() it creates a new mesh with a pivot point at 0,0,0 world position and center point at the object center. In the version above i tried to correct for this by moving the vertices towards the center . this fixed the pivot but moved the center point of the game object. I did this not fully understanding that i was dealing with two separate points.
to fix this i first moved my game object to the center of the world, then used CombineMeshes() so that the center and pivot overlapped, and finally moved the object back to where I want it.