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.

Animator issue in bullet hell game

Discussion in 'Editor & General Support' started by DuvE, Nov 23, 2016.

  1. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    149
    Hi, we making multiplayer bullet hell game. There is several bullet patterns or bullet scenarios, dont quite sure how to call it. Here is a quick example:

    Bullets are created with Instantiate function and they travels in a strait line. Bullet generator is animated by animator controller for rotation over time left to right. Player standing still. And here is the problem with frames or something. Sometimes for example, player get hit by 10 bullet, sometimes by 11 or 9. The number is not always the same and i think it depends on lag and fps.

    How i can make it constant? Even if PC freezes or lags, player will get hit by 10 bullets every time.
     
  2. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    149
    Still dont know how to fix this issue. Maybe it is wrong to test games in editor's play mode? But still, something wrong. Problems with either rotation with aimator or a instantiate function.
     
  3. The-Britain

    The-Britain

    Joined:
    Mar 31, 2015
    Posts:
    513
    First, don't instantiate your bullets while shooting. Use object pooling. You will cause massive lag.

    Second, do not move them by incrementing their transform position, you need to move them using the physics system. They need a rigidbody.

    Third, Ez Object Pooling in the asset store is great. Use that for bullets.
     
    DuvE likes this.
  4. The-Britain

    The-Britain

    Joined:
    Mar 31, 2015
    Posts:
    513
    Additionally, if you want LOTS of bullets, even object pooling isn't going to help. With a beefy computer I top out at 700 bullets on the screen before things fizzle. I suggest using particles for anything over 400 bullets on the screen at a time.
     
  5. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    149
    Thx for the answer.

    I dont think it is possible to use particles instead of bullet prefabs. There is several scripts and behaviors attached to bullets and they have their own stats like damage, public variable to explosion prefabs, speed and size buffs etc...

    I will try object pooling and physics movement. But the main reason i asked this question is inconstancy. Even if game lagging why bullets does not sync with each other or with framerate? And this lead to the fact that the player receives a different amount of damage each time scene is played.
     
  6. The-Britain

    The-Britain

    Joined:
    Mar 31, 2015
    Posts:
    513
    Like I said, make sure you are moving the bullet using physics and not transforming the position manually.
     
unityunity