Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shooting an arrow from a bow

Discussion in 'Scripting' started by franceshash, Dec 1, 2015.

  1. franceshash

    franceshash

    Joined:
    Dec 1, 2015
    Posts:
    5
    I'm doing work for a college project and one of the things I need to do is make a bow fire an arrow using script, I've looked all over the net and I cant seem to find any tips or examples where the arrow isn't spawned from the bow because when I fire my bow the arrow needs to be present.
    I have very little knowledge of C# scripting but any tips would be appreciated since I haven't even started yet

    thanks in advance!
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    simplest way to fire an arrow would be using the in built physics, i.e. rigidbodies. Thats covered in these sections
    https://unity3d.com/learn/tutorials/topics/physics

    specifically the "AddForce" function.

    at some point the arrow is going to be spawned... whether that is at the point the shot is fired, or at the start of the code execution (i.e. start) is fairly irrelevant, it's the same code, just in a different place.