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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to create randomly curved shoot effect like this(from ori and the blind forest)?

Discussion in 'Scripting' started by Le_Tai, Dec 19, 2015.

  1. Le_Tai

    Le_Tai

    Joined:
    Jun 20, 2014
    Posts:
    430
    Look at 1:25, how to make shoot curve randomly and smoothly like that?

     
  2. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    The only thing I could think of would be perhaps using some code to randomly change the gravity modifier in a particle effect and have it fire off when you press a button or key, I wouldn't know how to do that in code yet as I'm still learning though.

    I think the gravity modifier attribute will certainly help you or perhaps tweaking the randomised patricles, though it looks like you want it to go to a specific target which I don't know how to do with GameObjects.
     
  3. Afrodeity

    Afrodeity

    Joined:
    Dec 19, 2015
    Posts:
    12
    Find angle to target. Offset the starting angle of the projectile. Move in the direction its facing. Limit the speed at which it turns towards the target. Lastly, increase the maximum turn speed based on flight duration, so that the projectile doesn't miss its mark.
     
  4. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    How would he randomise that though? Hadn't though of doing it like that but the key thing here is he wants it firing off differently rather than being at a fixed rate.
     
  5. Afrodeity

    Afrodeity

    Joined:
    Dec 19, 2015
    Posts:
    12
    You could for instance use (Random.value-0.5f)*360 to get a random offset from -180 to 180 degrees each time a new projectile is instantiated. This is of course too wide a spectrum for this kind of shot, but I hope this illustrates the idea.
     
  6. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    Oh I see, just a matter of getting it into code form then, makes sense.