Це відео не доступне.
Перепрошуємо.

Unity VR Optimization : Object Pooling

Поділитися
Вставка
  • Опубліковано 31 січ 2023
  • In order to get the most out of our performance, we need to know how to use Object Pooling, which I cover in this video!
    One problem we can run into when developing our games can occur when we Instantiate and Destroy hundreds of Objects in a short period of time. A good example of this would be having a gun that generates hundreds of bullets when we shoot a gun. Instead of losing tons of CPU cycles to this wasteful process, we can use Object Pooling!
    🍤Check Out My Patreon🍤
    / fistfullofshrimp
    Written Tutorial
    fistfullofshrimp.com/unity-vr...
    Machine Gun Asset
    assetstore.unity.com/packages...
    Unity Object Pooling Documentation
    docs.unity3d.com/ScriptRefere...
    Music Credits
    ------------------------------
    Floating by Smith The Mister Hey Yeah, by Smith The Mister
    Smith The Mister Smith The Mister
    Free Download / Stream: [No Copyright Music] Floating by Smith The Mister · Hip Hop & Rap + Calm
    Music promoted by Audio Library Floating - Smith The Mister (No Copyright Music)
    ------------------------------

КОМЕНТАРІ • 22

  • @Sail_VR
    @Sail_VR Рік тому +3

    Fantastic Video!!!
    Adding it to my useful Unity Videos Playlist

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому

      Glad you liked it! I don't know why, but this video was a struggle to get out, so hearing it's helpful means a lot!!!

  • @cryptoversegirl7751
    @cryptoversegirl7751 Рік тому +2

    Looking forward to see more on UnityVR optimization, design patterns and S.O.L.I.D principles. Your videos are amazing!

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому

      That's very kind of you to say. Diving deeper into design patterns would be a blast. If you haven't checked it out yet, you might want to pick up Game Design Patterns by Robert Nystrom. Thanks again for watching! Link to the book listed below if you're interested.
      amzn.to/43q7el2

  • @rishavnathpati
    @rishavnathpati Рік тому +2

    Man I wish I could give you 1000 views each time I watched your videos. So so insightful and useful videos for people like me who are just starting with VR dev in Unity.
    I just had few questions, dont know if you will see the comment or not. But here it goes anyway.
    I am trying to use my Quest 2 controller buttons in a way how we used to do button clicks in keyboard, like Input.GetKeyDown or Input.GetKeyUp. What would be the exact process to make that happen, since in the current state I can just get button click, thats it.
    Anyway, thanks a lot again for your VR Optimisation series, it has helped me a lot

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому +1

      Glad you've been enjoying the optimization series! I've always wanted to learn more about optimizing, so what better way than making a whole bunch of UA-cam videos about it!? lol.
      As for your controller question, I found a forum post that might cover what you're looking for found here.
      forum.unity.com/threads/xr-input-quest-how-to-get-button-inputs-on-oculus-quest.871993/
      You might also get some useful info and ideas from my Input Data video
      ua-cam.com/video/Kh_94glqO-0/v-deo.html
      Sorry I can't get into greater detail due to time constraints, but hopefully this pushes you in a helpful direciton!
      Cheers! 🍤

  • @SetsuneW
    @SetsuneW Рік тому +3

    3:26 Unity just added (2021.3.17) a bunch of combined GetPositionAndRotation and SetPositionAndRotation functions that are supposedly more efficient than just setting each individually, so that might even improve performance a bit more!

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому +1

      I didn't know about this! I'll definitely check it out!! Thanks you for mentioning it.

  • @Arashi256
    @Arashi256 Рік тому +1

    I did my own in December before I realised Unity already gives you this functionality. Here's what I came up with: -
    public class ProjectileManager : SingletonBase
    {
    private static List projectiles;
    private void Awake()
    {
    projectiles = new List();
    }
    public GameObject CreateProjectile(GameObject prefab, Transform spawnPoint)
    {
    GameObject newProjectile;
    if (projectiles.Count == 0)
    newProjectile = Instantiate(prefab, spawnPoint.position, spawnPoint.rotation);
    else
    {
    var lastIndex = (projectiles.Count - 1);
    newProjectile = projectiles[lastIndex];
    projectiles.RemoveAt(lastIndex);
    newProjectile.transform.SetPositionAndRotation(spawnPoint.position, spawnPoint.rotation);
    newProjectile.gameObject.SetActive(true);
    }
    newProjectile.GetComponent().Init(3, 15);
    return newProjectile;
    }
    public void ReclaimProjectile(GameObject projectile)
    {
    projectile.SetActive(false);
    projectiles.Add(projectile);
    }
    }
    Oh well, you live and learn :D

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому +2

      I honestly didn't know Unity cooked up their own solutions until I started writing on this subject for this video. I always thought you had to cook up your own! At least you have a uber deep understanding of the Object Pooling design pattern! Cheers Arashi!!! 🍤

    • @Arashi256
      @Arashi256 Рік тому

      @@FistFullofShrimp Well, I've done it now so I ain't changing it Thanks for the illuminating (if somewhat depressing - given the circumstances) video on the matter!

  • @watercat1248
    @watercat1248 Рік тому

    I have few questions?
    1.If I add object pooling and those object is all in some area in the Sean wean is not in use ?
    For example let say that I weapon that spown object with object pool this object need to by always in this Sean even wean the weapon don't shooting ?

  • @dayshag5257
    @dayshag5257 Рік тому

    can you show us how to make a gun script for Ar's or two handed weapons?

  • @TheBuilderNpc
    @TheBuilderNpc Рік тому

    What would i do if the velocity direction and magnitude was dependent on the actual object that is spawning it?

    • @TheBuilderNpc
      @TheBuilderNpc Рік тому

      For anyone wondering, you can do bullet.Function(position, direction);
      Put this in the get function
      And in the bullet script, you can do
      public void Function(Vector3 position, Vector3 direction){
      "Insert code here"
      }

  • @ThatGuyPumpkin
    @ThatGuyPumpkin Рік тому +1

    Could you make a tut on Iap on oculus app lab

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому

      Funny you mention this. Was going to do a few videos on publishing to Itch.io and Sidequest. I think I can add on one for Oculus App Lab too!

    • @ThatGuyPumpkin
      @ThatGuyPumpkin Рік тому

      @@FistFullofShrimp Thx!

  • @AntonVish
    @AntonVish Рік тому +1

    me: tying to escape from war in Ukraine somewhere in vr and youtube
    youtube: here is a machine gun and billions of bullets 😢

    • @FistFullofShrimp
      @FistFullofShrimp  Рік тому +3

      My apologies. In the future, I will try to make a shrimp gun that shoots shrimp.

  • @Bongo2k
    @Bongo2k 6 місяців тому +1

    please get a new mic

    • @FistFullofShrimp
      @FistFullofShrimp  6 місяців тому

      Subscribe to my Patreon and make these dreams come true!! Seriously though, what about the audio was off? I'm always looking to improve thing, so let me know!