Hello, this is my first time using Playcanvas and been struggling with understanding coding lately. I’m making a simple 2D game where my character collects items to achieving the game’s objectives. I plan to trigger an object to appear when you collect a certain item, but I don’t know how to spawn the item when a certain item’s collected. How does the coding work? Thank you :"<
Hello @amara1105 and welcome!
I would take a look at this example. It takes you through on how to complete a game with PlayCanvas. I believe it covers the game mechanic you’re describing!
Hello, thanks for the welcome! Thank you so much for responding to my concern! Yes, this seem to be the kind of game mechanic I’m looking for! Is it also possible to spawning maybe 2 more items and when it gets collected, 2 appears? Thanks again!
Yes, of course. Once you get a good grasp of the game mechanics you can alter them as you like!
Hello! I just came back from the crash course tutorial and it’s pretty overwhelming but I understand it! Though, is there a simplified version of the code without the timer and specifically focuses on triggering items only? Thanks again!
Really glad you understood it! Maybe you will need to study a simpler project, like this tutorial: Collision and Triggers | Learn PlayCanvas
Once you understand this, you will need to figure out how to spawn items in the right event
Hi, Ms. Christina! It’s me again. I was able to do simple collision recently (like, collecting an item) but somehow I still struggle to enhancing my mechanic of spawning items. I read about this Programmatically Creating Entities | Learn PlayCanvas and it’s about creating entities but the tutorial is pretty overwhelming in my basic level. Maybe a simplified version of spawning objects in 2D can do since I get confused with 3D. Thank you for being patient with me :"(
Hey @amara1105 ,
Here is a simple project I’ve done in the past, it’s a simple cube spawner. Pretty simple and straight forward. Take a look here: PlayCanvas 3D HTML5 Game Engine
@Christina , the project is blank on master ?
Ah, yeah, actually you need to press space to start spawn cubes
The code is inside
Ahm… That’s weird I just opened it and there was an asset folder with scripts. There was no branch created as well. I just stepped outside let me take a look once a get back.
Oh, you were right! I had a branch and totally forgot about it. I will switch to master once I get back. Sorry about that!
It is now fixed.
Here is the link again: PlayCanvas 3D HTML5 Game Engine
This is amazing! Fully understood it now, thank you so much Ms.Christina!! I really appreciate this