Hi, a little rectification to my previous answer;
actually, storing the "reference frame" at Firing time (and then describing the motion of the bullet in such reference frame) will produce the same result as describing the bullet motion in Camera reference fram (instead of world reference frame).
The problem with your scenario is that Vuforia provides two reference frames, one is the World as defined by one of your targets, and the other is the Camera reference frame; these two frames are linked to each other by the trackable Pose transformation.
You would need in theory a "third" reference frame, a sort of "static" world reference that never changes, so that both the camera and the target reference frames can be represented with respect to such "static" frame.
So, the only way you can do this is to use 2 Image Targets (or FrameMarkers) instead of one:
- the first Image Target can be used to define the "static" reference frame
- the second Image target can be used to define the "moving target" reference frame (i.e. your moving target); the idea is that so you can move Image Target 2 (which is the target at which you want to shoot your bullet), while keeping the first Image target fixed at some position
In Unity + Vuforia, it is then quite easy to setup such scenario, as you just need to change the World Center Mode in the ARCamera game-object
(just click on the ARCamera object and check the World Center Mode property in the Inspector);
By default, this is set to Auto, which means that the World Reference frame will automatically be centered on the First Image Target detected
(so, if you have two image targets, the first one detected defines the World Ref; however, if you loose tracking of such Image Target, then the Worlkd Center will be recentered onto the other target)
So, you will need to set the World Center Mode to "USER"; when you do so, an exra field called "World Center" will appear, and there you can specify which Image target should always be used as World Center.
If you do so, the bullet will move in the world reference of the first target, while you will be able to move around with your hands the second target, achieving (hopefully) the desired effect.
I hope this helps.
Hi, a little rectification to my previous answer;
actually, storing the "reference frame" at Firing time (and then describing the motion of the bullet in such reference frame) will produce the same result as describing the bullet motion in Camera reference fram (instead of world reference frame).
The problem with your scenario is that Vuforia provides two reference frames, one is the World as defined by one of your targets, and the other is the Camera reference frame; these two frames are linked to each other by the trackable Pose transformation.
You would need in theory a "third" reference frame, a sort of "static" world reference that never changes, so that both the camera and the target reference frames can be represented with respect to such "static" frame.
So, the only way you can do this is to use 2 Image Targets (or FrameMarkers) instead of one:
- the first Image Target can be used to define the "static" reference frame
- the second Image target can be used to define the "moving target" reference frame (i.e. your moving target); the idea is that so you can move Image Target 2 (which is the target at which you want to shoot your bullet), while keeping the first Image target fixed at some position
In Unity + Vuforia, it is then quite easy to setup such scenario, as you just need to change the World Center Mode in the ARCamera game-object
(just click on the ARCamera object and check the World Center Mode property in the Inspector);
By default, this is set to Auto, which means that the World Reference frame will automatically be centered on the First Image Target detected
(so, if you have two image targets, the first one detected defines the World Ref; however, if you loose tracking of such Image Target, then the Worlkd Center will be recentered onto the other target)
So, you will need to set the World Center Mode to "USER"; when you do so, an exra field called "World Center" will appear, and there you can specify which Image target should always be used as World Center.
If you do so, the bullet will move in the world reference of the first target, while you will be able to move around with your hands the second target, achieving (hopefully) the desired effect.
I hope this helps.