Search Unity

Player Sprite Jittering While Shooting

Discussion in '2D' started by LiberLogic969, Jul 26, 2014.

  1. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
    I'm having some strange jittering with my player sprite in my top-down 2D space game. When the player is moved with the WASD keys its perfectly smooth, but as I start to fire bullets the ship sprite starts to jitter and it doesn't stop until I've stopped firing for a few seconds. I'm fairly new to Unity and really have no clue what could be causing this.

    Here is how I'm doing things :

    I have a GameObject called Player with a RigidBody2D, CircleCollider, and a Script called PlayerShip which controls Input and Movement. The Player object is the Parent of another GameObject called Ship which has a SpriteRenderer Component and a Script called LookAtCursor which lerps the sprites rotation to the mouse (I did things this way because of weird jitter and snapping when the sprite was attached to the Player object and rotated). The Ship Object is a parent to a Weapon object and the weapon contains a Weapon Script which controls firing projectiles. The Weapon is a parent of FirePoint GameObjects which contain a script called FirePoint that tells the weapon which projectile prefab to shoot, where to shoot it from, and the amount to shoot when firing. Its looks something like this :

    Player
    ..........Ship
    ................Weapon
    ...........................FirePoint
    ...........................FirePoint

    I'm moving the player with rigidBody2D.AddForce(force) in the FixedUpdate of the PlayerShip script and updating the force vector in the Update() method.

    Anyone have any ideas? I can post some code from my scripts if they are needed, I didn't want to turn this post into a TLDR hehehe... I'm really not sure if its even script related (its all really basic stuff) or just some weird artifact from the way GameObjects parent-child relationships work... Anyway, thanks in advance for any help.
     
  2. lrlelaldl

    lrlelaldl

    Joined:
    Jul 27, 2014
    Posts:
    75
    Do your bullets have non-trigger colliders?
     
  3. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
    The bullets are set to Triggers and the FirePoints are far enough out from the ship that they wont spawn bullets inside the players collider.


    EDIT : I put the V-Sync settings to "Every Second V-Bank" and it makes the jitters less pronounced and a little more infrequent but they are still noticeable... Not sure what that could mean but I thought I would put it out there.
     
    Last edited: Jul 27, 2014