Adding Collectables and scoring

https://playcanvas.com/editor/scene/2216001

Having trouble with the star added as a collectible. should collect and add to the score.

Any help is appreciated

Hi @Ashley_Solano!

It seems your script for item collection is not attached to any entity.

Could you please try attaching the script to the correct entity?

Thank you, I have many versions I am trying to work with to compare. I attached the collectable script to the Star Collectable.
I am getting an error on my play button :melting_face:
Editor Link

Scripts

It looks like you need to parse the GameManager script, because I can’t see the attributes in the editor (on your Root entity). You probably also need to assign the correct entity.

copyImage

the tutorial I am following puts in in the root entity so I am not sure what other one would work. When I hit parse the attributes did not show

Looks like you are missing these steps in the tutorial (time stamped)

Okay I fixed the button error, but now with my collectable added, my obstacles are no longer showing up and my collectable is not moving along the ground as desired either.
Is something now interfering with the obstacles script?
Thanks for all the help!
Updated Link

Where’s the code that moves it?

It has the same come now as the obstacles. They have all since disappeared.

You have a number of issues in the project that I don’t really have time myself to go through in detail but here are some of the issues that I saw:


Having the collectable and obstacle script on the same object is probably not a good idea as the obstacle script has specific code and logic for obstacles.

image

I would either move the code out of obstacles that makes it move into a new script called ‘moveLeft’ so that it can be used on any entity. However, doing this means that you are no longer following the tutorial.

It might be easier to copy the code that moves the object from the obstacle script to the collectable script.


In the obstacle script, Obstacles:StartGame and Obstacles:Reset events are not fired from anywhere else in the code base so those listeners you have don’t run


The render object of the obstacle has moved very far away from it’s parent and therefore the collision. You can see the grey obstacle on the left is not near the collision box on the right in this image