Search Unity

Uni Bullet Hell - 2D bullet hell's shot pattern system

Discussion in 'Assets and Asset Store' started by WestHill, Jun 28, 2014.

  1. SolarFalcon

    SolarFalcon

    Joined:
    Nov 28, 2015
    Posts:
    170
    Hello.
    I have updated to the most recent version in a new project and I'm having some issues with Homing Shot. I have a script that randomly selects a target near the Player and passes its transform to the UbhHomingShot.m_targetTransform.

    Here is what happens: Firstly when a new bullet, or missile in this case, is created, it is spawned in at the origin (0, 0, 0) and is then moved to the shot point. This causes an artifact to appear at the origin. You should probably make new bullets be created somewhere off screen or allow the User to set a specific transform for them to be instantiated at.

    Edit: I realized that the objects are spawning on the Pooler's transform, so I just moved it away from the origin.

    Secondly, randomly, the missile will be removed when it hasn't struck anything. I currently have it's auto remove time set to 5 seconds so this should not be happening. Each player attack is in their own layer so they only collide with enemies, and the missiles will randomly self remove. Not sure what is causing this, I will test some more to make sure it's not something on my end.
     
  2. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hi @WestHill

    Is it poosible to implement the feature for homing shot to not fire if there's no designated tag in the scene?

    Right now it's kinda wonky, the bullet goes upwards when fired without target, it would be could if it wouldn't fire at all.
     
  3. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    nice. I will add it.
     
  4. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Great, thanks :)
     
  5. medellinmario04

    medellinmario04

    Joined:
    Nov 29, 2018
    Posts:
    1
    @WestHill
    Hi, i'm having a problem where switching scenes gives me only this error

    Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
    The following scene GameObjects were found:
    UbhShotManager
    UbhTimer

    I've already tried calling UbhObjectPool.instance.ReleaseAllBullet() before moving the scene but the problem persists
     
  6. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @medellinmario04
    I want to find out if the cause of that is the asset.
    Can you send me the smallest project that causes the error?
     
  7. SolarFalcon

    SolarFalcon

    Joined:
    Nov 28, 2015
    Posts:
    170
    Am I the only one having this issue? Been waiting on a reply...
     
  8. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @MaximumTre
    Can you send me the smallest project that causes the error?
     
    Last edited: May 21, 2019
  9. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
  10. SolarFalcon

    SolarFalcon

    Joined:
    Nov 28, 2015
    Posts:
    170
    The log says nothing when the homing bullet vanishes. I decided to use my own homing method because I got tired of waiting for an answer.
     
  11. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @MaximumTre
    If the cause of the problem is in my asset, I will fix it.
    But if it is a problem specific to your project, I can not find it.

    Please send me the smallest project if you want me to make that decision.
     
  12. hedgeh0g

    hedgeh0g

    Joined:
    Jul 18, 2014
    Posts:
    102
    Hello @WestHill

    I want to update Uni Bullet Hell, because I'm currently using an old version. In my game, I have created several prefabs each of them with an UbhShotCtrl + shot patterns. Is there a way to update Uni Bullet Hell without corrupting the assets so I don't need to start over? Thanks in advance.

    Also:

    Coroutines have been deleted, but why example code only?
     
    Last edited: Jun 11, 2019
  13. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hey @WestHill any change of updating the asset so the weapons requiring target/tag don't fire when there's no target/tag found?
     
  14. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Hello
    Could someone tell me what is the best way to desable UBhShotCntrl.Scpipt when Player is dead?

    Is it something like this OK?
    Code (CSharp):
    1.  
    2.     private GameObject livePlayer;
    3.    public GameObject hellBullet;
    4.    // Use this for initialization
    5.    void Start () {
    6.        livePlayer = GameObject.FindWithTag ("Player");
    7.        
    8.    }
    9.    
    10.    // Update is called once per frame
    11.    void Update () {
    12.        if (livePlayer != null) {
    13.            hellBullet.SetActive(true);
    14.        }
    15.  
    16.        if (livePlayer == null) {
    17.            hellBullet.SetActive(false);
    18.        }
    19.    }
    20.  
    I am not a codder, so is it good for perfomance etc?
     
    Last edited: Jul 26, 2019
  15. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    Since it's just one player object the performance should be fine.
     
  16. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    thank you for the answer
     
  17. Globotix

    Globotix

    Joined:
    Oct 15, 2013
    Posts:
    10
    Hello, Great asset. Is there a simple way to have the bullets NOT rotate? I want my bullet's z rotation to remain zero (or the initial angle) even if they are locked-on a target. Thank you.
     
  18. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    alas but this did not help me. Sometime I steel see error message: "Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)"
    And UbhShotManager and UbhTimer appiares in new scene (where there is no any Bhl scripts). Sometime it could be only UbhShotManager. So is it bug or am I doing something wrong?
    Please help me, this asset is really good for my purpos but I can't move further.
     
  19. chihchanglin

    chihchanglin

    Joined:
    Jul 24, 2015
    Posts:
    28
    I'm dealing with that same problem where switching scenes.

    EDIT: v1.4.8 fix this issue! Good job.
     
    Last edited: Aug 28, 2019
  20. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    version1.4.8 has been released.

    Fixed an issue that OnDestroy error when changing scenes.
    *The singleton classes is now DontDestroyOnLoad.

    Added "UbhObjectPool.instance.RemoveAllPool()" method to remove all bullet pools.
    *If you want to clear the bullet pool when changing scenes, call the above method.
     
  21. freeze426

    freeze426

    Joined:
    Feb 17, 2018
    Posts:
    3
    Hi , I use "Core GameKit " and do " Enable a definition "USING_CORE_GAME_KIT" in "UbhObjectPool.cs". ",
    But I have the Error "Assets/UniBulletHell/Script/Singleton/UbhObjectPool.cs(159,34): error CS0246: The type or namespace name `PoolingParam' could not be found. Are you missing an assembly reference?".
    How can I fix it?
     
  22. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    I will check the latest version of CoreGameKit.
     
  23. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @freeze426
    version1.4.9 has been released.
    This version fixes an error when using CoreGameKit.
     
  24. freeze426

    freeze426

    Joined:
    Feb 17, 2018
    Posts:
    3
    Thank you , it work very well.
    Good job!
     
    WestHill likes this.
  25. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    I stuck with one problem. I make that my bullets can be destroyed by player missile. In this moment bullet instantiates explosion. My problem is that sometimes explosion appears in at the origin (0, 0, 0). (In most cases explosion appears in proper place)
    Could someone help me? How can one fix it?
     
  26. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @DYV
    Bullets is pooled, so when deactivated it moves under PoolManager and resets its position.

    If you want to play the effect at the hit position,
    get the bullet position before the bullet becomes inactive and play the explosion effect there.
     
  27. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    thank you for the answer. Here is my code of bullet:
    Code (CSharp):
    1. public void Hit(int damage)
    2.     {
    3.  
    4.         currentHealth -= damage;
    5.  
    6.         // If the current health is less than or equal to zero...
    7.         if(currentHealth <= 0)
    8.         {
    9.             // ... the enemy is dead.
    10.             Death ();
    11.         }
    12.     }
    13.  
    14.  
    15.     void Death ()
    16.     {
    17.  
    18.         Instantiate(explosion, transform.position, transform.rotation);
    19.         gameController.AddScore (scoreValue);
    20.         Destroy (gameObject);
    21.     }
    As I understand I get bullet position and instantiate explosion before it will be destroyed. Or do you mean something different?

    update: I put PoolManager at scene far outside of camera view and now everything looks fine :) I just wonder if it is OK or better to find another solution..
     
    Last edited: Sep 19, 2019
    WestHill likes this.
  28. chihchanglin

    chihchanglin

    Joined:
    Jul 24, 2015
    Posts:
    28
    Hi,
    I have a scene that have many different power up items dropped dynamically, so I have to change bullet power(damage) at runtime.
    How can I change the "Power" value after bullet spawn at runtime?
    There's a script "UbhPlayerBullet.cs" has "Power" value on it. Should I change that one?
    Any suggestion is welcome. :)
     
  29. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @chihchanglin
    The scripts under the Example folder (eg "UbhPlayerBullet.cs") are sample scripts and have minimal functionality.
    Please edit them freely.
     
  30. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hello @WestHill

    i'm having some issues with callback, i was hoping you could help. I'm sending some callbacks to Playmaker FSM, and it all works fine, however, only with one FSM. In the situation where i have multiple FSMs on the object that has UBH, sending callback to multiple FSM's does not work, events are sent only to one of them, in this case only to first one set to receive the callback.


    Image represents how it is set up, but both callbacks are received by FSM1 only.
     
  31. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @Oshigawa
    I don't have Playmaker so I can't check it.
    Can you send me the smallest Unity project (1 scene, 1 component)?
     
  32. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Sure.
     
    WestHill likes this.
  33. rrahim

    rrahim

    Joined:
    Nov 30, 2015
    Posts:
    206
    I know the asset is meant for 2D games on either x,y or x,z. However I'm hoping to implement it in my project which is in full 3d (x,y,z).

    Is there a way to implement this? And to handle shots as forward, left/right, up/down instead?

    I've used this asset in the past and it's perfect! however I decided to move my game from 2D to 3D, and i would like to continue using this asset in the new project.
     
    WestHill likes this.
  34. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @rrahim
    Sorry, this asset is for 2D or 2.5D games, so the axis of movement cannot be changed.
     
  35. rrahim

    rrahim

    Joined:
    Nov 30, 2015
    Posts:
    206
    I understand. I've already figured out a way to continue using it based on the gameplay of my project.
    Do you have any plans to create a 3D Bullet Hell asset?
     
  36. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @rrahim
    Thanks for the request. but I have no plans at this time.
     
  37. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80
    Hi!

    I acquired your asset some time ago but just recently I decided to use it in a project.

    The problem I´m having, besides the fact that I´m new to C# and game programming is:

    I´m using my custom bullet and it has a particle effect in it.

    I added a field so i can add this particleSystem and, originally it´s in a gameobject that is disabled

    I succeed to make it enable and play the particles when the enemy fires a bullet, but, when it returns to the pool it still enabled...

    anyway, here´s the modifications I did to your code, I´d really appreciate for any guidance to solve this issue

    Thanks in advance

    using UnityEngine;

    /// <summary>
    /// Ubh bullet for sprite2d and rigidbody2d prefabs.
    /// </summary>
    public class UbhBulletSimpleModel3d : UbhBullet
    {
    [SerializeField]
    private Rigidbody m_rigidbody3d = null;
    [SerializeField]
    private Collider[] m_collider3ds = null;
    [SerializeField]
    private MeshRenderer[] m_meshRenderers = null;
    [SerializeField]
    private GameObject[] m_gameObjects = null;
    [SerializeField]
    private ParticleSystem[] m_particles = null;

    private bool m_isActive;

    /// <summary>
    /// Activate/Inactivate flag
    /// Override this property when you want to change the behavior at Active / Inactive.
    /// </summary>
    public override bool isActive { get { return m_isActive; } }

    /// <summary>
    /// Activate/Inactivate Bullet
    /// </summary>
    public override void SetActive(bool isActive)
    {
    m_isActive = isActive;

    m_rigidbody3d.detectCollisions = isActive;

    if (m_collider3ds != null && m_collider3ds.Length > 0)
    {
    for (int i = 0; i < m_collider3ds.Length; i++)
    {
    m_collider3ds.enabled = isActive;
    }
    }

    if (m_meshRenderers != null && m_meshRenderers.Length > 0)
    {
    for (int i = 0; i < m_meshRenderers.Length; i++)
    {
    m_meshRenderers.enabled = isActive;
    }
    }

    if (m_gameObjects != null && m_gameObjects.Length > 0)
    {
    for (int i = 0; i < m_gameObjects.Length; i++)
    {
    m_gameObjects.SetActive(true);
    }
    }

    if (m_particles != null && m_particles.Length > 0)
    {
    for (int i = 0; i < m_particles.Length; i++)
    {
    m_particles.Play(true);
    }
    }
    }
    }
     
  38. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @lzardo2012
    Hi.
    Try to rewrite the part of the particle as follows.
    Code (CSharp):
    1.         if (m_particles != null && m_particles.Length > 0)
    2.         {
    3.             for (int i = 0; i < m_particles.Length; i++)
    4.             {
    5.                 if (isActive)
    6.                 {
    7.                     m_particles[i].Play(true);
    8.                 }
    9.                 else
    10.                 {
    11.                     m_particles[i].Stop(true);
    12.                     // If you need to clear it.
    13.                     // m_particles[i].Clear();
    14.                 }
    15.  
    16.             }
    17.         }
     
  39. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80
    Hi

    Thank you very much!

    I´m on my job right now but as soon as I get home I´ll try it out and let you know!

    Looks like it´ll work!
     
    WestHill likes this.
  40. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80
    Yes, it was needed:

    m_particles.Clear();
     
    WestHill likes this.
  41. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hello @WestHill

    This might be a bit out of your scope, but i'm using UBH in conjuction with Core Game Kit, and when i select Persist between scenes in Core Game Kit i get this when i load another scene

    Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
    The following scene GameObjects were found:
    UbhTimer
    UbhShotManager

    But the worst issue is that even if the error is always present, sometimes the UBH is active, sometimes not.

    Any ideas how to deal with this persistence problem?
     
    Last edited: May 4, 2020
  42. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @Oshigawa
    GameObjects with components that inherit from UbhSingletonMonoBehavior, such as UbhTimer and UbhShotManager, are set to DontDestroy.
    They will continue to survive throughout the game, but that's not a problem.
    It will be reused when UBH is used again.

    If you want to delete it explicitly, you can also use Destroy().
    But I don't recommend it.
     
  43. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Something weird is definitely going on. I'm using my CGK with don't destroy on load via Persist Between Scenes. Now, i have two main menus, one for startup (which includes CGK), and the other one which is a bootstrap so stuff that uses don't destroy on load doesn't get duplicate (without CGK since it's transferred between scenes).

    LevelWaveSettings from CGK is loaded on main menu, and when i load the level it is transferred to the next scene and UBH works ok in most cases, however, sometimes i get the error and the enemies don't fire bullets.



    Sometimes the UbhTimer is included in the message too. What is even more confusing is that i sometimes get the error but the enemies ARE firing and everything seems to be working fine.

    Also, there occurences when the level loads ok, without errors, and i go back to main menu without errors, back to game without errors and so on. But as soon as there's some firing, i.e. ubhshotmanager activating and i return to main menu afterwards i get the error. I must emphasize that i release all bullets before going back to another scene.

    When i get the error when going from main menu to level, UbhShotManager and UbhTimer are DESTROYED, as you can see they're not in the scene.

     
  44. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @Oshigawa
    Version 1.5.0 was released earlier, so please try to update it.

    If version 1.5.0 still has the same problem, can you send me your smallest project?
    We need to find out if the problem is in UBH or in the project.
     
  45. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Oh shoot, i didn't update. I'll check it out and let you know asap.
     
    WestHill likes this.
  46. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    That sorted it out, thanks.
     
    WestHill likes this.
  47. Mike891

    Mike891

    Joined:
    May 18, 2019
    Posts:
    23
    I search that too. Do you have new plans for 3d?
     
    WestHill likes this.
  48. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @Mike891
    I thought about it, but that would be a different asset.
    UBH is a 2D asset and is designed for it.
     
  49. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hi @WestHill

    Sorry for bugging you, there's another small issue. Sometimes it happens that enemies are firing their bullets at a 90 degree angle. You can see how it looks in the video, all the bullets should move towards the player.



    Also, here's a screenshot from the video, with the yellow dotted line being the bullet trajectory which is not good.



    I'm using linear lock on shot, i call ubh.StartShotRoutine(), when the shot is fired i call ubh.StopShotRoutineAndPlayingShot().I'm using shotroutine instead of startshot so i don't have to write actions for every shot type.



    I do get warnings in the console though:

    This bullet is not found in m_bulletList.
    This bullet is already added in m_bulletList.

    Also, when i click on the object holding the linear shot script i see that the angle is changed to 90 degrees.

    Bullets are properly released using UbhObjectPool.instance.ReleaseBullet(ubhbullet, false);
     
    Last edited: May 12, 2020
  50. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @Oshigawa
    Hi.
    Are there any prefab or in-scene instances of Enemy where the shot angle is 180?
    If they are not the cause, send me a minimum project that is reproducible, as I want to investigate.