@Spectral Penguin Check out my video on health bars: ruclips.net/video/fm9QJ9yk1jw/видео.html You should be able to use a local variable for the 'life' of each enemy. You could also clone the healthbar and peg it to the position of your clones, but you'll probs need to store xy locations in a list to help you out. A big task, but doable!
Yo thanks! This tutorial didn't just teach me how to do a specific thing it actually made me understand the concept. I never knew that local variables actually did that for clones as, and the fact that you explained the fact that it will say 1,2,4,8 and stopped that pitfall was a huge help. Using this tutorial I was able to make something almost entirely different than the showcased example, and thats a testament to how good a job it does teaching fundamentals!
i was making a space shooting game and the clone of the laser i had made had a variable named health and wanted to decrease the number of the variable when the clone of the laser touched that sprite and this helped me a lot in that game, thanks for the video.
FANTASTIC! Exactly the answer I was looking for. I'm creating a bubble particle system, where a bubble sprite is cloned, then each clone floats up at random speed until they reach a certain point when they pop. At this point I wanted to delete the clone and reset, having a new clone respawn and begin its cycle again. Each time the respawned clone ended up duplicating all 15 bubbles in the system. Agh. This global/local var technique will help me fix that. Awesome, thanks! Hope you caught that wave. Cheers dude.
I’m working on an Undertale-inspired game with blasters (multiple may be on screen at once, so the blasters themselves had to be clones). I used a local variable to determine whether the clone was the blaster (shooter) or the blast (bullet, to some extent??), and depending on what the variable is, it behaves either like a blaster or a blast. This video really helped me, thanks!
Yeah you should be able to. The trick is to keep track of all the clones using local variables. You'll have to loop through all the clones and get the x and y coordinates and check to see which is the closest to the sprite you're interested in.
@@SurfingScratcher Thank you very much! I ended up just making three different sprites instead of clones of the same one, but I'll use this technique if I want to expand the project.
my game goes smoothly and the bullet works fine but when you play for like a minute the bullet and my enemy stops making clones suddenly, do you know how to fix this? pls help
Hmm check that your clones aren't making clones. Scratch has a limit of around 300 clones, so you could have maxed out. That bug is demonstrated and fixed in the video. How can you check this? Count the number of clones you have on the screen and use the 'say' block to print its id number. They should match.
Nah, this awesome channel surely deserves more views, likes, shares & subs. Unfortunately I dont have any friends who are into Scratch and the programming stuffs like me :'(
Essential for trying to build a city maker or simulator game. Where when you place houses down and I want to program the sim going to his job with a car. So the houses are clones. And I figured out, how the list will record a spawn. It can record the clone's x and y positions and you can make it wait for 10 seconds until it does record the value if you need a lot of time. Then i'll try to make the car clone come out of that x and y position that was recorded for the house clone's x and y coordinate. Ultimately trying to get to an industry's or commercial's x and y. All the properties are either R, C or I (or just 3 different) types of clones. How Sim City would divide it's zones.
Great question! You'll need to track the x and y positions of clones in a list so that you can check to see which is the closest. You're not gonna be able to point in the direction of that clone using a built-in block. Instead, you'll need to use trigonometry based on the x and y coordinate that you've got from your list. Thankfully, I've just done a whole series on trig. Check out this video, it'll give you some clues: ruclips.net/video/kxRywPEUfcc/видео.html
6:35 im late to the party, but when you fire a bullet, the other existing bullets also create a clone of their own as you have the event to create a clone on the sprite itself.
Thank you so much for this video!! It helped a lot, and wasn't one of those six-hundred-million-hour-long tutorials you see all the time! Ha! This helped A LOT with my Paranoid Animation Meme, which I'm still working on as of now, but I'm done with the intro! In the intro I had to have FOUR CLONES all doing different things. I always wondered how to do this!! This is going to help a LOT with so many other things, such as animations with a limit of one sprite, and even more animation and code memes! Thank you again! ~Sunset
I was having trouble that the isClone? Fixed. Tbh I do not understand how that fixes my problem but thanks a ton. I tried (here and there) for hours to figure out the solution for my tycoon and it was here the whole time
I am making a paddle and ball game like scratch tutorial. I want to make another ball appear once the score reaches a certain number. Can I do this with clones? Or would I need to create another sprite?
Hi, I’m working on a game where I want to be able to create clones that are sort of magnetic and move towards each other. Can you help with how the code to make clones move towards each other might work?
I'm trying to make a button where it hides everything by using a broadcast, but I don't know how to hide the clones, can anyone help me? I can't find answers in this video.
Hi Bryan, thanks for your question. Short answer is yes. All the sensing blocks are still available (if touching other sprite). If you want to detet a specific sprite, that's where you'll need to check with IDs. If you broadcast an event, then every clone will receive it. If you want a specific clone to receive it, again, you'll need to use the ID method that's covered int he video. Let me now if that clears it up, or if it's something else you're wanting to do.
Can anyone help me please? I did the exact same thing he did but mine spins weird. It doesn't follow the arrow key properly and I'm not sure what to do.
I HAVE VERY IMPORTANT QUESTION WHY I CANNOT DELETE ONE OF MY CLONE IN SCRATCH because I can delete entire colony of clone if I use delete? Even you see all the help didn't seems know the answers... why?
hello! i know im really late, but i have a problem and idk how to fix it. so, i have been creating a fnf game in scratch, and im actually coding the notes, now, here is where the problem begins, i use clones and messages for the notes (e.x : send (left)) and when the left note recieves left, then it will show as a clone and it will move up, however, if i create too much clones, they just dont appear, they wont. i tried restarting scratch, remaking the game from 0, everything. it still happens, can you please help me? i got so excited to start with this game, and go so sad when i saw this problem.
Scratch has a 300 clone limit, so you won't be able to generate more clones if you've reached that limit. You'll need to delete clones before creating new ones. See if that helps your problem!
Nice, but the script broke after a while and the bullets wouldnt stop existing after hitting the wall, but only a enemy i made it hit. What should i do?
How would you then transfer the value of the local variable back to a new global one? For example, when you click on a specific bullet, a new variable is assigned the number of that bullet? When I try to do this by "set (variable) to bulletid" it doesn't choose a clone, it assigns 0, just as bulletid is listed at the top of your screen.
Hi SmartWittyName, thanks for your comment. In the video, we use a globalID, change it by 1, then make it the value of the localID. If you want to go the reverse, then just set the other global variable to the value of bulletID in the sprite clicked hat block. You've just gotta be sure that you've already set bulletID. Read the value of bulletID first and be sure that it's not already 0, if it is, you have a bug somewhere!
@@SurfingScratcher Thanks so much for replying! I found the bug - I had a different trigger for cloning in the script of another sprite, originally to prevent myself from cloning clones. After rearranging some things to use the isClone variable you showed in the video, it worked perfectly =)
Hi skruffles, my head's in a bit of a twist reading that. I'm going to rephrase to see if I'm understanding you. Sprite A (clone) wants to read the x,y position of Sprite B's (clone). You want Sprite A's (clone) to go to Sprite B's (clone)? You can store the x and y positions of clones in a list. If you use the 'id' approach that's in the video, then the item number of the list can refer to the 'id'. So if you have a list called xPositions, then item 1 would be the x position of the clone with id = 1. I'm curious to know what trigger (event/user interaction) prompts the Sprite A's (clone) to go to the xy of the Sprite B's (clone). Because if you know the target position based on a user event, you can capture those in variables. This approach acts like a bridge between the two. Good luck!
a little question: let's say i detect a collision with a clone, how do i get its ID? it's the last thing i need to finish up my ball physics engine (and just now i realised Griffpathc made a vid on it... whatever, doing it myself is more fun)
It's been a while since I made this. I'm guessing that I would try and read the local variable's value in the place where I'm detecting the collision. When you start as a clone, you're probably detecting some collisions there. You could 'wait until you collide with object and read its value then. Just some ideas.
@@SurfingScratcher i ended up writing my own collision system with lists of every clone's x pos, y pos, x vel, y vel, and radius. It works! God is vector math a pain in the ass when you only have the components And you're a 13 year old working with vectors for the first time
Should be doable. You'll just need to create a local variable for the clone that tells it which backdrop to follow or not to follow. Then when you switch backdrops, broadcast an event and get the sprite of the clone to check if its local variable is equal to that of the current backdrop.
I have a question for you because you seem like you know a lot about scratch. How could I make it so that my clone goes to a randomized piece of a(for example) 12 by 12 grid? I will send a link to the game in the reply section of this comment. Please respond in the comments of the game.
HI arcticwolf, you could probably just use some maths to help you out with this one. You'll have 12 x positions for each row. You'll have 12 y positions as well. The coordinates are just combinations of these. If each piece has an id, then you can locate its x and y position. The first 12 pieces will have id's from 1-12. Say you want id = 6. Well that's just going to be 6 x width of piece. All the y positions in the row will be different. You can also use the mod operator to figure this out. 6 mod 12 = 6, for the next row, 18 mod 12 = 6. Check out my video on Scratch operators including mod if that's confusing. For the y positions, you can just divide the id by 12 and round it to the floor or ceiling depending on how you like to do it. For example, 13/12 = 1.08. If you ceil that, it rounds it up to 2. Then you can just multiply the height of the piece by the result of the division. It will work for each row of you grid. Here's a project that creates a grid based on mods: scratch.mit.edu/projects/332495324 Okay, so now that you can calculate x,y coords based on an id, you should be able to send the clone of another sprite to that location.
Hi Shashi, thanks for your comment and question :) A clone is a sprite - it's a clone of a sprite. It 'inherits' all the behaviour that you've coded for the sprite you've cloned. The way to control it (like a sprite) is to use a 'When I start as a clone' hat block. That's the sprite way of saying (hey the green flag has been clicked, come into existence and do your thing).
Thanks soooo much. i was using just a bulletID which was global, so you can only use that variable at the INSTANT the clone is created, but with this i can use the local variable for the clone later on in the script and not have it interfere with the other clones. Maybe i'll link the project when i'm done if that's ok - it's simulating an ecosystem. Your videos are the best - they are clear and they are so professional looking, Happy Scratching!! :)
HELLO WORLD I am super late to this amazing video... I was making a battle cats not really a knockoff on scratch when I thought how to make clones die one at a time? thanks for the video helped me a lot
Great videos. Been teaching Scratch since 2015 and learned a thing or two from you. Thank you for sharing. Can you make two or more cloned ball sprites that are moving and bouncing bounce off each other? I can do this when they are the same color using touching color but what if they are different colors?
Hi Ken, thanks for dropping by with your comment. Pumped that you've found some value in the video! Here are two ideas that come to mind for me: You could probably wrap the color sensing blocks in the "OR" boolean blocks as a starting point. Though, that wouldn't account for a random color. A more advanced solution would be to track the x,y positions of the clones using a list. Then you would calculate the distance between the center's of each ball. If the distance is less than the radius of the ball, then you would have a collision. This solution would have some performance issues if you had lots of balls.
What are the differences between global and local variables? How do they work together? And what would happen if 'bulletID' was set to 'For all sprites'? Would it make any difference?
Yep, it would make a difference. That exact situation is explained in the video. 'globalID' is essentially the 'bulletID' that has been set to 'For all sprites'. It means that all clones will share this one value. No clone will have its own copy of it. When set to 'this sprite only' a clone will get its own copy of the variable. If the clone changes the value of the variable it only changes for that clone's copy, not any of the other clones. For all sprites = same value for every clone This sprite only = each clone has its own copy
Hey I'm trying to use Scratch clones for a Lives indicator. I read something about Clone IDs but I'm not getting it. Can you help me? I got as far as generating the Clones on the screen but I don't know what to do next.
If you wanted to create lives for each clone, then you would have a variable FOR THIS SPRITE ONLY called something like lives. Then, use a 'When I start as a clone' hat block to continually check if the clone should lose a life. Something like, if bullet touches clone then change lives by -1
Hi Jack, thanks for sharing. I suspect that you may have a go to position of gun in the space key press hat block. You will want to position the clone in the 'when I start as a clone' hat block.If you do it in the space key press, then it will apply to every clone and not the one that is created.
Hey! I've been working in Scratch and come across a really nasty problem. So basically, is there any way I can read a specific clone's coordinates/direction. Say, one that touches the player. This would truly help me a lot and you seem experienced. :)
Hi T and S Productions, thanks for your question. The 'id' system that's covered in the video can solve this issue. In fact, if you put your code inside the 'when I start as a clone' block and read the x and y reporter blocks it will report. You could use lists to make them global. Something like this: . . You'll need to assign a local variable called 'id' You'll need to create a list called x-coords You'll need to create a list called y-coords . . In the 'when I start as a clone' hat block, put a 'repeat until' block. Repeat until touching the player. Inside the repeat until, you could set the x-coords at the item location of the id and set its current x value. Do the same for y. Remember, this is only if you want them globally. I might make a video on this if it's confusing as I think it will help a number of people. But see how you go :) Good luck!
Um first sorry for bad English -Im using duplicate block to make bullets but if i shoot many bullets(duplicate many times), bullets stop duplicating. Im using scratch2 and am i have to use 3?- Sorry! Never mind me! I found that i didint put delete duplicate box lol thx!
Thanks for the feedback and it's useful to consider going forward. If you were to remake this clones tutorial, what themes/props would you use in its place?
SCRATCHY QUESTION: What is one reason why you might use local variables with clones?
i'm creating a project where you need to detect clones by the actions, imma use that localID for in-script detection
For commonly used variables like "i" ;D
I am trying to make electric field arrows do different things (depending on their distance and direction from charges)
@Spectral Penguin Check out my video on health bars: ruclips.net/video/fm9QJ9yk1jw/видео.html
You should be able to use a local variable for the 'life' of each enemy. You could also clone the healthbar and peg it to the position of your clones, but you'll probs need to store xy locations in a list to help you out. A big task, but doable!
For making the multiple enemy as a clone with its local variable store as it’s health. So your tutorial really helps me out a lot! Thx bro
Yo thanks! This tutorial didn't just teach me how to do a specific thing it actually made me understand the concept. I never knew that local variables actually did that for clones as, and the fact that you explained the fact that it will say 1,2,4,8 and stopped that pitfall was a huge help. Using this tutorial I was able to make something almost entirely different than the showcased example, and thats a testament to how good a job it does teaching fundamentals!
i was making a space shooting game and the clone of the laser i had made had a variable named health and wanted to decrease the number of the variable when the clone of the laser touched that sprite and this helped me a lot in that game, thanks for the video.
FANTASTIC! Exactly the answer I was looking for. I'm creating a bubble particle system, where a bubble sprite is cloned, then each clone floats up at random speed until they reach a certain point when they pop. At this point I wanted to delete the clone and reset, having a new clone respawn and begin its cycle again. Each time the respawned clone ended up duplicating all 15 bubbles in the system. Agh. This global/local var technique will help me fix that. Awesome, thanks! Hope you caught that wave. Cheers dude.
I’m working on an Undertale-inspired game with blasters (multiple may be on screen at once, so the blasters themselves had to be clones). I used a local variable to determine whether the clone was the blaster (shooter) or the blast (bullet, to some extent??), and depending on what the variable is, it behaves either like a blaster or a blast. This video really helped me, thanks!
Unreal, thanks for sharing your experience and what you're working on MrG4meLover!
dude same lol
I have been stuck with a problem for a while. Can you make a sprite go towards the closest clone of another sprite?
Yeah you should be able to. The trick is to keep track of all the clones using local variables. You'll have to loop through all the clones and get the x and y coordinates and check to see which is the closest to the sprite you're interested in.
@@SurfingScratcher Thank you very much! I ended up just making three different sprites instead of clones of the same one, but I'll use this technique if I want to expand the project.
Thank you so much, I needed a tutorial on how to detect which clone was being clicked, and this helped a lot!
my game goes smoothly and the bullet works fine but when you play for like a minute the bullet and my enemy stops making clones suddenly, do you know how to fix this? pls help
Hmm check that your clones aren't making clones. Scratch has a limit of around 300 clones, so you could have maxed out. That bug is demonstrated and fixed in the video. How can you check this? Count the number of clones you have on the screen and use the 'say' block to print its id number. They should match.
@@SurfingScratcher neva mine sorry i just forgot to use the "delete this clone" block and it kept on maxing out because i didnt delete any clones. Thx
tysm, i was making a card game and this helped me so much mostly specific clones!
Thanks for sharing!
Nah, this awesome channel surely deserves more views, likes, shares & subs. Unfortunately I dont have any friends who are into Scratch and the programming stuffs like me :'(
same :(
Essential for trying to build a city maker or simulator game. Where when you place houses down and I want to program the sim going to his job with a car. So the houses are clones. And I figured out, how the list will record a spawn. It can record the clone's x and y positions and you can make it wait for 10 seconds until it does record the value if you need a lot of time. Then i'll try to make the car clone come out of that x and y position that was recorded for the house clone's x and y coordinate. Ultimately trying to get to an industry's or commercial's x and y. All the properties are either R, C or I (or just 3 different) types of clones. How Sim City would divide it's zones.
omg I'm so stupid, I've been trying to find a way to make a clone visible while the original sprite still stays hidden thank u so much
the video helps me for a game thx
Thank you wery much, for a MONTHS ive been thinking how to give clones names. And now i know how.
how do you hide the sprite but show the clones?
I have a question thats gonna really help me out
I wanna do a sprite that points to the closest clone.
Great question! You'll need to track the x and y positions of clones in a list so that you can check to see which is the closest.
You're not gonna be able to point in the direction of that clone using a built-in block. Instead, you'll need to use trigonometry based on the x and y coordinate that you've got from your list.
Thankfully, I've just done a whole series on trig. Check out this video, it'll give you some clues: ruclips.net/video/kxRywPEUfcc/видео.html
@@SurfingScratcher That's really hard but. I JUST SPENT 4 WHOLE DAYS TO FIND THAT ANSWER. MASSIVE THANKS!!!!!
6:35 im late to the party, but when you fire a bullet, the other existing bullets also create a clone of their own as you have the event to create a clone on the sprite itself.
Yes, you may well have spotted a bug!
Thank you so much! I had a problem where the clone button cloned all of them. So glad to understand why and understand how to overcome that problem.
Ace, thanks for sharing!
Hi, I got a question, how did u make the gun move along the turret body when pointing towards the mouse pointer ? my gun seems to move weird
AHHH ITS SO SIMPLE AS TO JUST MAKING IT FOR THAT SPRITE ONLY!!!!! THANK YOU SMMM
7:00 you can also do
When green flag clicked
{; forever
If
Create clone of (myself)
;}
The issue is you can trigger it without the green flag
It also makes the isClone variable obsolete, because green flag is for original sprite but space key applied to both original and clones
Also I subbed
Thanks, I've been making a silly game on scratch and got stuck with cloning issues
Thank you so much for this video!! It helped a lot, and wasn't one of those six-hundred-million-hour-long tutorials you see all the time! Ha!
This helped A LOT with my Paranoid Animation Meme, which I'm still working on as of now, but I'm done with the intro!
In the intro I had to have FOUR CLONES all doing different things. I always wondered how to do this!! This is going to help a LOT with so many other things, such as animations with a limit of one sprite, and even more animation and code memes!
Thank you again!
~Sunset
Awesome, thanks for sharing your experience Sunset. Loved reading it :)
@@SurfingScratcher Thank you for the tutorial! :D
thanks man, you saved me, im making an ANT simulation but i didnt know how to refere to a specific ant of the colonyK
I was having trouble that the isClone? Fixed. Tbh I do not understand how that fixes my problem but thanks a ton. I tried (here and there) for hours to figure out the solution for my tycoon and it was here the whole time
can you help me please. why bulletld (for this sprite only) not show when (set bulletld to globalld). thank you
im making an evolution simulator, but i cant figure out how to make the animal go towards the closest food clone
Great content. Please keep it up.
Thank you so much! I just found out how to make a path generator with this :)
Ooh nice work!
I am making a paddle and ball game like scratch tutorial. I want to make another ball appear once the score reaches a certain number. Can I do this with clones? Or would I need to create another sprite?
How do i make clone point to other clone if they are enough close to each other
How can you make the clone not overlapping on each other?
this is helping my water physics engine thank you so much!
is there a way for clones, to have clones for themselves ?
like a clone all to themselves with their own properties
Hi, I’m working on a game where I want to be able to create clones that are sort of magnetic and move towards each other. Can you help with how the code to make clones move towards each other might work?
hello, i would like to make clones with differents script and differents costumes in one sprite. How can i do that plz ?
I'm trying to make a button where it hides everything by using a broadcast, but I don't know how to hide the clones, can anyone help me? I can't find answers in this video.
maybe i be late but i wanna know if clones can interac with other clones (from other sprites)
Hi Bryan, thanks for your question. Short answer is yes. All the sensing blocks are still available (if touching other sprite). If you want to detet a specific sprite, that's where you'll need to check with IDs.
If you broadcast an event, then every clone will receive it. If you want a specific clone to receive it, again, you'll need to use the ID method that's covered int he video.
Let me now if that clears it up, or if it's something else you're wanting to do.
This helped me SO MUCH. Thank you!
Brilliant!
It's very helpful for me to develop my first scratch project. Thank you for your video.
Can anyone help me please? I did the exact same thing he did but mine spins weird. It doesn't follow the arrow key properly and I'm not sure what to do.
I need to replace objectives in lists with the local variable of clones but it doesn't seem to work. Why is this?
I all unable to make that man pls help the bullets attend visible, they aren't moving... Pls help
I HAVE VERY IMPORTANT QUESTION WHY I CANNOT DELETE ONE OF MY CLONE IN SCRATCH because I can delete entire colony of clone if I use delete? Even you see all the help didn't seems know the answers... why?
Really cool, this enhances my understanding and shows me how little I know. Amazing stuff!!!
Good on you for checking it out and expanding what you know:)
THank You so much you very helped me
hello! i know im really late, but i have a problem and idk how to fix it. so, i have been creating a fnf game in scratch, and im actually coding the notes, now, here is where the problem begins, i use clones and messages for the notes (e.x : send (left)) and when the left note recieves left, then it will show as a clone and it will move up, however, if i create too much clones, they just dont appear, they wont. i tried restarting scratch, remaking the game from 0, everything. it still happens, can you please help me? i got so excited to start with this game, and go so sad when i saw this problem.
Scratch has a 300 clone limit, so you won't be able to generate more clones if you've reached that limit. You'll need to delete clones before creating new ones. See if that helps your problem!
@@SurfingScratcher thanks! I will try that later
How do I make the turret to do that
thank you so much this helped me a lot
Nice, but the script broke after a while and the bullets wouldnt stop existing after hitting the wall, but only a enemy i made it hit. What should i do?
You'll want to sense if touching the wall and then delete the clone once it's true.
@@SurfingScratcher Thanks
Thank you! I been trying to figure out how to do this for so long. ❤️
Boom jellyjam14blas! Thanks for dropping your comment. I'm pumped to hear you found value in the video. Keep your code on 😎
Thanks mate!
Really diggin’ that t-shirt, it is a really creative design!
Oh totally, it's probably my fave!
Why when I am making a clone, his script isn't working only if I click on it
Great video, it really helped me out with my script, thank you.
How would you then transfer the value of the local variable back to a new global one? For example, when you click on a specific bullet, a new variable is assigned the number of that bullet? When I try to do this by "set (variable) to bulletid" it doesn't choose a clone, it assigns 0, just as bulletid is listed at the top of your screen.
Hi SmartWittyName, thanks for your comment. In the video, we use a globalID, change it by 1, then make it the value of the localID. If you want to go the reverse, then just set the other global variable to the value of bulletID in the sprite clicked hat block. You've just gotta be sure that you've already set bulletID. Read the value of bulletID first and be sure that it's not already 0, if it is, you have a bug somewhere!
@@SurfingScratcher Thanks so much for replying! I found the bug - I had a different trigger for cloning in the script of another sprite, originally to prevent myself from cloning clones. After rearranging some things to use the isClone variable you showed in the video, it worked perfectly =)
Seus vídeos são excelentes..OBRIGADOOO
Is it possible to find the x,y position of a clone with another sprites clone and have the other sprites clone go to the clone
Hi skruffles, my head's in a bit of a twist reading that. I'm going to rephrase to see if I'm understanding you.
Sprite A (clone) wants to read the x,y position of Sprite B's (clone). You want Sprite A's (clone) to go to Sprite B's (clone)?
You can store the x and y positions of clones in a list. If you use the 'id' approach that's in the video, then the item number of the list can refer to the 'id'.
So if you have a list called xPositions, then item 1 would be the x position of the clone with id = 1.
I'm curious to know what trigger (event/user interaction) prompts the Sprite A's (clone) to go to the xy of the Sprite B's (clone).
Because if you know the target position based on a user event, you can capture those in variables. This approach acts like a bridge between the two.
Good luck!
@@SurfingScratcher yup you got it and this helps me alot, thanks!
a little question: let's say i detect a collision with a clone, how do i get its ID?
it's the last thing i need to finish up my ball physics engine (and just now i realised Griffpathc made a vid on it... whatever, doing it myself is more fun)
It's been a while since I made this. I'm guessing that I would try and read the local variable's value in the place where I'm detecting the collision.
When you start as a clone, you're probably detecting some collisions there. You could 'wait until you collide with object and read its value then. Just some ideas.
@@SurfingScratcher i ended up writing my own collision system with lists of every clone's x pos, y pos, x vel, y vel, and radius. It works!
God is vector math a pain in the ass when you only have the components
And you're a 13 year old working with vectors for the first time
@@Piokoxer I think you're epic! Great work on solving your own problem :)
How can I delete a specific clone?
Very helpful
Do you know how to hide clones on a certain backdrop? Then show them on another
Should be doable. You'll just need to create a local variable for the clone that tells it which backdrop to follow or not to follow.
Then when you switch backdrops, broadcast an event and get the sprite of the clone to check if its local variable is equal to that of the current backdrop.
I didn't realize local variables are also local to clones. I've been encoding information in costume number and direction😢.
I have a question for you because you seem like you know a lot about scratch. How could I make it so that my clone goes to a randomized piece of a(for example) 12 by 12 grid? I will send a link to the game in the reply section of this comment. Please respond in the comments of the game.
HI arcticwolf, you could probably just use some maths to help you out with this one. You'll have 12 x positions for each row. You'll have 12 y positions as well. The coordinates are just combinations of these.
If each piece has an id, then you can locate its x and y position. The first 12 pieces will have id's from 1-12.
Say you want id = 6. Well that's just going to be 6 x width of piece. All the y positions in the row will be different. You can also use the mod operator to figure this out. 6 mod 12 = 6, for the next row, 18 mod 12 = 6. Check out my video on Scratch operators including mod if that's confusing.
For the y positions, you can just divide the id by 12 and round it to the floor or ceiling depending on how you like to do it. For example, 13/12 = 1.08. If you ceil that, it rounds it up to 2. Then you can just multiply the height of the piece by the result of the division. It will work for each row of you grid.
Here's a project that creates a grid based on mods: scratch.mit.edu/projects/332495324
Okay, so now that you can calculate x,y coords based on an id, you should be able to send the clone of another sprite to that location.
how 2 create a specific amount of clones?
like if i wanna create 3 clones, i just wanna create 3 clones
@@ppcat8630 put ' create a clone' in a repeat 3 times block. Do it on a green flag press.
Is there a way I can make clones act like sprites?
Also, you make awesome informative videos.
Hi Shashi, thanks for your comment and question :) A clone is a sprite - it's a clone of a sprite. It 'inherits' all the behaviour that you've coded for the sprite you've cloned. The way to control it (like a sprite) is to use a 'When I start as a clone' hat block. That's the sprite way of saying (hey the green flag has been clicked, come into existence and do your thing).
omg thankyou, my shooter is playable
THAAAAAAAAAAAAAAAAAAAAAAAAAAAAANKS BRO
Thanks soooo much. i was using just a bulletID which was global, so you can only use that variable at the INSTANT the clone is created, but with this i can use the local variable for the clone later on in the script and not have it interfere with the other clones. Maybe i'll link the project when i'm done if that's ok - it's simulating an ecosystem.
Your videos are the best - they are clear and they are so professional looking, Happy Scratching!! :)
Awesome, Gavin! So pumped to hear that you found some value in the video and thanks for the supportive feedback :)
HELLO WORLD I am super late to this amazing video... I was making a battle cats not really a knockoff on scratch when I thought how to make clones die one at a time? thanks for the video helped me a lot
Thanks for sharing your experience :)
@@SurfingScratcher no problem this is such a good tutorial!
Great videos. Been teaching Scratch since 2015 and learned a thing or two from you. Thank you for sharing. Can you make two or more cloned ball sprites that are moving and bouncing bounce off each other? I can do this when they are the same color using touching color but what if they are different colors?
Hi Ken, thanks for dropping by with your comment. Pumped that you've found some value in the video!
Here are two ideas that come to mind for me:
You could probably wrap the color sensing blocks in the "OR" boolean blocks as a starting point. Though, that wouldn't account for a random color.
A more advanced solution would be to track the x,y positions of the clones using a list. Then you would calculate the distance between the center's of each ball. If the distance is less than the radius of the ball, then you would have a collision. This solution would have some performance issues if you had lots of balls.
It was that easy and i just tried to make something with lists
you are so cool!!
What are the differences between global and local variables? How do they work together? And what would happen if 'bulletID' was set to 'For all sprites'? Would it make any difference?
Yep, it would make a difference. That exact situation is explained in the video. 'globalID' is essentially the 'bulletID' that has been set to 'For all sprites'. It means that all clones will share this one value. No clone will have its own copy of it.
When set to 'this sprite only' a clone will get its own copy of the variable. If the clone changes the value of the variable it only changes for that clone's copy, not any of the other clones.
For all sprites = same value for every clone
This sprite only = each clone has its own copy
Hey I'm trying to use Scratch clones for a Lives indicator. I read something about Clone IDs but I'm not getting it. Can you help me? I got as far as generating the Clones on the screen but I don't know what to do next.
If you wanted to create lives for each clone, then you would have a variable FOR THIS SPRITE ONLY called something like lives. Then, use a 'When I start as a clone' hat block to continually check if the clone should lose a life.
Something like, if bullet touches clone then change lives by -1
Thank you very much :)
My pleasure, bud :) Pumped you found it useful.
scratch is not only for childrens is also for older peoples
Mine makes more than 1 clone for some reason
my clones all teleport to the gun when i press space
Hi Jack, thanks for sharing. I suspect that you may have a go to position of gun in the space key press hat block. You will want to position the clone in the 'when I start as a clone' hat block.If you do it in the space key press, then it will apply to every clone and not the one that is created.
@@SurfingScratcher thank you
Hey! I've been working in Scratch and come across a really nasty problem. So basically, is there any way I can read a specific clone's coordinates/direction. Say, one that touches the player. This would truly help me a lot and you seem experienced. :)
Hi T and S Productions, thanks for your question. The 'id' system that's covered in the video can solve this issue. In fact, if you put your code inside the 'when I start as a clone' block and read the x and y reporter blocks it will report. You could use lists to make them global. Something like this:
.
.
You'll need to assign a local variable called 'id'
You'll need to create a list called x-coords
You'll need to create a list called y-coords
.
.
In the 'when I start as a clone' hat block, put a 'repeat until' block. Repeat until touching the player. Inside the repeat until, you could set the x-coords at the item location of the id and set its current x value. Do the same for y. Remember, this is only if you want them globally. I might make a video on this if it's confusing as I think it will help a number of people. But see how you go :) Good luck!
@@SurfingScratcher With your advice, I managed to make it work! Thank you so much :)
@@leopaveley Unreal banana peel!
Um first sorry for bad English
-Im using duplicate block to make bullets but if i shoot many bullets(duplicate many times), bullets stop duplicating.
Im using scratch2 and am i have to use 3?-
Sorry! Never mind me! I found that i didint put delete duplicate box lol thx!
i have the same problem but i don't know what a delete duplicate box is, can you pls tell me? :)
I want clones that spawn in clones
eu entendi 85% vou ver de novo pra entender 100%😅😅😅😅
didn't work, now i cant even fire once.
I'm gonna make a game out of this. Also, this comment is the 100th comment!
WOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
i understood none of that
Watch it again!
I'm learning Combine from Apple at the moment and I need to rewatch content sometimes to help build my understanding.
ཨའི ཕུན ཚོ ཚོ པ རི ཤོ
great to have a clone tutorial. But please don't make them of weapons. Please make it gender neutral and peaceful. thank you
Thanks for the feedback and it's useful to consider going forward. If you were to remake this clones tutorial, what themes/props would you use in its place?
dude just put when space clicked create clone of myself wait until not key space pressed