Hello World! I'm going to make a fish swim back and forth a random amount. I have a clown fish and I'd like the clown fish to swim back and forth in this area, but I want him sometimes to go a little bit then turn around and go back and and not always go exactly to this point and this point. So I'm going to make this point and add an object marker, and just call this onTheLeft and then I'm going to move him over to the other side, and add an object marker there and call it onRight. So let's go to our code. I'm going to get rid of that Java code on the side. We have lots of room to see our scene, so we started here and I'm going to have them going back and forth so let's do that: while forever, while(true) and he's over here so the first thing the clown fish needs to do, is turn to face the onLeft position and then he is going to move Initially I'm just going to have him move That whole amount so he is going to move forward Just make it 2 for now, and then he's going to turn to face onTheRight and then he's going to move again, then, again, forward, I'll make that 3. Let's run this. and it isn't really quite enough, but he's doing the same thing over and over and over again. and I would like to look a little bit more random. So I'm going to use a variable and it will be a double and I'm going to call it distance. We have to give it some initial value. I want to make the distance a random amount the distance from the fish to that marker. (Let's make this a little smaller so you can see what I'm doing here. really small, OK.) So it's going to be a random amount from something to something and the first value I'm going to make .25 and the second value .5 but instead of the .5 I'm going to use the function. in the function I want to use is to get the distance to, that's going to replace that second value. the onLeft, and then he's going to move that distance. and then I'm going to do the same thing, let's just run that. He turns around and he moves some distance. but going back we've still got that fixed amount. So let's fix that now. I need to assign a new value to distance and distance is equal to .25 but then I want that to be a random amount between .25 and We'll just put in 0.25 for the first value and 1 for the second value. and then I'm going to use the function here that distance, get distance to this.onLeft. Ok, this second one is going to be this.onRight. Let's run this and see how were doing here. One of the things I wanted to see here is that it looks random. Now hear something interesting, you'll notice that the duration is the same for all of those. So if he's going a short distance he goes very slowly. And if he's going along distance he goes a little faster. So one of things we could do would be to make the duration have some relationship to the distance that he's traveling, so that he appears to swim at the same speed, but I'm going to leave that as an experiment for you. So let's just review what we've done here. I'm going to do while true that means it just keeps repeating over and over. I have distance which is a random value between .25 and the distance to the onLeft marker. and he's going to turn to face the onLeft marker and move towards it that distance. Then he's going to turn to face the onRight marker, and then we calculate the distance between .25 and the distance between the clown fish and the marker on the right. and then he'll move forward, We have to change that to distance, Change that to distance. So let's run that again and see how that looks. Notice that disparity in the speed depending on how far he has to go. So we could make the duration a random number or make a factor of the distance that he's going, and you should experiment with that all you want.