Search Unity

Fast Projectile Rendering/Collision Issues

Discussion in '2D' started by rflagg, Dec 16, 2013.

  1. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    Developing a 2d game and right now it seems the rendering isn't as "smooth" as I'd like with fast moving projectiles. The projectile looks like its skipping positions instead of moving very smoothly. I've tried setting the Interpolate on the rigidbody of the projectile to Interpolate, but it only helps very little.

    I'm using 2d toolkit and all the new Unity 4.3 physics. To move the projectile I just set its velocity after I instantiate it, and then I don't touch it after that.

    Any recommendations?
     
    Last edited: Dec 16, 2013
  2. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    I played around some more, and tried moving projectiles using AddForce, and also just removing the rigidbody entirely and just modifying its transform in Update. In all cases the sprite performs the same, it isn't seen clearly as it moves across the screen. This might be more of a refresh rate issue.
     
  3. gl33mer

    gl33mer

    Joined:
    May 24, 2010
    Posts:
    281
    Is this in editor or in a build?
     
  4. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    You might notice some choppy behavior inside the editor if you are actively inspecting a gameobject that is currently in motion. You can also adjust the velocity iterations Unity performs in Edit > Project Settings > Physics 2D -> Velocity Iterations / Position Iterations to see if this helps.

    $physics-2d-settings.jpg

    Cheers,
    Mike
     
  5. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    Both editor and build.

    I will try to do some more tests today, but maybe this is not much of problem as my projectiles might not *need* to move this quickly.

    If you want to try it out yourself, just move a simple sprite with a rigid body across the screen by setting the velocity to a really high value like 1000000. As long as the number is high enough, it will get clamped from the box2d max velocity. Curious if other people feel its not that smooth at these high velocities.
     
  6. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    I actually feel like projectiles going this fast would make sense for something like a gun. Anyways I'm linking a video to show what I'm seeing.

    https://docs.google.com/file/d/0B47NDNW2z2zSWjB4bC1mc2NSdjQ/edit
     
    Last edited: Dec 16, 2013
  7. softwizz

    softwizz

    Joined:
    Mar 12, 2011
    Posts:
    793
    I've noticed this as well, it make collision detection a bit crap as well

    I have a small game that demonstrates what is happening here

    http://www.softkeystore.com/games/cactusgun/

    The bullet and the target seem jerky to me. The bullet has a rigid body and 2D box collider the target has just a 2D box collider
     
  8. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    Yes, that shows the same problem softwizz! Thanks.

    Hopefully we can get some help from some experienced Unity devs on this. Wish it looked much smoother.
     
  9. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    I actually tried this with a particle system too and set the speed to 94. Same thing. Renders really choppy. Actually once you start getting above 50 it doesn't look so hot.
     
  10. rflagg

    rflagg

    Joined:
    Jan 18, 2013
    Posts:
    30
    This probably isn't a unity related bug. This is just a general fast moving small object issue that all games can experience. The monitor refresh rate just isn't fast enough to keep up with the speed of the projectile. to fix this I gave my projectile a little trail (essentially making the sprite bigger) which lets your eyes view the projectile much easier and not nearly as choppy.
     
  11. gl33mer

    gl33mer

    Joined:
    May 24, 2010
    Posts:
    281
    I thought I was subscribed to this thread. Got this message, now. This thread may well develop into an interesting one.

    I'd say with games you're usually better off thinking along the lines of a "magic trick" . Feel is probably most important.

    If I'm trying for example to model a 2d sprite character jumping about on the moon. I wouldn't expect the physics engine (in this case box2d - I haven't checked into that yet and what api's are really accessible yet. Anyone discovered any good undocumented 2d physics yet ;) ? Anyhow, back to the subject. I wouldn't expect a change in global gravity to 1.622 m/s² from 9.78 m/s² to achieve the feel of a 2d Sandra Bullock jumping on my 2d moon.

    Though, it might work. Haven't tried yet.
     
  12. gl33mer

    gl33mer

    Joined:
    May 24, 2010
    Posts:
    281
    Well, I guess this thread never did become an interesting one.