Projectile Movement & Why is it Useful? ( Unity Engine Tutorial )

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

КОМЕНТАРІ • 81

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

    I've never been so overwhelmed when writing code, but it was worth it. I wish you would share the codes ready.

  • @Crydonny
    @Crydonny 2 роки тому +7

    Incredible tutorial, took me about 2 hours to implement it correctly as I'm very new to this, but the instructions are really clear and the results are great. Next step is to get it controlled by mobile joystick rather than mouse! Thanks very much!

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

      How did you do that?. I can’t figure out how to do it with mobile joystick, even if you tell me what assets you used, it would help

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

    love you, please have my children this was truly enlightening, thank you so much!

  • @spacedoggames5335
    @spacedoggames5335 8 місяців тому +1

    Incredible tutorial. Thanks you so much for sharing!! So helpful!

  • @zhav3d
    @zhav3d 3 роки тому +3

    I just found your channel. Thanks for all of the high quality content!

    • @ABitOfGameDev
      @ABitOfGameDev  3 роки тому +1

      Hey thank you very much for the support I appreciate it. I hope you will find the future videos interesting as well :D

  • @kingofkilleurs
    @kingofkilleurs 3 роки тому

    2 week ago, I discovered your channel, Congratz ! It's just amazing. Thank you ♥

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

    Great tutorial that really went over the core concepts well!
    I was able to translate into GDScript for Godot with very little trouble.

  • @monetmonteal3181
    @monetmonteal3181 2 роки тому

    I had to get back to my old books just to understand how things are working. Awesome tutorial. Thanks a lot.

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

    I think, Unity needs to create a component like rigidbody or collider etc, which creates trajectory according to the preferences of users. I would be great.

  • @K.Z007
    @K.Z007 Рік тому

    What a genius. Thank you for sharing your valuable knowledge. Any chance to do the jumping with trajectory line showed in this video, I hope could have a chance to see how professionals to implement this with Jump.

  • @katyusha06
    @katyusha06 2 роки тому

    Thank you so much for the tutorial. Excellent work!

  • @munyunu
    @munyunu 2 роки тому +3

    Can you please post the ending code? I have no errors, but mine's not working like yours

  • @igorpopov3364
    @igorpopov3364 2 роки тому

    Thank you for the video! Great job!

  • @AlexJrDev
    @AlexJrDev 3 роки тому +1

    Love the content! Keep it up!

  • @ferozmd9126
    @ferozmd9126 2 роки тому +1

    Can You show the player predictable jump example

  • @sufianahmad621
    @sufianahmad621 2 роки тому

    Very well explained

  • @walldoffstudios
    @walldoffstudios 2 роки тому

    brilliant tutorial!

  • @Jacob-gb1zr
    @Jacob-gb1zr Рік тому +1

    When I type Mathf it doesnt come up green like yours does. Am I doing something wrong?

  • @ScientObject40
    @ScientObject40 2 роки тому +1

    Is it possible to find the right angle and velocity to make the projectile land in a specific point ?

    • @justcore
      @justcore 2 роки тому +1

      I have same task now. Can you please share your experience to me if you solve this task. It would be very useful for me :3

  • @kamaljerome1414
    @kamaljerome1414 2 роки тому +1

    hey people... im having issues with my line being rendered... its showing me two lines and they are not in a cirve but instead straight... how do I rectify this??
    ps: I'm working in 2d

  • @asmicdragon
    @asmicdragon 2 роки тому +1

    How do you connect the rotation of the object with the angle it is currently at? I am using this code for an arrow projectile, maybe that helps you understand better

  • @thiennguyen4481
    @thiennguyen4481 2 роки тому +1

    How can I increase the speed and reduce the travel time ? using CalculatePathWithHeight I don't know which parameters to change/add to make it go faster. And how do I keep the same height but increase the speed and lower the travel time ?

    • @walldoffstudios
      @walldoffstudios 2 роки тому +1

      In the movement coroutine where you use t += time.deltaTime you can multiply that by a float value to alter the speed of the simulation

  • @hana-games
    @hana-games 11 місяців тому

    hi I used this mechanic to make a game similar to tile hop ,, but the problem is the ball stop in the middle it is like the coroutines ends before the ball reach its destination,, at the beginning it work fine after a while it stops.

  • @de132
    @de132 2 роки тому

    For some reason, I can't get Raycast to work
    error CS0246: The type or namespace name 'Raycast' could not be found (are you missing a using directive or an assembly reference?)
    Changing the "using" to reflect UnityEngine.Physics doesn't work for me either. Is there any way to view the finished code to compare?

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

    How can you keep the momentum of the projectile once it reaches the end of the trajectory? I tried using a Rigidbody but it didn't worked if I just slap it

  • @zainuldin9095
    @zainuldin9095 3 роки тому +1

    please make more math tuts

  • @超-s4v
    @超-s4v 2 роки тому

    I did it completely according to the operation steps in the video, but when I was running, the question appeared: the ray passed through the ground, and the ball also passed through the ground, but I added a collision range on the ground, and the ground should not be crossed theoretically. I can't find the reason, can anyone help me?

  • @josepromera2453
    @josepromera2453 8 місяців тому

    How can I get a speed parameter for speed up the projectile?

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

    how do I predict projectile jotting dynamicly moving target?

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

    How would you calculate it in reverse, given the end coordinates?

  • @MilesWingsOficial
    @MilesWingsOficial 2 роки тому

    how could I change the target control to asdw instead of mouse?

  • @ВячеславВинник-ж1г

    How can i flip vertically parabola movement?

  • @day_that_i_die9854
    @day_that_i_die9854 2 роки тому

    How can I make projectile to be parallel to tangent to parabola ?

  • @Ptah1130
    @Ptah1130 3 роки тому +1

    Great channel! Can you do a tutorial on instantiating a different material on an npc each everytime damage decreases its health, say, 25%?

    • @ABitOfGameDev
      @ABitOfGameDev  3 роки тому +2

      Hmm well I don't think that warrants a full tutorial.
      If I understood correctly, You have the base material, and the "DamageMat" material. When the char takes damage, make a coroutine that finds all renderers on the character, and replaces each material with a new instance of DamageMat and you assign the character textures and properties unique to that character to the instanced DamageMat.
      After the coroutine finishes just replace the DamageMat instances in all renderers with the base material.
      Or you could make a shader that modifies itself when the character takes damage. Its a lot simpler to use later, but a lot harder to change if you want a different effect for something else.

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

    Possible to do it through rigidbody instead?

  • @kalpolproductions8558
    @kalpolproductions8558 2 роки тому

    AYYOO THAT BASKET BALL GAME

  • @ThatGuy-pk5su
    @ThatGuy-pk5su 2 роки тому

    Hey, thanks this is really helpful. I actually have the same use of it as you, which is predicting where the player (character) would jump to and how high he would jump. Please could you help with that tutorial? Thanks a lot, I'd really appreciate it.

  • @charlie12486
    @charlie12486 2 роки тому +1

    Can you change the speed of the movement without change the path of the projectile?

    • @ABitOfGameDev
      @ABitOfGameDev  2 роки тому

      Yeah, there is a parameter exactly for that :D

    • @SinusQuell_
      @SinusQuell_ 2 роки тому

      @@ABitOfGameDev I've tried setting the v0 parameter for the Movement Coroutine to a fixed value. Unfortunately, that alters the path. Am I missing something?

    • @walldoffstudios
      @walldoffstudios 2 роки тому +2

      @@SinusQuell_ In the movement coroutine where you use t += time.deltaTime you can multiply that by a float value to alter the speed of the simulation

    • @SinusQuell_
      @SinusQuell_ 2 роки тому

      @@walldoffstudios Nice, thank you! I have to try that later :)

  • @hubagarai3002
    @hubagarai3002 2 роки тому

    Is your gravity negative or positive in the beggining? Becouse If I write negative (My gravity is -9.81f) the Debug says: NaN

    • @ABitOfGameDev
      @ABitOfGameDev  2 роки тому

      I believe the gravity should be positive

  • @devildragon4562
    @devildragon4562 2 роки тому

    Love the video mate. How can i change the speed of the bullet? can't find the parameter for that or where to put it. i am in 2d space

    • @walldoffstudios
      @walldoffstudios 2 роки тому +1

      In the movement coroutine where you use t += time.deltaTime you can multiply that by a float value to alter the speed of the simulation

  • @iamthebubb
    @iamthebubb 2 роки тому

    Can this be used for a sideways curve?

  • @sufianahmad7337
    @sufianahmad7337 2 роки тому

    My shooting object is off from the line of projectile any gesses?

    • @ABitOfGameDev
      @ABitOfGameDev  2 роки тому

      Check the parenting and or check your offset values, as far as i remember all calculations are done with the object at Vector3(0,0,0) then the offset is applied to position it correctly

  • @blackmercy-il9me
    @blackmercy-il9me 2 роки тому

    Hi, say where i can find this code?

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

    Do you have 3d code available to share?

  • @VonBreuss
    @VonBreuss 2 роки тому +1

    Why change speed? It must be permanent! The angle must change, and only the angle!

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

    CODE POSTED IN REPLY

  • @abdugenco3544
    @abdugenco3544 3 роки тому +1

    Great Content!, I SUBSCRIBED for this video :). But even though I watched the video 100 time, I couldn't make it work in 3d can you attach the script to the description please.🥺

    • @ABitOfGameDev
      @ABitOfGameDev  3 роки тому

      Hey thanks for subbing, what exactly is the problem, im not currently home but maybe I can help you out

    • @abdugenco3544
      @abdugenco3544 3 роки тому

      @@ABitOfGameDev I have "Error Offset" from the target position the projectile can't hit the exact mouse position and the error increase by increasing the distance with the target especially on y axes.
      The drawn line also match the projectile arrival position which is different from the real coordination of the mouse position.

    • @ABitOfGameDev
      @ABitOfGameDev  3 роки тому +1

      @@abdugenco3544 i had a similar error when developing. You probably misscaclulated some small variable or used the wrong axis. Here is a list of things where the error might be.
      Chech the axis calculation, for 3D the distance is the combination of x and Z axis.
      Chech if you may have used sqrtMagnitude instead of Magnitude.
      Check you offsets from your zero position maybe you misscalculated something there.
      And check the video VERYY carefully for anything you might have done differently, im 99% sure the code in the video is correct.
      If nothing works comment here and we'll work something out (discor or something)

    • @ABitOfGameDev
      @ABitOfGameDev  3 роки тому

      @@abdugenco3544 i too have meny times been in your exact position wherr i think i did everything exactly as in the vid but it doesnt work. Its certainly some tiny bit of basic code you overlooked

    • @abdugenco3544
      @abdugenco3544 3 роки тому

      @@ABitOfGameDev Everything looks fine but I couldn't get it to work properly.😢😵‍💫

  • @CurlyScheck
    @CurlyScheck Рік тому +10

    Second Comment: If you are here for a method of 3d projection and drawpoint, keep looking.
    The dev in the video fragments the information into 2d parts then says "Heres how to do it in 3d", changes a couple lines of code on the "2d" version then he shows off a character controller thats built fully and works perfectly. I took the time to recreate the singleton c# script from the video, I parsed it and compared it to the video twice and tested it with the exact same code. The reason it DOESNT work is that the original file is calculating x and y positions. The dev in the video doesnt change ANY of that. He also doesnt show whats on the character controller in the 3d environment as hes showing it off. If I find the time, I'll recreate this project with a WORKING 3d version and I'll share the github source code here. This guys ridiculous.

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

      please share the github link

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

      I don't really know what your problem was but it's working perfectly fine for me. I had a few problems first where the projectile was shooting in the right direction but with some absurd speed. If that's the case for you check that you normalized ground direction and path your new calculated targetPosition in the calculate path function.
      If your problem is something else check again if you didn't do any mistakes because itÄs perfectly working for me.
      You mentioned that the dev isn't changing x and y position but he does.
      The original line in the Coroutine_Movement funtion said:
      transform.position = _firePoint.position * new Vector3(x, y, 0);
      The new one says:
      transform.position = _firePoint.position + direction * x + Vector3.up * y;
      Yes there is still only x and y but you need to consider that there is always a 3d vector that gets calculated. The variable "direction" is a vector that (as it obviously says) says what the direction of the projectile is. This is a description of x AND z which gets multiplied by an x which gets calculated based on the cos function. X in this case has nothing to do with the x in worldspace rather than x in mathematical context of the cos function.

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

      u dont seem to know what ur talking about lmao

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

      OP is correct. this code is not a working third person jump. you will have to create your own third person script that uses this code as a mere calculation.
      Vector3 initialPos;
      IEnumerator CoroutineMovement(Vector3 direction, float v0, float angle, float time)
      {
      initialPos = FirePoint.position;
      float t = 0;
      while (t < time)
      {
      float x = v0 * t * Mathf.Cos(angle);
      float y = v0 * t * Mathf.Sin(angle) - (1f / 2f) * -Physics.gravity.y * Mathf.Pow(t, 2);
      transform.position = initialPos + direction * x + Vector3.up * y;
      t += Time.deltaTime;
      yield return null;
      }
      }
      This is the fix to make it work like the video.

    • @elumiie
      @elumiie 8 місяців тому

      It works fine if you change "float yt = targetPos.y;" to "float zt = targetPos.z;" in "CalculatePathWithHeight"

  • @kauasacramento2380
    @kauasacramento2380 2 роки тому

    this can be used at DDTank?

    • @ABitOfGameDev
      @ABitOfGameDev  2 роки тому +1

      Im not sure what that is

    • @kauasacramento2380
      @kauasacramento2380 2 роки тому

      @@ABitOfGameDev i want to use it to make a aimbot for a game called ddtank

    • @ABitOfGameDev
      @ABitOfGameDev  2 роки тому

      @@kauasacramento2380 Well I guess so, the main point is the Parabolic formula, which you can implement in any sort of way. This is just the Unity version

  • @BroxAGM
    @BroxAGM 2 роки тому

    wow mateeee

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

    I wish I could support developers that get technical like this more often, but most often those that provide tutorials like this refuse to provide any source code. I understand the argument that following along with the video can give you "insights" but it doesn't TEACH you the material and while a classroom environment where everyone learns step-by-step is ideal, its not possible for many that can't afford it. Playing around with source code is literally the ONLY way to learn advanced concepts for many indie dev's and youtube is often the only source for that.
    My rant is done thanks for reading.

  • @exe.m1dn1ght
    @exe.m1dn1ght 2 роки тому

    didn't understand nothing

    • @robertottinger
      @robertottinger 2 роки тому +1

      hmmm - guess that means you understood everything ;)

    • @la-ki5wd
      @la-ki5wd Рік тому

      @@robertottinger ayyyyyyyyyy good one

  • @nabilabenhssein9175
    @nabilabenhssein9175 2 роки тому

    the worst video ever.. after implemnting all unity crushes in entering play mode