Add Rain to your Unity Games! | Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ก.พ. 2025

ความคิดเห็น • 41

  • @AvianFluu
    @AvianFluu ปีที่แล้ว +12

    Thank you for the tutorial! For anyone else using this in an FPS project and would like for their rain to be slightly offset from the players movement for a more believable look, I created a script to smoothdamp the rain to the players position over a small amount of time - this just adds to the look a bit.
    I imagine you will likely need to play with the numbers a bit for your personal project.
    (Careful where I put Vector3(dot)zero; I need to remove the link so youtube doesn't mark the comment as spam)
    public class Rain : MonoBehaviour
    {
    ///
    /// The point of this script is to have the rain follow the player at a slight offset
    /// this makes it so that as the player runs the rain doesn't match u perfectly, makes the rain more believeable as u run past some particles
    ///
    //rainSmoothSpeed is how fast the rain will smoothdamp to the player pos, .2 seconds right now
    private float rainSmoothSpeed = .2f;
    //player
    public Transform player;
    //player pos
    Vector3 currentPlayerPos;
    private Vector3 velocity = Vector3(dot)zero;
    // Update is called once per frame
    void Update()
    {
    //player pos but I'm adding -20 to the X because it seems like the particle zone does not use the center, offset to keep player near the center of the particle zone
    //also setting y to 15 to keep it above player (its rain)
    currentPlayerPos = new Vector3(player.localPosition.x - 20, 15, player.localPosition.z);
    //do da smoothdamp to player pos
    transform.position = Vector3.SmoothDamp(transform.position, currentPlayerPos, ref velocity, rainSmoothSpeed);
    }
    }

    • @sandycolours641
      @sandycolours641 ปีที่แล้ว +3

      thanks very much good sir/madam/somthingelse

    • @RecombobulatedStuff
      @RecombobulatedStuff ปีที่แล้ว +3

      you could just set the world space of the system to world instead of local in the settings, then the particles will stay attached to the world instead of the player but will still spawn around it

    • @AvianFluu
      @AvianFluu ปีที่แล้ว +1

      @@RecombobulatedStuff The main point of this script is to keep the particles from sitting in the same spot while the player moves around to give the effect that the rain is in the world while it follows the player. I don't think your solution would do the same thing.

    • @_strangeways_
      @_strangeways_ 6 หลายเดือนก่อน

      ​@@AvianFluu That's exactly what it does. If the particle positions are relative to world space then even if the emitter moves the particles don't follow the emiiter because they aren't relative to emitters position which is what local means, using world space looks more realistic than using local with a lerp/smoothdamp and it's its intended function.

  • @AlqueMeteor
    @AlqueMeteor 21 วันที่ผ่านมา +1

    awesome rain effect and straight to the point!

  • @callmesammyboi
    @callmesammyboi 2 หลายเดือนก่อน +1

    2 years later still incredibly useful thank you so much for the tutorial!

  • @ROCKSMASHER
    @ROCKSMASHER 8 หลายเดือนก่อน +2

    Thank you bro it helped a lot a perfect short tutorial straight to the point, you are underrated man

    • @LordEvilM44
      @LordEvilM44  8 หลายเดือนก่อน

      Appreciate it, glad it helped 😀

    • @ROCKSMASHER
      @ROCKSMASHER 8 หลายเดือนก่อน +2

      @@LordEvilM44 :)

  • @Massive-3D
    @Massive-3D 2 ปีที่แล้ว +2

    Awesome! I can not wait to use this to make rain, snow, hail and sleet in my game.

  • @Huy44-dev
    @Huy44-dev 2 หลายเดือนก่อน +1

    thanks so much! it's very easy and good! i love it!!!!!!!!

  • @Crashlikag6
    @Crashlikag6 2 ปีที่แล้ว +15

    Now I really want to make something that requires rain lmao

  • @ReyGameDev
    @ReyGameDev 2 ปีที่แล้ว +4

    Very helpful! Keep up the great work!

  • @wicgamesdev
    @wicgamesdev 7 หลายเดือนก่อน +1

    Thanks mate!

  • @ivanmj123
    @ivanmj123 8 หลายเดือนก่อน +1

    Good job i will use it in a project, tahnk you

  • @MilkIsYum
    @MilkIsYum 5 หลายเดือนก่อน +1

    Brilliant!

  • @Haffey.z64
    @Haffey.z64 2 ปีที่แล้ว +2

    Nice vid. Please make more tutorials!

  • @thegodoftheworld
    @thegodoftheworld ปีที่แล้ว +1

    Oh my god ,you're awesome!!!!

  • @sebiosebio7524
    @sebiosebio7524 ปีที่แล้ว +1

    Thanks alot its working even on 2D

  • @Frodmoney
    @Frodmoney ปีที่แล้ว +1

    lit video

  • @sandycolours641
    @sandycolours641 ปีที่แล้ว +2

    i suggest writing a scripot to make the rain follow the player but not rotate with the nplayer good tutorial though thanks

  • @pacoantonio1573
    @pacoantonio1573 ปีที่แล้ว +1

    Good job!

  • @余唯聖
    @余唯聖 ปีที่แล้ว +1

    Hello I have a question, Collision's type I choice world then i will have two problem. 1. when the shape scale too big ,rain will through my floor and house 2.when so many object in the Particle System range that will have the same problem

  • @soumikGameDev9599
    @soumikGameDev9599 2 ปีที่แล้ว +2

    grate video

  • @PlaneMusic46294
    @PlaneMusic46294 ปีที่แล้ว +2

    is there a way to make a weather CYCLE so over time it rains randomly? please

  • @ahmetomercicek5848
    @ahmetomercicek5848 9 หลายเดือนก่อน

    Well, in Particle Effects, for example, we make it snow, but we do not want every grain to be the same. What should we not do for this?

  • @1actose
    @1actose 2 ปีที่แล้ว +3

    Poggers vid!

  • @theticksquad8218
    @theticksquad8218 ปีที่แล้ว +1

    I have an issue that the rain particles are not showing up when I enter play mode.

    • @liornaveh192
      @liornaveh192 หลายเดือนก่อน

      Do you have a solution for that cause i have it too?

  • @Davimations
    @Davimations ปีที่แล้ว +1

    bbut it wass nice

  • @EvilXero359
    @EvilXero359 ปีที่แล้ว +1

    This is what's missing in Subnautica

  • @nebuladevelopments
    @nebuladevelopments ปีที่แล้ว +3

    Is this good performance wise, if it's covering an extremely large area? It kinda ruins the immersion if it's following the player

    • @LordEvilM44
      @LordEvilM44  ปีที่แล้ว +2

      The thing is when it's covering a large area the particles will constantly run even when the player isn't in that part of the map making it lag or drop fps, witch you don't want, and you could use Occlusion Calling or make a chunk base system to only render the particles when the play is near.

    • @KM-dh4st
      @KM-dh4st ปีที่แล้ว +3

      Wouldn't it be better to set the rain particles to world space (instead of local space)? That should solve the problem.

    • @NorthstriderGaming
      @NorthstriderGaming ปีที่แล้ว +2

      you gotta change the simulation space from local to global. This way the particles stay where they fall and wont follow the player. Alternatively another approach would be using a GFX-Graph als these are made for large amounts of particle effects in paticular

  • @_LeMinhTanAn
    @_LeMinhTanAn ปีที่แล้ว +1

    hay quá

  • @Davimations
    @Davimations ปีที่แล้ว +1

    tooo fast!

  • @Squerl2005
    @Squerl2005 2 ปีที่แล้ว +3

    Thanks this really helped me It's nice and simple, but I find this color to be better for rain 9099A1.

    • @LordEvilM44
      @LordEvilM44  2 ปีที่แล้ว +2

      I'm happy it helped you.