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. Ren-the-Unclean

    Ren-the-Unclean

    Joined:
    Nov 7, 2012
    Posts:
    10
    Hi WestHill,

    Just picked up the asset and I am loving it so far!

    I flip my sprites around the Y axis (doing a horizontal shooter thing, so it is for facing direction) and it looks like the aimed shots don't compensate for this, giving me mirrored shots.

    Is this anything you could take a look at or intend to support? You can see it in the demo just by putting 180 in the Y rotation for the demo ship that is firing.

    Thanks!
     
  2. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi

    Thank you for the report.
    I will fix that problem in the next version.

    If you want to fix quickly, please replace the sprite(y angle 180) as a child of the shot root.

    Regards.
     
  3. Ren-the-Unclean

    Ren-the-Unclean

    Joined:
    Nov 7, 2012
    Posts:
    10
    Thanks for the fast reply!

    I fixed it temporarily by just setting the transform rotation to identity every frame for now, so I should be good until whenever you can get to it.

    Thanks again!
     
  4. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Thumbs up, that would be a neat feature.
     
  5. Adoll

    Adoll

    Joined:
    Apr 16, 2016
    Posts:
    20
    Hi, is there a way to mark the shot angle following the rotation of the object? the translation following works well. I wanted to add the function in the base shot class, but found out that the angle property is in each sub class with different names but the same functionality. Writting the same code in each of them is not what I want to do. Maybe you have done something but I haven`t figured out
     
    Oshigawa likes this.
  6. Oshigawa

    Oshigawa

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

    Yeah, that would be really cool, i think it would make an asset a well rounded solution for all shot related purposes.
     
    Last edited: May 11, 2017
  7. ZouhairSerrar

    ZouhairSerrar

    Joined:
    Oct 17, 2016
    Posts:
    4
    I've noticed a bug in the current version. When you create an object pool, you'll have to make sure it is positionned at the center (0, 0, 0), otherwise, any bullet shot will not be located at the center of the shot controller's transform, but will have a relative position equal to the absolute position of the object pool in the scene.
     
  8. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi, I used local position, but if the impact on performance is small, I will change it to global position.
     
  9. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    Hi

    How is the performance on mobile?
     
  10. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi

    Uni Bullet Hell works on mobile.
    Often it depends on the performance of the device and the project.
     
  11. SolarFalcon

    SolarFalcon

    Joined:
    Nov 28, 2015
    Posts:
    170
    I can say that it's performance on mobile is pretty good.

    I do get some strange behavior if bullets are collided with immediately after they are shot though, sometimes it disrupts the patterns. Also, sometimes it will instantiate bullets at the origin point and then move them to where they should actually appear. Not sure if this is UBH or my code though.
     
  12. SolarFalcon

    SolarFalcon

    Joined:
    Nov 28, 2015
    Posts:
    170
    I will say that homing shots do NOT work very well at all. It will constantly lock on to the same enemy even if that enemy is not active in the hierarchy. I had to add a little hack to fix that for my game.

    Homing should take a list of active objects and possibly randomize what ACTIVE enemies it will lock on to. Yes I am using 'tag' option.
     
  13. Ren-the-Unclean

    Ren-the-Unclean

    Joined:
    Nov 7, 2012
    Posts:
    10
    Hi WestHill,

    Looks like this issue (rotating a shot control makes aimed shots mirror, rather than staying on target) persists in 1.2.7.
    Any update on if this will be fixed in a future version?

    Thanks!
     
  14. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi
    I added a random selection flag in the next version.
    Please wait a few days.
     
    SolarFalcon likes this.
  15. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    I fixed it to move on global position and rotation with ver1.2.7.
    Can you send me the smallest project?
     
  16. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    I only got a few questions and I played around with the Shot Showcase:

    1. Is there any way to actually reload the bullet pattern through manual time instead of only waiting until the bullets disappear from the screen? Might come in handy for those that want to program ones that only shoot when it sees the player.

    2: In Enemy Tentacle Parent when using Linear Shot Tentacle Bullets, why do all the bullets disappear when a child bullet enters the no-bullet zone or when the parent bullet disappears? Should it make sense that the children continue to do their thing when those individual bullets disappear through collision or exiting bounds?

    Behavior problem for tentacle bullets:

    Any child tentacle bullet is invincible against player ship
    Any child bullet that enters bullet destroy zones destroys all bullets
    When center bullet, when enabled, hits the player, the whole tentacle disappears

    Solution: Allowing each individual bullet to be removed upon collision with anything that removes bullets. Only when the last bullet gets removed, then the tentacle object, consisting of only the root, can be properly removed.

    I am actually looking forward to trying this thing out to experiment the possibilities. I am sure that this will get better and better.

    P.S. I also dig the sine bullet pattern, but it could be improved by implementing something based on the periodic function so that bullets can travel like sine, and best made as a different version of sine pattern:

    y = A sin(Bx + C) + D
    • amplitude is A
    • period is 2π/B
    • phase shift is −C/B
    • vertical shift is D
    https://www.mathsisfun.com/algebra/amplitude-period-frequency-phase-shift.html


     
  17. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Thank you for your request.
    I will think whether to include it in future plans.
     
    MrJBRPG likes this.
  18. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    I also got a question in regards to the shot control and shooting from the desired object. I have attempted to get the bullets to shoot from the desired game object, but they always spawn from the center of the scene, based on initial position of the UBH object pooler.

    I am curious to know how the transform inside the UBH Base Shot or other derivative classes manage to assign the transform to the object itself. Your demos made it successful while my own implementation does not.

    If anyone knows about this and provides explanation, it will be very helpful.
     
    Last edited: Jun 9, 2017
  19. Ren-the-Unclean

    Ren-the-Unclean

    Joined:
    Nov 7, 2012
    Posts:
    10
    Hi WestHill,

    You can reproduce this behavior with the following steps:
    1. Load UBH_ShotShowcase and start it.
    2. Change to shot type 2, Linear LockOn
    3. Select the ShowcaseEnemy gameObject, and put 180 in the Y rotation in its transform.

    Thanks again!
     
  20. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi

    This issue has been fixed next version (ver1.2.9).

    Thx.
     
  21. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    Hi there, I have decided to make a subclass for UbhBullet and I did make all the private values protected to subclasses can access, but I wonder where in the script files that the component UbhBullet gets added into the existing prefabs?

    Edit: Found those inside the UbhObjectPool that gets the prefab gameObject and then AddComponent<UbhBullet>(). It seems like I either have to include all of those custom features inside the main class or tweak it in some way that it detects whether the UbhBullet is already inside or not. Probably the latter might make more sense. I will see what I can do myself in the meanwhile.
     
    Last edited: Jun 29, 2017
  22. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi
    UbhBullet is added by GetBullet method of UbhObjectPool.cs.
     
  23. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    I am also curious about the Base Shot with its autoRelease coroutine. I wonder why you decided to use that on a shot that created bullets and then call the object pool rather than giving the auto-release timer on the bullets themselves?

    I believe that if the auto-release (aka auto-despawn time) was used on the bullets themselves, then it might have costed more computing time.

    I like to know your reason behind this because your ways of handling multiple objects with one object seems like a nifty way to improve computation speed.

    Also, I want to set angle of of the bullets being shot based on the transform.up of the shot pattern instead of the angle parameter. The only thing I know is that I have to use a lock-on and then make a new object that is away from the shot pattern. Let me knwo whenever you are available.

    P.S, I am using your scripting add-on to make a game involving multi-directional shooting (Geometry Wars, Robotron, Guardian Force, Asteroids, etc.)
     
    Last edited: Jul 5, 2017
  24. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Thanks for the suggestion!
    I will update scripts to make assets better.
     
  25. Ren-the-Unclean

    Ren-the-Unclean

    Joined:
    Nov 7, 2012
    Posts:
    10
    I just checked out the LockOn changes and it works super well, thanks!

    Unfortunately I think this change broke shot patterns that don't lock on when they are rotated (this may be what MrJBRPG is referring to as well, though I am not sure). It looks like the angle defined on the Ubh Shot script is now absolute, rather than relative.

    You can reproduce it in the UBH_ShotShowcase in the same way as before, but put 180 in the Z rotation of the ShowcaseEnemy's transform.
    The bullets will continue to go downwards, rather than respecting the rotation of the game object the script is attached to.

    Thanks!
     
  26. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi

    I changed from the local angle to the global angle to fix the problem that the rotation is not working properly when the sign of the scale is changed.

    Fortunately, parent angle problems can be fixed from the script.
    It only adds the parent's angle to the shot's angle property.

    I am planning to find a nice solution, but until then I think that you can use the workaround in the script.

    Thank you.
     
  27. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    Yes, that is what I am talking about when it comes to shot patterns that do not have the lock on feature that mimics the multi-directional shooting games: Shot pattersn are / were initially designed with absolute angles from the editor instead of relative to an object. Same goes for the velocity of bullets if the rigidbody 2d/3d is applied.

    I like to know what part of the script involves adding the parent's angle to the shot angle's property? It would be great to know clearly so that others can make a work-around cleanly until the next patch comes.

    Also, having the local angle of the shot for movement could explain why bullet speeds act wonky when any moving object shoots.

    Perhaps there should be a toggle switch to allow shots (from Base Shot) to be fired relative to the object being shot from as an alternative to absolute angles.

    I am looking forward to the next update that hopefully fixes that rotation and angle problem.

    Also, whenever you make an update to your asset, take your time to make a list that describes all the specific changes made onto the asset so that users of the script better know what improvements have been made like how many professional software developers keep a change log to keep clear of past changes done.
     
    Last edited: Jul 10, 2017
  28. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Thanks for the feedback.
    I will update this asset in a few days.
     
    Last edited: Jul 11, 2017
    MrJBRPG likes this.
  29. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    I should have informed everyone here earlier but I have noticed a movement behavior problem, especially when using the lock-on aim trick when it comes to moving bullets that also adds movement from other sources like the player ( especially with Rigidbody2d.velocity applied) by making a child class of UBH bullet with its UpdateMove after base.UpdateMove as it creates inconsistent movement. I have tested it with the Lock-on N-way shot, and it may apply to all bullet classes.

    I do hope that the next update addresses the bullet angle movement issue so that I can smoothly add other sources of movement to the bullets without getting such wonky behavior.
     
  30. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi.
    UBH ver 1.3.1 released.
    Added flag of inherit UbhShotCtrl's angle to bullets.

     
    Last edited: Jul 20, 2017
    MrJBRPG likes this.
  31. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    So far so good on the latest update as it now simplifies the process of shooting bullets in any direction desired.
    However, when adding in other sources of movement to the object holding the prefab, it can mess up the movement significantly such as moving the bullets relative to the direction of a fast-moving object because somehow the updateMove changes the local position of the bullets rather than global position of the bullets. It may also have something to do with implementing physics 2d on a few objects, and that is a different story.

    Anyways, I will have more fun using it thanks to that inherit angle update.

    Also, if you want multi-directional shooting to happen smoothly, then set the angle at 0 so it shoots towards the local up vector.
     
  32. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    I decided to make a separate post about movement issue from bullets when adding other sources of movement outside of the ubh bullet.

    I somehow am stumped when attempting to add different "velocities" to a ubhBullet because it messes up the movement of the bullet, like adding the frame-snapped velocity of a player's fast speeding car to the bullet that has been shot.

    Bullet moves based on its up vector + speed, and the driver also moves based on its up vector with its own speed.

    I have posted the question that should hopefully delve deeper into the issue:
    http://answers.unity3d.com/questions/1383889/adding-multiple-global-velocities-to-an-object.html

    I will send in my work if anyone needs to test it out through PM.
     
  33. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi,
    Could you send me your smallest project?
    I will check about it.
     
  34. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    Sorry about it... I solved that thing myself, and using that draw line gizmo came in very handy.

    Here is the link that helped me debug my own velocity problem:
    http://answers.unity3d.com/questions/211910/getting-object-local-direction.html

    Anyways... I am very pleased that the inherit angle update simplified the process and expands the game design possibilities.

    Also I may have one suggestion for a different shot type: Laser-like.

    Basically, all the bullets shot during the shooting period will stay lined up based on the origin and direction of the moving objects like how laser weapons work from various video games.
     
  35. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Good!
    If you have any questions, please contact me. ;)
     
  36. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    Hi

    I just got this asset together with core game kit.
    To me it’s not clear what I need to do, to let them work together. Is there a tutorial for this setup?
    The read me file has no info on this and don’t seem to find anything with the links on the unity store.


    Btw the asset is really nice ^^
     
  37. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi

    You need to comment out one line.
    Enable a definition "USING_CORE_GAME_KIT" in "UbhObjectPool.cs".
     
  38. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27

    Hi one more question.

    (Haven’t tried the script change jet but just removed the top // simbols in front of “#define USING_CORE_GAME_KIT” right?

    However. My game runs at 400 fps at the moment. When I load the demo scene it runs at around 60.

    When I go back to my project it now also runs at 67. Why does this happen, and how can I reset it?
     
  39. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27

    Never mind XD when playing the demo scene it enables v sync. I simply had to disable it again.
     
  40. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
  41. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    Ok one more question XD

    Everything works. Only thing I have a problem with is the pooling?!

    I made a Poolbos pool for the bullet. Unibullet takes the bullet and uses it. The bullet is a killable, so the core game kit removes the object and puts back into the poolbos pool.

    However when unibullet takes the bullet it puts it in its own pool list.

    This wouldn’t bother me, but the console keeps throwing caution message that keep stacking:

    This bullet is already added in m_bulletList.
    UnityEngine.Debug:LogWarning(Object)
    UbhBulletManager:AddBullet(UbhBullet) (at Assets/UniBulletHell/Script/Singleton/UbhBulletManager.cs:45)
    UbhObjectPool:GetBullet(GameObject, Vector3, Boolean) (at Assets/UniBulletHell/Script/Singleton/UbhObjectPool.cs:214)
    UbhBaseShot:GetBullet(Vector3, Boolean) (at Assets/UniBulletHell/Script/ShotPattern/UbhBaseShot.cs:130)
    <ShotCoroutine>c__Iterator0:MoveNext() (at Assets/UniBulletHell/Script/ShotPattern/UbhLinearShot.cs:45)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)


    This bullet is already added in m_bulletList.
    UnityEngine.Debug:LogWarning(Object)
    UbhBulletManager:AddBullet(UbhBullet) (at Assets/UniBulletHell/Script/Singleton/UbhBulletManager.cs:45)
    UbhObjectPool:GetBullet(GameObject, Vector3, Boolean) (at Assets/UniBulletHell/Script/Singleton/UbhObjectPool.cs:214)
    UbhBaseShot:GetBullet(Vector3, Boolean) (at Assets/UniBulletHell/Script/ShotPattern/UbhBaseShot.cs:130)
    <ShotCoroutine>c__Iterator0:MoveNext() (at Assets/UniBulletHell/Script/ShotPattern/UbhLinearShot.cs:45)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    UbhLinearShot:Shot() (at Assets/UniBulletHell/Script/ShotPattern/UbhLinearShot.cs:21)
    <ShotCoroutine>c__Iterator1:MoveNext() (at Assets/UniBulletHell/Script/Controller/UbhShotCtrl.cs:144)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)


    I get the same problem when I don’t create a poolbos pool in advance. I guess that’s because I use the killable component to remove the bullet.


    Is there a way around this? Or can I ignore this massage?
     
  42. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Please call "UbhObjectPool.instance.ReleaseBullet (ubhBullet)" method when returning Bullet to pool.
     
  43. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    Sorry but this is not really an option.
    One of the main features of the Dark Tonics Core GameKit, is the ability to use its kill component.
    When you advertise that the asset works with the Core Gamekit Pooler:

    "*Supports object pooling system of Core Gamekit (Dark Tonic inc.)"
    I expect it to function in combination with that said asset.

    On Play, unibullet creates: UbhObjectPool (Why?)
    It takes the bullets from the Core GameKit and puts it in its own pool.

    The error "This bullet is already added in m_bulletList" (once all bullets have been used once) should not happen in the first place. Unibullet should simply use the Core GameKit pooler without putting the bullet in its own pool.

    I can only imagen that this is a bug?! Because otherwise this asset simply does not work together with the Core GameKit as advertised.



    (And yes, I did Enable a definition "USING_CORE_GAME_KIT" in "UbhObjectPool.cs".)
     
  44. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    It is only temporarily transferring parents to control bullets at UBH.
    Bullet's is not new created.
    After using, it need to call the ReleaseBullet method to return to PoolBoss.

    Current UBH can cooperate with PoolBoss of CoreGameKit, but it can not cooperate with Killable.
    (Another user who wanted cooperation with CoreGameKit first was satisfied with the current function.)

    I appreciate your suggestion.
    I will improve it in the future.
     
  45. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    Thank you for you're reply.

    For now, I will keep unibullet on the side line.
    I still think it is a great asset!

    Hope to see something that works with killable somewhere down the line ;)
     
  46. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hello Nishioka,

    i'm having slight trouble with the shot fire callback events and i need your help :)

    I use an enemy ship prefab which instantiates (on runtime) a Gunpoint object which holds UbhShotCtrl and a bullet preset, doesn't matter which. I've got the Gunpoint prefab set up like this



    I'm using Playmaker so i set up an event proxy to communicate with FSM and play the animation when the shot is fired, but when i instantiate the gunpoint prefab, settings are erased. Is there a way to set it up on runtime, since i haven't found out how.

     
  47. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    @Kruko
    I do not have Playmaker, so I am not familiar with it.
    I plan to be able to add shot callback events from the code in the next update.
     
  48. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Looking forward to it, it's kinda useless if you lose the callback on instantiating. Don't get me wrong, but it really needs to be possible to be set from code on runtime :)
     
    Last edited: Oct 14, 2017
  49. WestHill

    WestHill

    Joined:
    Oct 29, 2012
    Posts:
    174
    Hi
    @agito1987
    @Kruko
    UBH 1.3.2 has been released. It includes the following changes.
    Fixed problem when reusing by Core Game Kit's Killable component.
    Changed shot's callback event to public variable.
     
    SolarFalcon and Oshigawa like this.
  50. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    You're the man!
     
    WestHill likes this.