Question by 
               firepro20 · Feb 17, 2020 at 10:13 PM · 
                fpscamera-movementthrowing  
              
 
              Throwing an object whilst moving FPS
I am currently throwing an object while moving. The force applied is large enough so that the player does not catch up with the sword in midair. The problem I am facing is that when moving, the sword appears to be going back and forward, sort of a pixelated effect in air. Throw Sword is being called from the Update function when button is clicked, and Camera is being moved through Update function as well.
     public void ThrowSword()
     {
         if (isHolding) // might cause issues as isHolding rules in update might interfere
         {
             isHolding = false;
             sword.transform.position = shootPoint.position;
             sword.transform.rotation = new Quaternion(Camera.main.transform.rotation.x, swordParent.transform.rotation.y, swordParent.transform.rotation.z, swordParent.transform.rotation.w);
             //Vector3 localForward = transform.parent.InverseTransformDirection(transform.forward);
             sword.GetComponent<Rigidbody>().useGravity = true;
             sword.GetComponent<Rigidbody>().detectCollisions = true;
             float forceMultiplier = 0f;
             if (PlayerController.Instance.GetPlayerSpeed() == forceMultiplier)
             {
                 forceMultiplier = 0f;
             }
             else if (PlayerController.Instance.GetPlayerSpeed() > 0f && PlayerController.Instance.GetPlayerSpeed() <= 5f)
             {
                 forceMultiplier = 1f;
             }
             else
             {
                 forceMultiplier = 2f;
             }
             sword.GetComponent<Rigidbody>().AddForce(Camera.main.transform.forward * throwForce * forceMultiplier); // swordParent.transform.forward // fires from pivot3
             //Debug.LogError("Launched!");
         }
     }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Camera Recoil Script Not working Correctly 0 Answers
Arms move with camera FPS game 1 Answer
Object and camera following mouse 0 Answers
Camera movement for Inertia 0 Answers
Camera jumping to final position despite regulating speed. 0 Answers