Thanks in advance for taking the time to read this.
Problem: I have a XR grab interactable ‘Gun’ with script attached to generate bullet & muzzleflash prefab, when shooting while strafing/moving player the bullet & muzzleflash prefab lags/appears in previous position not current (video attached). You can also see there is no issue generating these prefabs when stationary.
Vr device: Oculus Quest 2
Unity Version: 2020.1.9f1
Package: XR Interaction Toolkit 0.10.0
PlayerMovement Component: Continuous Move Provider (device based)
Weapon has XR grab interactable component & weapon script with>
private void Awake()
{
interactable = GetComponent<XRGrabInteractable>();
}
private void OnEnable()
{
interactable.onActivate.AddListener(Fire);
}
private void OnDisable()
{
interactable.onActivate.RemoveListener(Fire);
}
private void Fire(XRBaseInteractor interactor)
{
CreateProjectile();
}
private void CreateProjectile()
{
GameObject projectileObject = Instantiate(projectilePrefab,
barrel.position, barrel.rotation);
Projectile projectile = projectileObject.GetComponent<Projectile>();
projectile.Launch();
GameObject muzzleFlashObject = Instantiate(muzzleFlashPrefab,
barrel.position, barrel.rotation);
Destroy(muzzleFlashObject, destroyTimer);
}
Troubleshooting>
1.I have tried using <on Select Entered (XRbaseInteractor)> to assign the gun object as a child of the hand object.
2.Project Setting>Time>Fixed Timestep: tried 0.01388889 thru 0.0111111
3.Tried changing xr grab interactable components for smooth position/rotations & tried all 3 movement types.
-
Used Object Pooling method instead of instantiation.
-
Tried assigning the muzzlePrefab as a child of the barrel location and just enabling and disabling.