Dont know how to make collectibles or scene change

so the game im trying to make is where you need to collect a certain ammount of things and when you do you can go to the door and leave then it takes you to the next scene.

-dont know how to make collectibles

-dont know how to make the door take you to another scene when you touch it (and only when you have the correct ammount)

-also cant figure out how to make something spin but thats not a very high priority right now

ALSO for some reason whenever I copy and paste the script it just doesnt work, but it does work when i have it in a downloadable file so can someone plz send me direct file or someone elses thing that i can download from

ANYONE WHO HELPS will be put in the credits (if they want to be)

Hi @Cuddles_The_Cat,

For collectibles you can easily use the collision component on any entity, to subscribe to collision events in your code and get informed whenever the players “interacts” with that entity. From there you can disable/destroy it and keep track of how many the player has collected.

Here is a good tutorial on collisions and triggers to get you started:

The door can use a similar trigger, so when the player touches it you execute a method that does one of the following two:

  • positions the player at some other portion of your game world, if you are putting all levels in the same scene. You can have multiple levels in the same scene by enabling/disabling entities that correspond to the different levels.
  • use different scenes all together, one for every level, and implement a scene changing script. Here is a sample project for this:

To rotate an entity around its Y axis, to make it spin, you can easily do that in a script attached to the entity, in the update method:

MyScript.prototype.update = function(dt){
   var rotationSpeed = 10;
   this.entity.rotate(0, rotationSpeed * dt, 0);

i put it in exactly, it didnt work

thanks for trying i guess

but the only way i can make ANY script work is if i download it and use the file. even if i put it in exactly the same way, it just does not work.

no matter what i do, it never works. nothing i do is good enough.

The code Leonidas posted is a fragment of code that needs to be placed in a script.

It seems likely to me that you need to take a step back and review some simple projects and or work through some tutorials to get an idea of how the various parts of PlayCanvas work together and how scripts are structured and organized. This page is a good place to start:

If you aren’t already a programmer, PlayCanvas can be fairly difficult at first. But once you get the grasp of a few key concepts and how scripts are structured, it gets easier (which is not to say that it gets easy). What has worked for me is to fork a tutorial project and then use it as a “sandbox” to try out different ideas. Every time I want to do something new, I experiment with that one thing in some simple project where I have some basic inputs like a button to push already set up.

Other simple sample projects can be found here:

1 Like

i cant find anything that has what i need though

Start simple, grab a number of tutorials from the Playcanvas developer site and try building them yourself.

Slowly you will gather experience and you will start feeling more confident where to start and how to structure your questions in the forum.

1 Like

You’ll find a way just don’t give up.I felt exactly like you at times but I didn’t give up now look I’m running one of the biggest self made games on this website and soon on mobile.Just ask yourself what am I really trying to do,then find out what your really trying to do ,next take the challenge step by step no rushing

The tutorials seldom have “exactly” what you need. But they often have some significant chunk of what you need. So fork one and give it a try. Keeping it simple helps to avoid confusion. If/when you get stuck, you’ll also have a simple project that you can refer others to where it will be easier to see what is going wrong.

1 Like

I found this out on Thursday but in the editor, not the code menu you assign the attributes of the script like in the thing I am working on right now.

It is the part at the bottom

Strange seeing this post brought up again. Dont worry everything worked out fine.