- Home /
Throwing knife goes straight
I have a script to throw my knife forward, and do damage. But when I throw my knife it goes forward, as expected, but I am guessing that the forward isn't changing when I look up and down. For example, if I were to look upwards, it would still go straight, but not where I am looking. It just goes straight in front of my player, not my knife. Can someone help me so it throws correctly? Here is the section of my script that throws the knife: knifeSend.Play(); rb.isKinematic = false; rb.velocity = transform.forward * rbSpeed; yield return new WaitForSeconds(0.5f); FindClosestEnemy(); yield return new WaitForSeconds(0.1f); ReturnKnife();
Answer by James_BadAlchemy · Oct 19, 2018 at 06:01 AM
Is this a first person game?
The reason your knife is always going forward is because the forward of your gameObject doesn't change when you look up or down. If you ARE using a first person camera set up, you can get the forward of the camera (which will have a changing forward due to looking up and down), and then throw your knife based on that.
Thanks for the answer. Sadly, doing that got the same effect. Every forward of the object I get has the same effect. Any suggestions?