I am developing an AR game that allows the player to launch a sphere at an image target. When the player presses a button it adds force to the sphere's rigidbody component to launch it from its current position (which is directly in front of the camera). My problem is that I cannot seem to get the ball to fire in the direction the camera is facing. I have tried adding the force using the Camera.main.transform.forward * someVelocityValue but it doesnt seem to work. I've also tried using AddRelativeForce but that's not working either. The sphere begins its life as a child of the ARCamera until the moment the "Launch" button is pressed, at which time I parent it to the ImageTarget before adding force so that its movement is now relative to the image target (so if i move my camera I can see the ball traveling along its arc based on the force applied)
If you guys could help me figure out how to make my sphere always fire in the correct direction (the Vector3.forward value of the ARCamera) that would be great!
Figured it out, I had to use the Vector3.forward of the projectile's transform not the camera. So, at start I instantiate the sphere with a rigidbody at a Camera.ScreenToWorldPoint coordinate (spawns the ball at bottom half of screen like a FPS gun) and then when the button to launch the ba
Launching rigidbody with force in the direction of the ARCame..
Thanks for sharing your thinking here.
Would be great if you can point to a video when you have something further to share :)