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!
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.
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.
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
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
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.
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 ?
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
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.
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?
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?
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.
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.
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.
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.
@@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?
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.
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
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 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.
@@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)
@@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
@@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
I've never been so overwhelmed when writing code, but it was worth it. I wish you would share the codes ready.
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!
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
love you, please have my children this was truly enlightening, thank you so much!
Incredible tutorial. Thanks you so much for sharing!! So helpful!
I just found your channel. Thanks for all of the high quality content!
Hey thank you very much for the support I appreciate it. I hope you will find the future videos interesting as well :D
Great tutorial that really went over the core concepts well!
I was able to translate into GDScript for Godot with very little trouble.
I had to get back to my old books just to understand how things are working. Awesome tutorial. Thanks a lot.
2 week ago, I discovered your channel, Congratz ! It's just amazing. Thank you ♥
No, thank you 👉👉
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.
Thank you so much for the tutorial. Excellent work!
Thank you for the video! Great job!
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.
Very well explained
Can you please post the ending code? I have no errors, but mine's not working like yours
brilliant tutorial!
Love the content! Keep it up!
Can You show the player predictable jump example
When I type Mathf it doesnt come up green like yours does. Am I doing something wrong?
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
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
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.
AYYOO THAT BASKET BALL GAME
Is it possible to find the right angle and velocity to make the projectile land in a specific point ?
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
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 ?
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
please make more math tuts
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
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.
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?
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?
How can I get a speed parameter for speed up the projectile?
Great channel! Can you do a tutorial on instantiating a different material on an npc each everytime damage decreases its health, say, 25%?
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.
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.
please share the github link
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.
u dont seem to know what ur talking about lmao
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.
It works fine if you change "float yt = targetPos.y;" to "float zt = targetPos.z;" in "CalculatePathWithHeight"
How would you calculate it in reverse, given the end coordinates?
how do I predict projectile jotting dynamicly moving target?
Possible to do it through rigidbody instead?
how could I change the target control to asdw instead of mouse?
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
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
How can i flip vertically parabola movement?
wow mateeee
Is your gravity negative or positive in the beggining? Becouse If I write negative (My gravity is -9.81f) the Debug says: NaN
I believe the gravity should be positive
How can I make projectile to be parallel to tangent to parabola ?
Can this be used for a sideways curve?
Can you change the speed of the movement without change the path of the projectile?
Yeah, there is a parameter exactly for that :D
@@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?
@@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
@@walldoffstudios Nice, thank you! I have to try that later :)
Do you have 3d code available to share?
Why change speed? It must be permanent! The angle must change, and only the angle!
Hi, say where i can find this code?
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.
My shooting object is off from the line of projectile any gesses?
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
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.🥺
Hey thanks for subbing, what exactly is the problem, im not currently home but maybe I can help you out
@@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.
@@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)
@@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
@@ABitOfGameDev Everything looks fine but I couldn't get it to work properly.😢😵💫
CODE POSTED IN REPLY
this can be used at DDTank?
Im not sure what that is
@@ABitOfGameDev i want to use it to make a aimbot for a game called ddtank
@@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
didn't understand nothing
hmmm - guess that means you understood everything ;)
@@robertottinger ayyyyyyyyyy good one
the worst video ever.. after implemnting all unity crushes in entering play mode