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. Dismiss Notice

Hitscan or projectile? What is their pros and cons? Which is better for balanced gameplay?

Discussion in 'General Discussion' started by Stonetronics, Feb 14, 2015.

  1. Stonetronics

    Stonetronics

    Joined:
    Feb 7, 2015
    Posts:
    18
    Title says...
     
  2. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
  3. Stonetronics

    Stonetronics

    Joined:
    Feb 7, 2015
    Posts:
    18
    lol wut
     
  4. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    How long is a piece of string?

    Coke or pepsi?

    this is a very broad and open-ended question to which there are a million answers
     
  5. Blacklight

    Blacklight

    Joined:
    Dec 6, 2009
    Posts:
    1,241
    Define "balanced gameplay".

    Projectiles are good if you want weapons to be dodgeable. I haven't tried setting up realistic bullet physics before, but I imagine that it would be easier to accomplish using projectiles. You do have to be aware of the speed at which the object is going. If it's too fast than it might end up going through some objects, so you have to set up something to detect for that or work around it.

    Hitscan/raycast weapons are good for imitating fast projectiles and you don't have to worry about them passing through objects but as I said, you're probably better off going with projectiles if you want to simulate realistic bullet physics. Be aware if you're enemies are using raycast weapons, deaths may feel cheap because of the instant damage and no chance to defend against them.
     
  6. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Well with the Projectile part, according to Unity Reference, if you change the projectiles rigidbody to Continuous checking instead of discreet it will detect any collision, but in so doing that, you take a lot more Physics Calculations away from more important things if they are needed.
     
  7. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    This is broken in unity 4.x
    apparently fixed in unity 5.

    I'm in need of this eature right now, and very upset about this.
     
  8. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    My solution for Unity 4 is saving the projectiles last position and then next frame do a raycast from the last position to it's current position.
     
    Devil_Inside likes this.
  9. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Yeah, I do the same. Works great!
     
  10. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Hmm didn't realize that, I used it a few times in my prototype games in 4X series and it just made my game spike with frame lag. But I'll definitely be sure to try it again in the 5X Series when I get that far into my game in 5X.
     
  11. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    952
    Hitscan are easier to write hacks for. Projectile are harder to do so, while also requiring more skill/experience from player. In pvp I wouldn't mind if the game tuned down the importance of hitscan weapons and rewarded projectile more. But that's a rare sight. I think basically only Tribes has done that.
     
  12. Deleted User

    Deleted User

    Guest

    Raycast based on trajectory formula! Realastic behaviour and probably cheaper than collider + rigidbody.