Making clones and moving them

i am making a game that you a human is holding a gun that you can aim that you shoot to destroy meteors

i have already prepered things like rotation and menus but have no idea how to to make spirtes so my gun can shoot and make it so that

i know it can be done since someone made a game non newgrounds called puking duck
where the duck pukes(shoots) out circles
so if anyone knows how to do it can you teach me pls :slight_smile:


Hey @mlgcoolguys_1, welcome to the forum!

The interaction you’re looking for here is the object.clone() method.

If you have a character/object on screen, you can name it, then us the clone method like this to get a copy.

// Cloning
var myClone = object.clone();

You can move that clone around, or give it more information to use, by saying, like this:

// Move the clone to 50, 100    
myClone.x = 50;
myClone.y = 100; 

// Give the clone a "speed" value to use later.
myClone.speed = 5;

I’m attaching an example that shows you how to then allow objects to interact with clones. The easiest way is by using hitTest on a clone and another object. You can do this, by looking through all of the clones of an object like this:

// Go through all clones and see if they hit me.
for (var c of myClone.clones) {
    if (this.hitTest(c)) {
        this.remove(); // Delete this object
        return; // Stop checking.

In the example, I delete rain drops, and allow other types of clones to play an animation, but you can really do anything! (I need to add this example to the website, it’s super handy!)

We’re happy to help, just reach out if you need any more assistance!

CloningDemo.wick (58.1 KB)

so like this?
if (key === “space”){
var bullet = object.clone(1);
bullet.x = 50
bullet.y = 100
bullet.speed = 5
for (var c of bullet.clones) {
if (this.hitTest©) {


Hello! I am the creator of the game you mentioned called “Puking Bird”.
There is a simpler way to shoot bullets without using the clone function.
I used a tween to make the bullet go 200 units up.
Here’s how I did it.
First, I’ll show the timeline.
This is the timeline for the mode in Puking Bird where you can shoot.
I’ll go layer by layer explaining what these frames do.
First, there’s the top layer which covers all of the frames below it.
The highlighted frame is the gameplay frame.
This is where the bird and meteors are.
The frame is as long as all of the frames below it combined so no matter what frame it’s on, the gameplay is still showing.
The code for this frame is as follows:
That’s all it is.
When the game ever goes into that specific spot, it stops.
Now, it’s time to move on to the second layer.
The first frame is simple enough.
In this frame, the bullet is following the bird, hiding behind it.
The bullet has this code for it:
Every tick on this frame, this code is ran:
this.x = bird.x
this.y - bird.y

When a key is pressed, this code is ran:
if (key === “space”) {
project.pukego = 1

This makes project.pukego = 1, and to explain what that does, I’ll show you what the code for the frame does.
This code is ran on this frame:
Every tick, this code is ran on this frame:
if (project.pukego === 1) {
project.birdlast = bird.x

By default, project.pukego = 0.
When project.pukego = 1, it saves the bird’s x coordinate and then it goes to frame 7 and plays.
Now, we move on to this frame.
The bullet only has one line of code.
Here is the code:
Every tick on this tween, this code is ran:
this.x = project.birdlast
On the last frame, when space was pressed, it set project.birdlast to the bird’s x coordinate when space was pressed.
This means that the bullet will travel in a straight line without moving to the left or the right because of the tween.
This frame has these lines of code:
project.pukego = 0

So, it resets project.pukego and goes to frame 6, or the start.
Now it’s time to discuss the last layer and the last frame (with code).
Every time that it enters that frame, this code is ran:
project.birdlast = bird.x
The gameplay is still running through this whole thing, so when it goes back to the frame where it started, the bullet starts behind the bird.
If this is too confusing for you, then I linked the .wick file if you want to inspect it.
Puking Bird (2).wick (20.6 KB)


Great suggestion @DylanExists! This is also a totally valid way of making projectiles / moving objects in Wick Editor!

1 Like

does this work with rotation as well
and i also need help for making the metetors move to the left

yes, it does work with rotation

sorry for the wait but my i know where you hid the animation on the cloning demo
i also want to put a thing in my code so that the player cant scam click and shoot many times and glitch my game (according to my tests)

For the first one, when you select a clip, there’s a button called “Edit Timeline”. That’s where I hid the animation.
For the second one, do you mean that you want to have a period between when the bullet ends and when you can fire again, sort of like a reloading time? You can do that. I’m going to refer to the explanation I used on the first comment I posted on this thread. You can add an empty frame between the 2nd and 3rd frame on the 2nd layer and elongate it to the amount of time you need. Just make sure that all of the other frames on the other layers line up.

1 Like

thanks :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face:

1 Like

Hi I am making an interactive zombie shooter game how would i clone the bullets to go forward until they hit a target from wherever the player is at

Hello new person. Using the hit test function will help you with that
if (this.hitTest(something))
And the something is the bullet, so in the something update script, insert this code
this.x -= 7
That makes the something go 7 steps each frame.

you mean 7 pixels each frame? a millisecond per frame is like 1000 fps.

I think a millisecond is a frame

Actually, it depends on your fps (which stands for frame per second). That can be set from the settings.

1 fps would be 1 frame every second. So an fps of 1k would be a frame per millisecond

Cloning the bullet based (UPDATE OR KEY SCRIPT)
//Switch "e" with name of your key
var bc=bullet.clone();
//set direction & speed

//change wall with the name of your object
About names

Change “bullet” with the name of your bullet
Change “wall” with the name of your wall
Change “player” with the name of your player

I didn’t try this, but it should clone a bullet to where the player is, have it move right (you can change direction depending on the player’s position), and have the bullet removed after it hits a wall. Let me know if you’ll need any help with this