Log in or register to post comments

Fixing Game Object with button (OnButtonPressed)

April 23, 2021 - 3:43pm #1

Dear Vuforia users,

currently I am designing an application in which I want to fix an object's position that is tracked by an image. Thus, the object will stay in position when I press a button.

Right now, I got to this code but the object will not exactly be in the correct position when I press the button, it will move a few x,y,z-values in any direction. Thus the object is not fixed correctly. Any tips?

public class Button_fixation : MonoBehaviour


// Thus Tibfib and button can be dragged into box in Unity

public GameObject BttnTibia;

public GameObject Tibfib;

// Create position vector for fixation

private Vector3 m_OriginPos;

// Start is called before the first frame update

void Start()


// Create button functions




public void onButtonPressed(VirtualButtonBehaviour vb)


//Fixate object

Vector3 currentPos = Tibfib.transform.position;

currentPos.x = m_OriginPos.x;

currentPos.y = m_OriginPos.y;

currentPos.z = m_OriginPos.z;

Tibfib.transform.position = currentPos;


Log in or register to post comments