How to Simulate Projectiles WITHOUT PHYSICS in Unity3D

Поділитися
Вставка
  • Опубліковано 4 лис 2024

КОМЕНТАРІ • 39

  • @amac333
    @amac333 16 днів тому

    this is perfect, I tried a bunch of different approaches over the last couple days but this exactly what I was after.

  • @Alex-ck4in
    @Alex-ck4in Рік тому +5

    love pure programming videos, nicely done

  • @reggieisnotadog4841
    @reggieisnotadog4841 10 місяців тому +1

    THANK YOU! This explains this in such a nice way and shows an actual use case.

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

    I liked how condensed you made you video and you explained it very well. thank you

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

    Dude great fucking video, love how direct and clear and concise it is. You helped me understand and follow without wasting my time.

  • @ck88777
    @ck88777 2 місяці тому

    This might be fine for some applications but for a slow moving projectile youll notice it doesnt act like a real projectile. Real projectiles decelerate on the ascent until the vertical velocity is 0 at the peak, then accelerate on the descent. Projectiles' time in flight is also dependent on the initial velocity and distance, which bezier curves fail to account for. I also want my projectile to continue past the point of the target, which would require a further modification that I havent figured out yet.

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

    cant describe how wonderful this video is THANKS ALOT!

  • @payasoprince9333
    @payasoprince9333 11 місяців тому +1

    This is really fantastic. Thanks a ton for the video, dude! I noticed that depending on Control's position, the wirespheres become either closer or farther from each other. Because of this, the speed of the projectile changes and can add an unwanted "easing" effect. My problem is that the specific curves I need have this easing issue. Is there anyway to avoid this with curves that smoosh the wirespheres closer?

    • @igorkim3558
      @igorkim3558 11 місяців тому

      you don't need to set transform.position = evaluate(t), instead use transform.Translate towards next checkpoint

    • @payasoprince9333
      @payasoprince9333 11 місяців тому

      @@igorkim3558 sorry, I don’t quite understand. May I please see an example?

  • @jackwo95
    @jackwo95 7 місяців тому

    Dude you saved my life thank you so much

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

    Exactly what i needed, thanks

  • @asalaj5885
    @asalaj5885 Місяць тому

    Can you move a and b when projectile is already on the move?

  • @dbweb.creative
    @dbweb.creative 5 місяців тому

    My question is, why not use Animator curve field to evaluate??

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

    awesome tutorial!

  • @dertobbe1176
    @dertobbe1176 10 місяців тому

    Thanks alot my mate

  • @Maskeowl
    @Maskeowl 9 місяців тому

    u are a legend man

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

    This is gold, wp brother

  • @Ghin_Antonic
    @Ghin_Antonic 11 місяців тому

    Double checking but pretty sure you can, this can be adapted for 2D fairly easily yes? Would there be any issues if we set it up so when the projectile hits something early it also disintegrates?

    • @ForTheOmnissiah
      @ForTheOmnissiah 9 місяців тому

      If the projectile object is destroyed before it reaches the endpoint, it won't exist any longer to cause any reference problems, though I don't see where references would necessarily cause an issue here. The way it's shown in the video is a brittle way to implement this behavior tbh. All of this can be achieved by modifying the evaluate function to accept 3 Vector3's and the float t, calculate, then just give the calculated Vector3 back to whoever called it. There's no need for a class to extend MonoBehaviour in order to provide this functionality. You could make a static class that just extends Object with just this function in it and it'd work the same, except with way fewer steps, just call it from literally anywhere and get your Vector3.

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

    Cool~ Thanks!

  • @worldkho
    @worldkho 5 місяців тому

    legend

  • @kyroic6128
    @kyroic6128 10 місяців тому +1

    This same method can be used for my archer towers in my tower defense project?

    • @UnofficialCyane
      @UnofficialCyane 4 місяці тому

      No sorry it only works for scifi lasers and stuff

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

    Nice 👌

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

    This is great when you know points A and B and C (max height). What if you only have point A, an angle, and speed of the velocity; where velocity is the forward vector of your object, who's length is 1. This is what I've been trying to wrap my head around. I need to be able to draw the trajectory based on only my velocity, speed and angle. I've looked into parabolas and stuff, but none of it clicks with me lol.

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

      look into kinematics

    • @christopheremerson2848
      @christopheremerson2848 4 місяці тому

      Can you not have a function in QuadraticCurve like this?
      public void SetTarget(Transform b) { B = b; }
      Then before firing your projectile call SetTarget and insert your target's transform.

  • @TREXYT
    @TREXYT 11 місяців тому

    Cool but you did with only 1 bullet, im pretty sure that if we do it with tons of bullets then it will drop fps a lot, by a lot i mean really a lot!

    • @Rytech_Dev
      @Rytech_Dev  11 місяців тому

      well of course the frame rate is inversely proportional to the number of objects. More stuff = More computation time = Less FPS. Since this is a math based approach to ptojectiles, the Unity Job system can remedy this by introducing multithreaded calculations. Hence, the support for larger amounts of projectiles or bullets.

    • @TREXYT
      @TREXYT 11 місяців тому

      @@Rytech_Dev can you do a tutorial on that please ? This is really interesting, also multithreading works on mobile project ? Thanks

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

    but how wuld you detect collision detection? does oncollisionenter work?

    • @Rytech_Dev
      @Rytech_Dev  Рік тому +4

      This system uses pure mathematics and there is no influence of physics.
      To add in collision detection, in the update function you can run Physics.CheckSphere to see if any objects have entered a defined distance from your object:
      docs.unity3d.com/ScriptReference/Physics.CheckSphere.html

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

      For more information on collision detection here is a video I made a while back: ua-cam.com/video/NNJs4wYZGvs/v-deo.html

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

      @@Rytech_Dev yeah, but do you think the oncollisionenter events will work? i dont think you need to actually move the object thru physics for it to trigger these events

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

      "Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached." Therefore, no.

  • @MEMUNDOLOL
    @MEMUNDOLOL Рік тому +4

    i hate myself for abandoning math in school

    • @cure4883
      @cure4883 Рік тому +5

      Trust me, math classes in pre-college, would essentially be of little to no help in game dev. Don't hate urself, hate ur school for not making it more engaging.

  • @nTu4Ka
    @nTu4Ka 9 місяців тому

    Cool video!
    Btw. You can calculate point on Bezier curve in single line:
    ua-cam.com/video/pnYccz1Ha34/v-deo.html