- Home /
Question by
jbrummert · Oct 26, 2020 at 11:21 AM ·
inventory system
Position.Set() Not Working Properly?,Position.Set() not working Properly?
I am trying to get an object (called HoverObject) to follow my mouse. However, I want there to be a slight vertical offset so it does not prevent the player from clicking. This is why you see (position.y - hoverYOffset).
The object follows the mouse spot on without the offset being present. Any ideas as to why?
if (InventoryManager.Instance.HoverObject != null)
{
Vector2 position;
RectTransformUtility.ScreenPointToLocalPointInRectangle(InventoryManager.Instance.canvas.transform as RectTransform, Input.mousePosition, InventoryManager.Instance.canvas.worldCamera, out position);
position.Set(position.x, position.y - hoverYOffset);
InventoryManager.Instance.HoverObject.transform.position = InventoryManager.Instance.canvas.transform.TransformPoint(position);
}
Comment