I’m trying to make a game that has augmented reality in it. I want to make a sphere come towards the vuforia camera when a player concludes a task that i already programmed, but i cant find out how to.
I’ve tried using MoveTowards() but all it does is make it go up on a horizontal axis and not towards the camera on a vertical axis.
Any help would be apreciated, thanks.
Hi, maybe you can scale the model so can be seen as it´s nearer. Try using coordinates based on the camera as (0,0,0) then move along the z axis.
Hope it helps!
To move the sphere towards the camera, you can follow the steps.
- Rotate the object towards the camera using transform.lookAt().
- Use Vector3.moveTowards() and pass the current position, target position (camera’s position - minimum distance from camera, if any) and the speed of the movement.
I would be able to help more accurately if you can tell me some more details such as will you want the sphere to disappear when the image target is lost or after a fixed amount of time?
If the sphere you’re trying to move, is attached to any Image target in Vuforia, I recommend to move it out as it might cause issues in the movement of the sphere when the image target is lost and found again.
You can then enable and disable the object (Sphere) by registering to Vuforia events to get the callback OnTrackingFound and OnTrackingLost.
Hope it helps. Let me know if you have any further queries.