How do I respawn the Coin/Sphere that already collected?

var Coin = pc.createScript('coin');

Coin.prototype.initialize = function() {

    this.entity.collision.on('triggerenter', this.onCollision, this);


Coin.prototype.onCollision = function(event) {



1 Like

Hi @lowprioismylife and welcome! If you mean you want to add a new coin to your scene, you can create a template for you coin and instantiate this template.

1 Like

this is my game that I created and I’m just new
I just want my coins to respawn again after I collected it
Is there any solution to this?
Thanks in advance :blush:

First of all, if you want to keep the coin in the game you don’t want to destroy the entity, like you do right now. I’m not sure what you mean with respawn in this case. Do you want to change the position of the coin, if the coin is collected?

Yes please

You could also try disabling the coin and having some kind of a master script to reneable it after a certain amount of time. I did this at one point.

1 Like

You need a reference for your new position first. That can be the position of an entity in your scene or a position that you create by script. Then you can set the position of your coin.

var newPosition ='NameOfEntity').getPosition();
var newPosition = new pc.Vec3(0, 0, 0);
1 Like

This really helps. Thank you so much sir

Sir I still have a problem, can you please check this

Can I see your game?

No need to call me ‘sir’, but what is the problem?

1 Like

After I collected the coin 4 times, it does not reach my player anymore because of the script in my platform movement

try making some clones of the coins

1 Like

I see you solved the issue already. Well done! :ok_hand: