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.
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?
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?
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.
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.
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.
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.
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 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
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.
this is perfect, I tried a bunch of different approaches over the last couple days but this exactly what I was after.
love pure programming videos, nicely done
THANK YOU! This explains this in such a nice way and shows an actual use case.
I liked how condensed you made you video and you explained it very well. thank you
Dude great fucking video, love how direct and clear and concise it is. You helped me understand and follow without wasting my time.
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.
cant describe how wonderful this video is THANKS ALOT!
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?
you don't need to set transform.position = evaluate(t), instead use transform.Translate towards next checkpoint
@@igorkim3558 sorry, I don’t quite understand. May I please see an example?
Dude you saved my life thank you so much
Exactly what i needed, thanks
Can you move a and b when projectile is already on the move?
My question is, why not use Animator curve field to evaluate??
awesome tutorial!
Thanks alot my mate
u are a legend man
This is gold, wp brother
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?
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.
Cool~ Thanks!
legend
This same method can be used for my archer towers in my tower defense project?
No sorry it only works for scifi lasers and stuff
Nice 👌
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.
look into kinematics
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.
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!
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.
@@Rytech_Dev can you do a tutorial on that please ? This is really interesting, also multithreading works on mobile project ? Thanks
but how wuld you detect collision detection? does oncollisionenter work?
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
For more information on collision detection here is a video I made a while back: ua-cam.com/video/NNJs4wYZGvs/v-deo.html
@@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
"Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached." Therefore, no.
i hate myself for abandoning math in school
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.
Cool video!
Btw. You can calculate point on Bezier curve in single line:
ua-cam.com/video/pnYccz1Ha34/v-deo.html