@@darkfrei2 Simon is a VIP member of the Coding Train community, so I think he has access to videos before us. Btw make sure to check out his videos, he's a young coding genius.
Instead of adding the boolean arrival as a parameter, I would have added slowRadius as a parameter. Then you pass slowRadius=0 for the Seek function. You pass slowRadius=100 for the Arrive function. You could add an ArriveCarefully function with slowRadius=500
Tuning the characteristics of the vehicle is certainly one way to tune the behavior. But if you don't want to change the vehicle, an alternative is to change the slow-down radius. If you change line 47 to: let slowRadius = this.maxSpeed * (this.maxSpeed / this.maxForce + 1) / 2; you can set the vehicle maxSpeed and maxForce to whatever values you want, and arrive will slow the vehicle down perfectly.
I did something similar and noticed it still overruns a tiny bit. I think it's because the slowing down function gets applied one frame too late, so I'm adding "+ this.maxSpeed" to slowRadius!
A tip for the seek() function. Instead of using slowRadius create this.slowRadiusSq = 100*100 as a member varialble and use distSq = force.magSq() , but of course your testing us :) Love your videos.
I've been watching your stuff for years (discovered you while I was in college a few years ago for a CS degree). Even now, I still love your stuff. I don't really play around with the code you produce, but I like watching someone else think through how they would do it. Its really helped me when it comes to my own code. If I get really stuck at work or for persona projects, sometimes I pause and say "how would X do it?" and it breaks me out of whatever "coders block" I got myself into. Thank you so much for your videos! I have recommended this channel so so many people. It does the fun+educational balance very well (dare I say: it does it best)
I have a coding challenge for you: write a simple barcode scanner and evolve to qr code scanning. and if you're brave go forward to build an augmented reality marker detector and start to place simple 3d objects on them. that was something i did few years ago and it was a lot of fun! seems like you have all the basics to accomplish this already covered in past videos, so maybe this is some content idea for you :D looking forward
Cool video! The author inspires! I tried to rewrite this code in C# in Unity, the achieve method works fine, but when implementing the arrive method there were problems, I didn't find the Map function, so I decided to write it myself, but it doesn't work correctly, the object slows down but then starts moving in the opposite direction before reaching the goal. Can anyone tell me what's wrong)This is my Map method: public static float Max(float val, float oldman, float max, float new Min, float newMax) { val = (val - oldman)/(oldman - oldman); returns new Min + val * (newMax - newMin); }
I study at the university the computer department, but I do not have a computer, I attend electronic lectures and exams on my mobile. I wish I had a computer, I work to buy it, but it is expensive 😞😞
Wouldn't it be easier to just limit the force to maxSpeed? So when it is far from target it moves at max speed, but when it is close it is limited by the distance?
Something's really wrong with me, as you said: "Once I'v arrived, I don't want to go anywhere ever again" made me emotional. Once I get wealthy, I'm gonna take a month and do this tutorial from square one up to the final episode. If only...
An easy way would be to have force equal to some scalar times the difference of positions. If position error is larger, it will move faster and assymtotically approach zero.
Hi there, Dan! Love your videos. I am a senior Node developer for my day job. One small suggestion: you found that your arrival flag was unclear when used inline towards the end of this video. In my past few jobs (and current company) I've found that the standard is to pass your variables as an object (destructured in the definition). This does a couple of things for you: when used inline it ensures you A) pass in a clearly labeled parameter and B) don't have to worry about the order. So your seek definition becomes seek({target, arrival = false}) and when you call it: seek({target, arrival: false}) because you already have a target variable that you're passing through (so you can avoid target: target)
That was my thought as well. Bonus: if you make a typescript version, an object will help encapsulate those configuration parameters beyond just individual parameter types.
I recently saw your video on animation is p5, and thought, if we have multiple images instead of a sprite sheet, can't we store them in an array, and write a for loop to go over each of them, every couple of frames?
But that will require making a lot of images and preloading a lot of images which will slow down the system. Could work for simple short animations though
@@RajJaiswal538 On the internet, sometimes you can find separate images on websites, so that's why you can use this method, instead of creating a sprite sheet yourself. Also preload runs once, and from my experience, p5 can handle up to 50 objects, and display them(images) at once, so it should have no problem displaying images one at a time, I think.
@@icecrack4579 yes! For less images. Anything over 50 and it will take like 10 minutes just to preload p.s. I am not sure if 50 is the golden number and it also depends upon the size of image
@@RajJaiswal538 Oh, I misunderstood your comment, I had done it with the same image, in the object class itself, I'm not sure about 50 different images tho.
Youre always seeking, so you can simply add an if statement if you’re in the slowing zone, you start to “arrive” i think it would be more clear and you won’t have a separate function for arriving
@@DanKaschel Which isn't the case, so yeah...if you always want the vehicle to go at maxspeed then there would be no way to do it if you do it like that
These videos are simply a beautiful rollecoaster. It's a nice mix of relaxation from seeing the final result and the anxiety from trying to read Daniel's mind XD
Hi, You are an amazing teacher ... thanks a lot for teaching amazing stuff... I kindly request you teach asymptotic notation Big -O and when we write any algorithm , how to calculate Big - O ... Can you please help
Random question but I really like your videos and wanted to ask you, how can I connect a MIDI keyboard via USB and get the input of the frequency and amplitude of each note being played? I want to map the frequency and amplitude to color! thank you!
I have used many of the concepts he has taught and applied the same things in my own language. I like to code in c#. It doesn't matter what code he teaches because it's the concepts you are learning not the direct code.
It seems really reasonable to use it to me, I mean it works fine, and has the great bonus of it being super easy to share with people because they don't have to set up an environment for it, just open the link and start playing.
The knowledge can be used for any programing language. I am sure many people here can help translate the code to any programming languge. Also, I do use p5. Which is basically just javascript.