Hello! I just signed up to your site unitycodemokey.com and I am trying to validate my account after receiving your "Code Monkey Account Activation" email with the validation link. Whenever I click on the link, a Code Monkey page opens up showing the message "Invalid validate link.". I even tried clicking on the "Resende Validation Email" located on the top of such page, but the same thing keeps happening. How can I have my account validated then? Thanks in advance.
But for real that is some ADVANCED math that could easily be portrayed in matrices or other similarly complex calculus! He explained simply enough that I am almost certain a child could understand especially with the visual rendering!
you can make evenly spaced distance on curves //this is placed on update() if (MakeCurve == true{ MakeCurve = false; for (float t = 0; t 1 ){ // add vector position on list PrevPosition = EnemyPos; } Progression += 0.0001f; } if (Progression >= 1){ Progression = 0; MakeCurve == true; // or just go to the next route of bezier curve } i did thiis last week and it took me 3 days to it so.... im just sharingg
I legitimately have never found mathematical graphical interpretation or interpolation nearly as impressive or exciting as I have than in this video. If this is how I was taught Algebra and Calculus in school I would literally have pursued a career in mathematics or programming 12 years ago instead of enlisting.
Thanks for a pleasant math tutorial CM. Seeing AB_BC brought back nightmares of trigonometry. But you know, it was good. I liked it. Always missed maths, and I'm a programmer too hahah.
i always missed maths because of how maths is taught and the whole education system running have had a pretty rough high school life, made me lose all interests in learning, including maths. Now watching this video, it actually gets kind of fun Just if they actually teach stuffs like this man, school would have been so much fun
Thank you, great video - it really helps to visualise the maths behind the spline. One thing - should your QuadraticLerp and CubicLerp functions be using the data member 'interpolateAmount' directly? I think it makes more sense for them to use the parameter 't' instead. The end result in this example is not affected though, but it will cause problems if these functions are used from other places.
I have a thousand questions...but for starters, you are using time of one second to move between points, but if the distance from one point to another is greater, the car appears to move faster. How do I set a speed for the car regardless of distance?
You need to calculate the unit distance in the spline. I did that in the expanded version of the Spline class that is included in the project files you can download
Thank you for your tutorial and files. However, there is a possibility to make all normal direction more vertical ? for example, people walking on stairs.
I’m trying to do the same thing, My plan was to make my game get the Y position of the train, the lower the Y position, the faster the speed that the train moves to each spline point, I’ll make it update every frame but my problem is I don’t know how to code and I’m trying to do everything using Bolt
Lovely video! Really showed how easy it can be do to something that seams more complex. Question: In your project files you use MeshUtils to Create and Add Line points and Line meshes, but MeshUtils does not exist in the current context, is this a code file you wrote on your own or is my Unity missing something? EDIT: Found it, though now I can't get the Spline Done example to work due to the menu for adding and removing anchors not working. It states that the index it out of range. Is there something more I need to get the Spline Done example to work?
I eventually solved it by adding some code that checks if there are any anchors in the list and if not it creates one without first executing the points functions. The error came from no anchors being in the list but the add anchor function tries to use the index of the last anchor
Thanks I needed it very much because I am creating an open world game just like simcity and skylines and being a solo developer I had to rely on third party codes which are not very customizable and also I needed a create a road of my own using this splines thanks very much.
hey good content thank you again! I got a question, do you recommend any kind of books or content for mathematics/physics that apply to video game development?
Hello Code Monkey. I first and foremost wanna let you know you are the best. I have actually never come across a fellow coder who can code in such a mind blowing way. I think you are gifted with this. God bless and keep up the good work. I have one request though, and that is if you can teach how to about 2D ladders. i.e. to make a player climb up and down a ladder. Cheers
Thanks! That's going to depend quite a bit on your design, is it top down? Sidescroller? One simple way is to do a Physics2D.OverlapBox right on top of the player and see if the player is on top of a ladder, if so enable up and down motion.
@@CodeMonkeyUnity Wow it worked. Its a somewhat a mix of it. I am using Cinemachine 2d camera to follow the player around. Its more or less a bit like the classic jetpack game just that not all the level is captured in the camera, hope u get what I mean. I am quite new to Unity so your this method didnt cross my mind earlier but it works. Thanks a lot Bro. Keep up the great work. :)
Really good solution! However, I'm having issue with the SplinesDone script trying to use negative indices for anchors and resulting in runtime errors.
Please help, I don’t understand how to make the car move, I have like 10 cars, one on each spline section, how do you make one car? I tried making it so my game gets the time and then rounds it and then on every frame, it gets the rounded time and if it is 1, it sets the first spline section car to active, then if it’s 2, it sets the second one to active and also deactivates the one before it, I tried doing this but there were lots of problems like for some reason my car would start to get off-sync with the rounded time somehow, the car would get to the end of the track sections and then for like 4 or 5 frames, the car would appear at the beginning of that spline section and then suddenly appear on the next spline section, it would start off smooth and then mess it’s self up, also My game requires there to be 1 spline section at the start and then the player can add more and move then around but I don’t know how to reframe something that isn’t in the game at the start, also I’m using visual scripting
I need your help once again I just started with unity and should I learn 2D game development or 3D game development? I have no almost knowledge of unit or coding.
IT really depends on what you are trying to do and what support software you are using, an what kind of assets you have access to. From there it is learning the syntax of the programming style necessary, and the workflows of the programs you are using. I have been playing around with 3D Modeling for at least 2 months and have yet to find a way to integrate my 3D models into a 3D space, but was able to following along, coding in real time, with tutorials and was able to create fully functional games, modules, and scripts that sever a myriad of solutions. It's all in what you are already familiar with and what comes naturally to you!
If your UI is already set up in 3D then everything should work. If you can see a regular 3D cube then you should be able to see the spline mesh. Maybe it's just rotated the wrong way and the UI camera is seeing the backside of the spline?
I made a game that has 1 of these splines, a roller coaster car I kade in blender, and an FPS counter and thats it, for some reason it only runs in 18 FPS on my iPad
I am trying to make a 2d spline road where the player controls the car. The problem is, I want the player to die when he hits either edge of the road. How would I add colliders to achieve this since I can't just add a collider to the road because then it wouldn't detect collisions with its edge if the player is inside the collider. I tried adding 2 edge colliders to each edge but I wasn't sure how to do that
Also, in conjunction with this issue above, even if I solve how to add the colliders, how can I make the road endless and have random turns? I first thought to make different road segments but that doesn't seem good since I don't want to repeat the same road part multiple times. I want it to randomly turn and generate infinitely
@@anonymoussloth6687 For random generation, you just need to spawn those end points and adjust anchor points to match the curve of turn. For endless games, best solution is to spawn track in segment and delete those that you don't longer needs. First make your game with straight line and than add spline, it will be easier for you if you strugle with it
Divide the spline into various points, calculate the forward vector of those points, then rotate them 90º and -90º and you have the offset for the edges. Then place an object there with a collider. Track segments is the easiest way to do an endless road, if you make about 10 of them that already leads to tons of randomness. Or just use math to calculate the next point position and more the anchors and handles.
The Unity Spline package does seem awesome although I haven't used it myself. Back when I made this video that package didn't exist, nowadays I would probably use their package
@@CodeMonkeyUnity Even though I've used Unity for quite a few years now it's new to me too. I've not been able to find any examples of it's use though, which is strange. Just to be clear, I'm not referring to 'Sprite Shapes' which may internally uses these.
Yeah it's the Splines package docs.unity3d.com/Packages/com.unity.splines@2.0/manual/index.html It just recently got a huge upgrade in Unity 2022 LTS, I need to find some time to research it
i need some for off Splines system for my game but i wand i system like this that im able to animated in my game the player have cable hands so it's important for my to find some way make cylinder system with mash that able to check the shape off this in real time
Can you please do a video on how to use the native splines that were added to the beta version of Unity 2022, they are in the package manager and they are called Splines 2.0, also can you make a video about how to make something move across a spline using gravity like a roller coaster car would, Like where it goes fast and then slow over hills and stuff using gravity?
Ok, thank you so much. I tried using it to make a game for phones but for some reason every time I try to build a game in Xcode that was made in Unity 2023, it keeps saying Build Failed, I don’t understand why
hm.. but doesn't the way you interpolate between points by time make the object (i.e. car) go faster and slower depending how far apart the points are?
You might be able to solve this by first getting the distance between two points and factoring that into the interpolation amount. Smaller distance = faster interpolation, larger distance = slower interpolation.
Yes, you need to add some extra logic to make it move based on units. I added that extra logic in the final Spline class that is included in the project files.
Monkey can you do a tutorial on how to play with someone through bluetooth , or on same wifi ? a racing game maybe? or fighting game that would be awesome
🌐 Have you found the videos Helpful and Valuable?
❤️ Get my Courses unitycodemonkey.com/courses or Support on Patreon www.patreon.com/unitycodemonkey
Great video
amazing as always, thank you very much!
Hello code monkey is the course free
Hello! I just signed up to your site unitycodemokey.com and I am trying to validate my account after receiving your "Code Monkey Account Activation" email with the validation link.
Whenever I click on the link, a Code Monkey page opens up showing the message "Invalid validate link.". I even tried clicking on the "Resende Validation Email" located on the top of such page, but the same thing keeps happening. How can I have my account validated then? Thanks in advance.
@@erichrcl Wait a bit then click on the last email you receive, check your spam folder.
Your ability to distil complex topic in a way that make them feel simple is quite impressive. This channel is quickly becoming one of my favorites.
Thanks!
Man, it absolutely awesome! It’s the most easiest quadratic interpolation explanation I’ve ever heard, thank you!
The internet shows me lots and lots of genius in the world, and you definitely one of those geniuses!
💬 Do you need a nice smooth shape for a road/orbit/patrol/anim/path?
Splines to the rescue!
Exactly what I'm trying to do for a project .I'm trying to make a rider clone with AI riders
Is there anyway to make a 3d rope with physics and collision
Reticulating splines. This brings back Sims 2 memories. 😄
I only ever heard of that phrase from Simcity 4.
I remember playing sims city 4, o was to young to remember stuff like that from it
Sped up key stroke sounds are very satisfying
Beautifully done tutorial! Easily explains how interpolation works and how you can expand on it!
But for real that is some ADVANCED math that could easily be portrayed in matrices or other similarly complex calculus! He explained simply enough that I am almost certain a child could understand especially with the visual rendering!
Probably one of the best videos I've seen on Bezier Curves, really clear! Thanks a lot! :)
Was planning to program a race game in the future. This will surely help, thanks!
Mind blown, seriously... You're definitely Brackeys 2.0
You're are the brilliant Unity master.
Thanks!
so powerful, yet so simple
Thanks for your best tutorial !
you can make evenly spaced distance on curves
//this is placed on update()
if (MakeCurve == true{
MakeCurve = false;
for (float t = 0; t 1 ){
// add vector position on list
PrevPosition = EnemyPos;
}
Progression += 0.0001f;
}
if (Progression >= 1){
Progression = 0;
MakeCurve == true; // or just go to the next route of bezier curve
}
i did thiis last week and it took me 3 days to it so.... im just sharingg
Even though this isnt relevant to me, its appreciated that you threw in some extra stuff for people reading!
Math is absolutely important!! Thanks for the good video.
Best spline/bezier curve tutorial I have ever seen.
I legitimately have never found mathematical graphical interpretation or interpolation nearly as impressive or exciting as I have than in this video. If this is how I was taught Algebra and Calculus in school I would literally have pursued a career in mathematics or programming 12 years ago instead of enlisting.
Congrats, you coded the photoshop pen tool
More importantly I learned how the Pen tool works, very useful to know the math behind it and know that it's not magic.
Thanks for a pleasant math tutorial CM.
Seeing AB_BC brought back nightmares of trigonometry.
But you know, it was good. I liked it. Always missed maths, and I'm a programmer too hahah.
i always missed maths because of how maths is taught and the whole education system running
have had a pretty rough high school life, made me lose all interests in learning, including maths.
Now watching this video, it actually gets kind of fun
Just if they actually teach stuffs like this man, school would have been so much fun
thank you. very well explained.
10:20
Driver: "I'm a middle of the road kind of guy"
Thank you, great video - it really helps to visualise the maths behind the spline. One thing - should your QuadraticLerp and CubicLerp functions be using the data member 'interpolateAmount' directly? I think it makes more sense for them to use the parameter 't' instead. The end result in this example is not affected though, but it will cause problems if these functions are used from other places.
You’re a genius
do you have a tutorial how to wrap a spline to a spherical surface (ie : like roads on a spherical planet)
ThanQ
So games Like worms are using drafting interpolation? When you throw a hand granade for example?
Those are just using physics. Add a rigidbody to a component, call AddForce with the vector the player selected and just let it go.
I have a thousand questions...but for starters, you are using time of one second to move between points, but if the distance from one point to another is greater, the car appears to move faster. How do I set a speed for the car regardless of distance?
You need to calculate the unit distance in the spline. I did that in the expanded version of the Spline class that is included in the project files you can download
Th thanks. I'll check it out.
What there is no spline system in the Unity api, you have to write your own? But its such a useful thing to have splines and curves
I remember seeing somewhere that they were going to add it, maybe its in version 2020?
What would be a good way to make this a Consistent speed? Trying to make a homing attack system and it's a bit too fast when you are further away haha
This is cool tool!!
Thnx man!
Great video keep up the good work man
This is just beautiful
Thank you
Thank you for your tutorial and files. However, there is a possibility to make all normal direction more vertical ? for example, people walking on stairs.
Your videos are wholesome
Thank you 😌
How can we move along the spline with physics? like a roller-coaster affected by force and gravity.
I’m trying to do the same thing, My plan was to make my game get the Y position of the train, the lower the Y position, the faster the speed that the train moves to each spline point, I’ll make it update every frame but my problem is I don’t know how to code and I’m trying to do everything using Bolt
Can you explain how did you apply the road sprite? How did you manage to get middle lane be dashed this way
It's just a texture with 2 solid yellow lines on the side and a dash in the middle stretched out depending on the spline size
@@CodeMonkeyUnity Oh, could you explain the dash stretching a bit more in detail?
@@Nervniyak You just change the textureScale on the material
Fantastic! Thanks!
Great tutorial!
Thanks🥰😍
Why have you replaced Update function on testing script?
Lovely video! Really showed how easy it can be do to something that seams more complex.
Question: In your project files you use MeshUtils to Create and Add Line points and Line meshes, but MeshUtils does not exist in the current context, is this a code file you wrote on your own or is my Unity missing something?
EDIT: Found it, though now I can't get the Spline Done example to work due to the menu for adding and removing anchors not working. It states that the index it out of range. Is there something more I need to get the Spline Done example to work?
where di u find it ? :))
Did you ever find the solution for the index out of range error?
@@codingsloth5256 It's in _-> stuff -> Videos->
@@arthurvanschravendijk4111 No sorry, I don't think I solved this one. :(
I eventually solved it by adding some code that checks if there are any anchors in the list and if not it creates one without first executing the points functions.
The error came from no anchors being in the list but the add anchor function tries to use the index of the last anchor
this is beauty
Very useful !
Its beautifully explained!
By the way if you can make videos on saving and loading of games 😅
Yup I covered saving and loading here ua-cam.com/video/6uMFEM-napE/v-deo.html
but the car would crash if something comes in the way is there any way to dodge them?
Excellent video sir! Explained it so well
Great video! But once you hear the sound of that keyboard it drives you nuts! Why is that keyboard so loud?
It's under the microphone, I can't really add anything between my hands and the mic
fantastic, great tutorial
Nice This is great for city walls !
Yup! Great for making a freeform castle
it's a Great tutorial , thanks man
Can I make a more detailed video on this topic?
Thanks I needed it very much because I am creating an open world game just like simcity and skylines and being a solo developer I had to rely on third party codes which are not very customizable and also I needed a create a road of my own using this splines thanks very much.
welp, don't really WANT to do this, but i need spline stuff for track and road generation for my game. so, need to learn non-linear lerping
hey good content thank you again! I got a question, do you recommend any kind of books or content for mathematics/physics that apply to video game development?
How would you make an object on the track draggable with mouse?
Hello Code Monkey. I first and foremost wanna let you know you are the best. I have actually never come across a fellow coder who can code in such a mind blowing way. I think you are gifted with this. God bless and keep up the good work.
I have one request though, and that is if you can teach how to about 2D ladders. i.e. to make a player climb up and down a ladder. Cheers
Thanks!
That's going to depend quite a bit on your design, is it top down? Sidescroller?
One simple way is to do a Physics2D.OverlapBox right on top of the player and see if the player is on top of a ladder, if so enable up and down motion.
@@CodeMonkeyUnity Wow it worked. Its a somewhat a mix of it. I am using Cinemachine 2d camera to follow the player around. Its more or less a bit like the classic jetpack game just that not all the level is captured in the camera, hope u get what I mean.
I am quite new to Unity so your this method didnt cross my mind earlier but it works. Thanks a lot Bro. Keep up the great work. :)
This could've saved me days if I had this a year or two ago xD
Really good solution! However, I'm having issue with the SplinesDone script trying to use negative indices for anchors and resulting in runtime errors.
the links don't work and neither does the download for me
It's working fine for me, try again, maybe the server went down for a few seconds
Hi, great video!
Is there a way to make the ABCD point go slower? Thanks!
The "points" dont move by themselves, you query the class to get a specific position, it's up to you how you handle that position request
How to set up the road sprit?
So this is what i did on papers. Wow
RIGHT?!?!?!?!
Please help, I don’t understand how to make the car move, I have like 10 cars, one on each spline section, how do you make one car? I tried making it so my game gets the time and then rounds it and then on every frame, it gets the rounded time and if it is 1, it sets the first spline section car to active, then if it’s 2, it sets the second one to active and also deactivates the one before it, I tried doing this but there were lots of problems like for some reason my car would start to get off-sync with the rounded time somehow, the car would get to the end of the track sections and then for like 4 or 5 frames, the car would appear at the beginning of that spline section and then suddenly appear on the next spline section, it would start off smooth and then mess it’s self up, also My game requires there to be 1 spline section at the start and then the player can add more and move then around but I don’t know how to reframe something that isn’t in the game at the start, also I’m using visual scripting
Sir, can you do a breakdown video of minecraft, and how its mechanics work?
Remaking Minecraft would be an interesting project that I'd like to do at some point!
I need your help once again
I just started with unity and should I learn 2D game development or 3D game development?
I have no almost knowledge of unit or coding.
I started with 3d with brackeys beginner tutorial
And I feel 2d is hard
@@Unknown_Programmer ooh
IT really depends on what you are trying to do and what support software you are using, an what kind of assets you have access to. From there it is learning the syntax of the programming style necessary, and the workflows of the programs you are using. I have been playing around with 3D Modeling for at least 2 months and have yet to find a way to integrate my 3D models into a 3D space, but was able to following along, coding in real time, with tutorials and was able to create fully functional games, modules, and scripts that sever a myriad of solutions. It's all in what you are already familiar with and what comes naturally to you!
That's Brilliant!
Hi. I need to make a spline that is part of my 3D game's GUI. Is there anything you could point me to? Thanks.
If your UI is already set up in 3D then everything should work. If you can see a regular 3D cube then you should be able to see the spline mesh. Maybe it's just rotated the wrong way and the UI camera is seeing the backside of the spline?
@@CodeMonkeyUnity Thanks. I need to look into how UI works more.
Road contain only one strip , even i use tilling
I made a game that has 1 of these splines, a roller coaster car I kade in blender, and an FPS counter and thats it, for some reason it only runs in 18 FPS on my iPad
And 30 FPS on my iPhone xs max, and my ipad is the ipad 6
Look in the profiler to see what is taking so long, could be many different things
Ok, thank you for replying
How I can rotate a 2d object around player?
I am trying to make a 2d spline road where the player controls the car. The problem is, I want the player to die when he hits either edge of the road. How would I add colliders to achieve this since I can't just add a collider to the road because then it wouldn't detect collisions with its edge if the player is inside the collider. I tried adding 2 edge colliders to each edge but I wasn't sure how to do that
Also, in conjunction with this issue above, even if I solve how to add the colliders, how can I make the road endless and have random turns? I first thought to make different road segments but that doesn't seem good since I don't want to repeat the same road part multiple times. I want it to randomly turn and generate infinitely
@@anonymoussloth6687 For random generation, you just need to spawn those end points and adjust anchor points to match the curve of turn. For endless games, best solution is to spawn track in segment and delete those that you don't longer needs. First make your game with straight line and than add spline, it will be easier for you if you strugle with it
Divide the spline into various points, calculate the forward vector of those points, then rotate them 90º and -90º and you have the offset for the edges. Then place an object there with a collider.
Track segments is the easiest way to do an endless road, if you make about 10 of them that already leads to tons of randomness.
Or just use math to calculate the next point position and more the anchors and handles.
Do Unity's SplineUtility and BezierUtility not have some functionality that can replace some of this hand crafted code?
The Unity Spline package does seem awesome although I haven't used it myself. Back when I made this video that package didn't exist, nowadays I would probably use their package
@@CodeMonkeyUnity Even though I've used Unity for quite a few years now it's new to me too. I've not been able to find any examples of it's use though, which is strange. Just to be clear, I'm not referring to 'Sprite Shapes' which may internally uses these.
Yeah it's the Splines package docs.unity3d.com/Packages/com.unity.splines@2.0/manual/index.html
It just recently got a huge upgrade in Unity 2022 LTS, I need to find some time to research it
thanks
You are Awesome!!!
Thanks!
Reminds me of tweening in the Flash days
where did you learn it
This is really just math so there's tons of places to learn from, you can find videos on UA-cam or look up the equations on Wikipedia
Great video
i need some for off Splines system for my game but i wand i system like this that im able to animated
in my game the player have cable hands so it's important for my to find some way make cylinder system with mash that able to check the shape off this in real time
awesome tutorial....
I'm glad you liked it! Thanks!
Can a snake character be made with splines?
Sure, snakes are curvy so a spline works well
just gotta lerp the lerped lerp. XD
Can you make a slash effect with splines??
Slash how? It's just a point curve in the world, you can use it to define a slash curve
thank u for help
can u make a dev react to cyberpunk 2077
it will give u a little boost too since its trending
TIA
I have been playing the game and I'm planning to do a video recreating some systems from it so stay tuned!
Hey! Can this be used to make a race car AI?
It's just a shape so I'm not sure what kind of AI you're envisioning.
I covered a car AI here ua-cam.com/video/xuCtxIcfboM/v-deo.html
Where can I find the SplineDone script?
Theres a link jn the description
Can you please do a video on how to use the native splines that were added to the beta version of Unity 2022, they are in the package manager and they are called Splines 2.0, also can you make a video about how to make something move across a spline using gravity like a roller coaster car would, Like where it goes fast and then slow over hills and stuff using gravity?
Yeah I would like to explore the built-in splines package, haven't used it yet, just need to find the time
Ok, thank you so much. I tried using it to make a game for phones but for some reason every time I try to build a game in Xcode that was made in Unity 2023, it keeps saying Build Failed, I don’t understand why
hm.. but doesn't the way you interpolate between points by time make the object (i.e. car) go faster and slower depending how far apart the points are?
You might be able to solve this by first getting the distance between two points and factoring that into the interpolation amount.
Smaller distance = faster interpolation, larger distance = slower interpolation.
Yes, you need to add some extra logic to make it move based on units.
I added that extra logic in the final Spline class that is included in the project files.
really nice
Monkey can you do a tutorial on how to play with someone through bluetooth , or on same wifi ? a racing game maybe? or fighting game that would be awesome
Unity has this built in, it’s called Mirror Networking and you have to get it from the package manager. There are videos about it
Also, to fix the null reference error for AddAnchor() Here is what worked for me.
public void AddAnchor()
{
if (anchorList == null) anchorList = new();
else
{
if (anchorList.Count > 0)
{
Anchor lastAnchor = anchorList[anchorList.Count - 1];
anchorList.Add(new Anchor
{
position = lastAnchor.position + new Vector3(1, 1, 0),
handleAPosition = lastAnchor.handleAPosition + new Vector3(1, 1, 0),
handleBPosition = lastAnchor.handleBPosition + new Vector3(1, 1, 0),
});
}
else
{
anchorList.Add(new Anchor
{
position = Vector3.zero,
handleAPosition = new Vector3(0, 0, 1),
handleBPosition = new Vector3(0, 0, -1),
});
}
}
}
Hello sir, huge fan
Can I ask something
Pls make "Journey of the Priarie king" with unity,pls pls pls
thx
You always manage to explain complex and useful things to the Unity Community, thank you!
Thanks for the kind words! I'm glad you found the videos helpful!
is there anyone to tell me the name of the program / software used in the video??
I'm using Unity
Woow nice!
easy tween ... poggg
Nice!
Be·zi·er | \ ˈbe-zē-ˌā