Unity 2D : How to make a perfect clone of my Game Object?

Hello
I have a gameobject rock in my game scene and I cloned it and made it appear in the same position after it exits the game scene by using OnBecameInvisible but the problem I am facing is that after it re-appears it’s actually a bit faster and just like that a bit more faster in the next turn and it keeps increasing. I tried using delta time but after using this the Rock doesn’t even re-appears
I have 2 rocks coming from both side of screen and hitting the ground and exiting the game scene, but I want my gameobject (rocks) to follow the same path and speed just like in the initial run but it changes right after they re-appears and keep changing one of the rocks even disappear after 3-4 runs(w/o delta time)

Please help me with the script I am new to unity…
Thanks everyone

In the picture that I attached is how the initial run goes but after that it just changes and I want it to keep following the same path, should I not clone and do prefab ? If yes please help me with prefab script so that my object pooling is just like the original one. Thanks a lot

Hi there,

It seems like that rock is saving the speed that it has when it exits the scene. So when you clone, you start with that speed instead of starting without any speed.

To avoid this, and believing that the rock has a Rigidbody attached to it, you have to set its velocity to 0 when it exits the scene.

yourRock.GetComponent<Rigidbody2D>().velocity = Vector2.zero;

If your rock does not have any rigidbody attached to it… We will need some more information about your scene and components.

Hope it helps.

@rufopufo

Hey there, @Bunny83 @thor348k @Eric5h5 @crazyKnight @SirCrazyNugget can anyone help me with this? i am abit new i hope someone can help me, Thanks! :smiley: