Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Projectile Velocity

Discussion in 'Scripting' started by joshcamas, Aug 2, 2018.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    In my project, one can shoot arrows. One issue I've had is when the arrow is shot and the character is moving, the arrows velocity is strange. My initial thought was in real like, when an object in motion throws another object, the thrown object's velocity is both the thrown velocity and the thrower's velocity combined. (Like a person throwing a ball on a train). At least, that's my understanding.

    So I figured I'd simply add the shooter's velocity to the initial velocity of the arrow. And this doesn't work either. For example, if the character is moving left or right, the arrow moves left or right, which of course is unrealistic due to the shape of the arrow.

    Any thoughts on making this make sense?
     
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    Try adjusting actual velocity of movement applied to the arrow.
    Something like ~0.7 * Character_Movement_Speed, or even less.

    Also, direction of movement of the shooter do matter.
    When moving forward (could/should be ~0.9-1), velocity should be applied more than moving left / right (~0.3-0.7), or even (0-0.1) when moving backwards and shooting forward.
    Since the shooter doesn't apply any momentum to the arrow's movement direction.

    I bet the Vector3.Dot could do the trick with determining on how to apply the velocity, based on shooter's movement direction and arrow shooting direction.

    I don't think in real life objects gather their "parent" momentum by 100% due to multiple physics factors affecting them. That's why it doesn't look "realistic" when moving slowly.
     
    Last edited: Aug 2, 2018
    joshcamas likes this.
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    I'll try that! And yeah, the reason an arrow doesn't move left or right is because of the fact than an arrow is designed to go forward (weight forward and arrow is straight to have as little air resistance). But if I remember correctly, the initial velocity is indeed equal to the thrower. Should have paid attention more in physics class xD
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,599
    Actually in a vacuum if you fired an arrow while strafing sideways, it would move as much sideways as you expect.

    Arrows have feathers and the aerodynamics are such that any movement NOT aligned precisely with the primary aerodynamic axis (i.e., "forward") is quickly damped out.

    It also imparts a turning moment on the arrow while the lateral velocity is damped, since the center of pressure on an arrow is behind the center of mass.

    There's lots of bow hunters talking about firing in a crosswind, which is the same as if you are moving sideways in an air volume and you fire. Here's one:

    http://www.bowhuntingmag.com/tactics/tactics_part_1_of_4_how_wind_affects_arrow_flight_051111/

    BUT! At computer game speeds (usually 30FPS or 60FPS) there are expectations on projectile behavior, and the ideas posted above by @VergilUa are some of the ways to meet those non-realistic expectations and end up with a fun game rather than a physics-pedantically-correct game. :)
     
    xVergilx likes this.